29 Commits

Author SHA1 Message Date
57597bf8a2 xC: move TEXT_* constants where they belong 2022-08-27 15:06:28 +02:00
c0996fcbe7 xC: normalize BSD Editline's history behaviour
Now it's a realistically useful frontend.
2022-08-27 15:06:27 +02:00
03d8ea4c5a xC: general.save_on_quit -> general.autosave
Power outages and similar situations make the former unreliable,
so get rid of any false promise it might seem to give.
2022-08-27 09:15:38 +02:00
dc002a2db4 xC: revise configuration options
This commit constitutes a breaking change to old configurations.

All behaviour.* options have now become general.*, with the following
few renames as exceptions:

 - editor_command -> editor
 - backlog_helper -> pager
 - backlog_helper_strip_formatting -> pager_strip_formatting
2022-08-27 09:15:37 +02:00
a32916ffcf xC: label code sections better
Introduce tildes as a new sublevel of markers.
2022-08-27 09:15:37 +02:00
f7be510d26 xC: make fancy-prompt.lua alignment more reliable
And generally clean up that script.
2022-08-27 09:15:37 +02:00
83764d1e1b Fix xB.adoc parsing with current libasciidoc 2022-08-24 03:17:05 +02:00
a717782480 Build with AsciiDoc as well as Asciidoctor 2022-08-24 00:13:51 +02:00
c50c959f4d Bump copyright years 2022-08-17 18:27:52 +02:00
0dd7536b5a Update README 2022-08-15 15:49:59 +02:00
0750096827 xC: expand behaviour.editor_command examples 2022-08-14 20:27:30 +02:00
49d9980662 xC: improve backlog helper capabilities
Snippets now receive positional parameters in the form of the buffer's
name in the locale encoding, and a filename if applicable
(we keep passing stdin along with the filename, which happens to
work out well for less(1)).

The default value of the configuration option also no longer uses
the "long prompt", which used to unhelpfully tell position in terms
of lines, but rather sets its own prompt that counts pages,
and makes sure to indicate the source buffer.

The main motivation behind this change is to make the 'v' command
work in less(1).  LESSSECURE must be omitted from the snippet
for this to work.

Bump liberty to receive a config parser that allows for less
convoluted escaping.
2022-08-14 18:52:26 +02:00
2f7fbcdc5d CMakeLists.txt: fix a typo 2022-08-12 13:21:46 +02:00
ef0cbe9a59 Rename the project
It is about to see some extensions, obsoleting the number three.
2022-08-07 10:40:42 +02:00
2d8808d795 utm-filter.lua: mention the passing of fbclid 2022-07-18 17:59:28 +02:00
60d52ad479 xC, xD: add basic WALLOPS support 2022-02-04 22:48:54 +01:00
b358f53ec3 Bump version, update NEWS 2021-12-21 05:58:34 +01:00
2eb315f5c4 utm-filter.lua: add Facebook to the filter 2021-12-20 14:36:41 +01:00
851c2ee548 CMakeLists.txt: fix macOS build 2021-11-02 15:34:51 +01:00
f9848ed627 Update README 2021-10-31 05:16:57 +01:00
686a39df38 CMakeLists.txt: slightly modernize 2021-10-31 04:30:04 +01:00
9cea3fca91 Update NEWS 2021-10-30 14:25:13 +02:00
5165f76b7c xC: quote text coming from a bracketed paste
Not having this has caused me much annoyance over the years.
2021-10-30 09:27:32 +02:00
92ac13f3c6 xC: allow passing the cursor position to editors
Add a configuration option to set a custom editor command,
different from EDITOR or VISUAL--those remain as defaults.

Implement substitutions allowing to convey cursor information
to VIM and Emacs (the latter of which is fairly painful to cater to),
and put usage hints in the configuration option's description.

This should make the editing experience a bit more seamless
for users, even though the position is carried over in one way only.

No sophisticated quoting capabilities were deemed necessary,
it is a lot of code already.  The particular syntax is inspired
by .desktop files and systemd.

["/bin/sh", "-c", "vim +$2go \"$1\"", filename, position, line, column]
would be a slightly simpler but cryptic way of implementing this.
2021-10-30 09:02:35 +02:00
df4ca74580 xC: make libedit autocomplete less miserable
Omitting even this hack was a huge hit to overall usability.
2021-10-30 08:29:16 +02:00
9e297244a4 Update .gitignore 2021-10-30 03:37:22 +02:00
d32ba133c0 Add clang-format configuration, clean up 2021-10-30 02:55:19 +02:00
ce3976e1ec xC: normalize ^J behaviour to follow Readline
For some reason Editline inserts it verbatim,
but in a more broken manner than it has with ^V^J.
2021-10-28 08:49:01 +02:00
e5ed89646b xC: fix newer libedit (2021-08-29) 2021-10-28 08:23:52 +02:00
15 changed files with 636 additions and 281 deletions

32
.clang-format Normal file
View File

@@ -0,0 +1,32 @@
# clang-format is fairly limited, and these rules are approximate:
# - array initializers can get terribly mangled with clang-format 12.0,
# - sometimes it still aligns with space characters,
# - struct name NL { NL ... NL } NL name; is unachievable.
BasedOnStyle: GNU
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
BreakBeforeBraces: Allman
SpaceAfterCStyleCast: true
AlignAfterOpenBracket: DontAlign
AlignOperands: DontAlign
AlignConsecutiveMacros: Consecutive
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
IndentGotoLabels: false
# IncludeCategories has some potential, but it may also break the build.
# Note that the documentation says the value should be "Never".
SortIncludes: false
# This is a compromise, it generally works out aesthetically better.
BinPackArguments: false
# Unfortunately, this can't be told to align to column 40 or so.
SpacesBeforeTrailingComments: 2
# liberty-specific macro body wrappers.
MacroBlockBegin: "BLOCK_START"
MacroBlockEnd: "BLOCK_END"
ForEachMacros: ["LIST_FOR_EACH"]

10
.gitignore vendored
View File

@@ -3,7 +3,9 @@
# Qt Creator files # Qt Creator files
/CMakeLists.txt.user* /CMakeLists.txt.user*
/uirc3.config /xK.config
/uirc3.files /xK.files
/uirc3.creator* /xK.creator*
/uirc3.includes /xK.includes
/xK.cflags
/xK.cxxflags

View File

@@ -1,15 +1,19 @@
cmake_minimum_required (VERSION 3.0) # Ubuntu 18.04 LTS and OpenBSD 6.4
project (uirc3 VERSION 1.4.0 LANGUAGES C) cmake_minimum_required (VERSION 3.10)
project (xK VERSION 1.5.0 DESCRIPTION "IRC client, daemon and bot" LANGUAGES C)
# Options # Options
option (WANT_READLINE "Use GNU Readline for the UI (better)" ON) option (WANT_READLINE "Use GNU Readline for the UI (better)" ON)
option (WANT_LIBEDIT "Use BSD libedit for the UI" OFF) option (WANT_LIBEDIT "Use BSD libedit for the UI" OFF)
# Moar warnings # Moar warnings
set (CMAKE_C_STANDARD 99)
set (CMAKE_C_STANDARD_REQUIRED ON)
set (CMAKE_C_EXTENSIONS OFF)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC) if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
# -Wunused-function is pretty annoying here, as everything is static # -Wunused-function is pretty annoying here, as everything is static
set (wdisabled "-Wno-unused-function") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra ${wdisabled}")
endif () endif ()
# Version # Version
@@ -57,6 +61,8 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively; # Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
# our POSIX version macros make it undefined # our POSIX version macros make it undefined
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1) add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
elseif (APPLE)
add_definitions (-D_DARWIN_C_SOURCE)
endif () endif ()
# -lrt is only for glibc < 2.17 # -lrt is only for glibc < 2.17
@@ -112,10 +118,16 @@ endif ()
if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT)) if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT))
message (SEND_ERROR "You have to choose either GNU Readline or libedit") message (SEND_ERROR "You have to choose either GNU Readline or libedit")
elseif (WANT_READLINE) elseif (WANT_READLINE)
pkg_check_modules (readline readline)
# OpenBSD's default readline is too old # OpenBSD's default readline is too old
if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
include_directories (${OPENBSD_LOCALBASE}/include/ereadline) include_directories (${OPENBSD_LOCALBASE}/include/ereadline)
list (APPEND xC_libraries ereadline) list (APPEND xC_libraries ereadline)
elseif (readline_FOUND)
list (APPEND xC_libraries ${readline_LIBRARIES})
include_directories (${readline_INCLUDE_DIRS})
link_directories (${readline_LIBRARY_DIRS})
else () else ()
list (APPEND xC_libraries readline) list (APPEND xC_libraries readline)
endif () endif ()
@@ -184,7 +196,7 @@ add_custom_target (clang-tidy
# Installation # Installation
install (TARGETS xB xC xD DESTINATION ${CMAKE_INSTALL_BINDIR}) install (TARGETS xB xC xD DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
# XXX: our defaults for XDG_DATA_DIRS expect /usr/local/shore or /usr/share # XXX: our defaults for XDG_DATA_DIRS expect /usr/local/share or /usr/share
install (DIRECTORY plugins/xB/ install (DIRECTORY plugins/xB/
DESTINATION ${CMAKE_INSTALL_DATADIR}/xB/plugins USE_SOURCE_PERMISSIONS) DESTINATION ${CMAKE_INSTALL_DATADIR}/xB/plugins USE_SOURCE_PERMISSIONS)
install (DIRECTORY plugins/xC/ install (DIRECTORY plugins/xC/
@@ -192,20 +204,31 @@ install (DIRECTORY plugins/xC/
# Generate documentation from text markup # Generate documentation from text markup
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor) find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
if (NOT ASCIIDOCTOR_EXECUTABLE) find_program (A2X_EXECUTABLE a2x)
message (FATAL_ERROR "asciidoctor not found") if (NOT ASCIIDOCTOR_EXECUTABLE AND NOT A2X_EXECUTABLE)
message (FATAL_ERROR "Neither asciidoctor nor a2x were found")
endif () endif ()
foreach (page xB xC xD) foreach (page xB xC xD)
set (page_output "${PROJECT_BINARY_DIR}/${page}.1") set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
list (APPEND project_MAN_PAGES "${page_output}") list (APPEND project_MAN_PAGES "${page_output}")
if (ASCIIDOCTOR_EXECUTABLE)
add_custom_command (OUTPUT ${page_output} add_custom_command (OUTPUT ${page_output}
COMMAND ${ASCIIDOCTOR_EXECUTABLE} -b manpage COMMAND ${ASCIIDOCTOR_EXECUTABLE} -b manpage
-a release-version=${project_version} -a release-version=${project_version}
"${PROJECT_SOURCE_DIR}/${page}.adoc"
-o "${page_output}" -o "${page_output}"
"${PROJECT_SOURCE_DIR}/${page}.adoc"
DEPENDS ${page}.adoc DEPENDS ${page}.adoc
COMMENT "Generating man page for ${page}" VERBATIM) COMMENT "Generating man page for ${page}" VERBATIM)
elseif (A2X_EXECUTABLE)
add_custom_command (OUTPUT ${page_output}
COMMAND ${A2X_EXECUTABLE} --doctype manpage --format manpage
-a release-version=${project_version}
-D "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/${page}.adoc"
DEPENDS ${page}.adoc
COMMENT "Generating man page for ${page}" VERBATIM)
endif ()
endforeach () endforeach ()
add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES}) add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
@@ -217,7 +240,6 @@ foreach (page ${project_MAN_PAGES})
endforeach () endforeach ()
# CPack # CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unreasonable IRC client, daemon and bot")
set (CPACK_PACKAGE_VERSION "${project_version_safe}") set (CPACK_PACKAGE_VERSION "${project_version_safe}")
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch") set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>") set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")

View File

@@ -1,4 +1,4 @@
Copyright (c) 2014 - 2021, Přemysl Eric Janouch <p@janouch.name> Copyright (c) 2014 - 2022, Přemysl Eric Janouch <p@janouch.name>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted. purpose with or without fee is hereby granted.

32
NEWS
View File

@@ -1,3 +1,35 @@
Unreleased
* xC: all behaviour.* configuration options have been renamed to general.*,
with the exception of editor_command/editor, backlog_helper/pager,
and backlog_helper_strip_formatting/pager_strip_formatting
* xC: replaced behaviour.save_on_quit with general.autosave
* xC: improved pager integration capabilities
* xC: normalized editline's history behaviour, making it a viable frontend
* xC: made it show WALLOPS messages, as PRIVMSG for the server buffer
* xD: implemented WALLOPS, choosing to make it target even non-operators
1.5.0 (2021-12-21) "The Show Must Go On"
* xC: made it possible to pass the cursor position to external editors,
in particular VIM and Emacs
* xC: started quoting text coming from bracketed pastes,
to minimize the risk of trying to execute filesystem paths as commands
* xC: fixed to work with post-2021-08-29 editline
* xC: extended editline's autocomplete to show all options
* utm-filter.lua: added Facebook's tracking parameter to the filter
1.4.0 (2021-10-06) "Call Me Scruffy Scruffington" 1.4.0 (2021-10-06) "Call Me Scruffy Scruffington"
* xC: made message autosplitting respect text formatting * xC: made message autosplitting respect text formatting

View File

@@ -1,32 +1,31 @@
uirc3 xK
===== ==
:compact-option:
The unreasonable IRC trinity. This project consists of an IRC client, daemon, 'xK' (chat kit) is an IRC software suite consisting of a terminal client,
and bot. It's all you're ever going to need for chatting, as long as you can daemon, and bot. It's all you're ever going to need for chatting,
make do with minimalist software. so long as you can make do with slightly minimalist software.
All of them have these potentially interesting properties: They come with these potentially interesting properties:
- IPv6 support - supporting IRCv3, SOCKS, IPv6, TLS (including client certificates)
- TLS support, including client certificates - lean on dependencies
- lean on dependencies (with the exception of 'xC')
- compact and arguably easy to hack on - compact and arguably easy to hack on
- very permissive license - maximally permissive license
xC xC
-- --
The IRC client. It is largely defined by being built on top of GNU Readline The IRC client, and the core of 'xK'. It is largely defined by being built
that has been hacked to death. Its interface should feel somewhat familiar for on top of GNU Readline that has been hacked to death. Its interface should feel
weechat or irssi users. somewhat familiar for weechat or irssi users.
image::xC.png[align="center"] image::xC.png[align="center"]
This is the largest application within the project. It has most of the stuff It has most of the stuff you'd expect of an IRC client, such as being
you'd expect of an IRC client, such as being able to set up multiple servers, multiserver, a powerful configuration system, integrated help, text formatting,
a powerful configuration system, integrated help, text formatting, CTCP queries, automatic splitting of overlong messages, multiline editing, bracketed paste
automatic splitting of overlong messages, autocomplete, logging to file, support, decent word wrapping, autocomplete, logging, CTCP queries, auto-away,
auto-away, command aliases and basic support for Lua scripting. command aliases, and basic support for Lua scripting. As a unique bonus,
you can launch a full text editor from within.
xD xD
-- --
@@ -37,10 +36,8 @@ do it just fine.
Notable features: Notable features:
- TLS autodetection (why doesn't everyone have this?), using secure defaults - TLS autodetection (I'm still wondering why everyone doesn't have this)
- IRCop authentication via TLS client certificates - IRCop authentication via TLS client certificates
- epoll/kqueue support; this means that it should be able to handle quite
a number of concurrent user connections
- partial IRCv3 support - partial IRCv3 support
Not supported: Not supported:
@@ -58,16 +55,14 @@ and development continues over there.
xB xB
-- --
The IRC bot. It builds upon the concept of my other VitaminA IRC bot. The main The IRC bot. While originally intended to be a simple rewrite of my old GNU AWK
characteristic of these two bots is that they run plugins as coprocesses, which bot in C, it fairly quickly became a playground, and it eventually got me into
allows for enhanced reliability and programming language freedom. writing the rest of this package.
While originally intended to be a simple rewrite of the original AWK bot in C, Its main characteristic is that it runs plugins as coprocesses, allowing for
it fairly quickly became a playground, and it eventually got me into writing enhanced reliability and programming language freedom. Moreover, it recovers
the rest of the package. from any crashes, and offers native SOCKS support (even though socksify can add
that easily to any program).
It survives crashes, server disconnects and timeouts, and also has native SOCKS
support (even though socksify can add that easily to any program).
Packages Packages
-------- --------
@@ -76,18 +71,16 @@ a package with the latest development version from Archlinux's AUR.
Building Building
-------- --------
Build dependencies: CMake, pkg-config, asciidoctor, awk, liberty (included) + Build dependencies: CMake, pkg-config, asciidoctor or asciidoc, awk,
liberty (included) +
Runtime dependencies: openssl + Runtime dependencies: openssl +
Additionally for 'xC': curses, libffi, lua >= 5.3 (optional), Additionally for 'xC': curses, libffi, lua >= 5.3 (optional),
readline >= 6.0 or libedit >= 2013-07-12 readline >= 6.0 or libedit >= 2013-07-12
Avoid libedit if you can, in general it works but at the moment history is $ git clone --recursive https://git.janouch.name/p/xK.git
acting up and I have no clue about fixing it. $ mkdir xK/build
$ cd xK/build
$ git clone --recursive https://git.janouch.name/p/uirc3.git $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
$ mkdir uirc3/build
$ cd uirc3/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug \
-DWANT_READLINE=ON -DWANT_LIBEDIT=OFF -DWANT_LUA=ON -DWANT_READLINE=ON -DWANT_LIBEDIT=OFF -DWANT_LUA=ON
$ make $ make
@@ -95,10 +88,10 @@ To install the application, you can do either the usual:
# make install # make install
Or you can try telling CMake to make a package for you. For Debian it is: Or you can try telling CMake to make a package for you:
$ cpack -G DEB $ cpack -G DEB # also supported: RPM, FreeBSD
# dpkg -i uirc3-*.deb # dpkg -i xK-*.deb
Usage Usage
----- -----
@@ -156,14 +149,18 @@ Beware that you can easily break the program if you're not careful.
How do I make xC look like the screenshot? How do I make xC look like the screenshot?
------------------------------------------ ------------------------------------------
First of all, you must build it with Lua support. With the defaults, 'xC' With the defaults, 'xC' doesn't look too fancy because I don't want to have
doesn't look too fancy because I don't want to depend on Lua or 256-colour a hard dependency on either Lua for the bundled script that provides an easily
terminals. In addition to that, I appear to be one of the few people who use adjustable enhanced prompt, or on 256-colour terminals. Moreover, it's nearly
black on white terminals. impossible to come up with a colour theme that would work well with both
black-on-white and white-on-black terminals, or anything wild in between.
/set behaviour.date_change_line = "%a %e %b %Y" Assuming that your build supports Lua plugins, and that you have a decent,
/set behaviour.plugin_autoload += "fancy-prompt.lua" properly set-up terminal emulator, it suffices to run:
/set behaviour.backlog_helper = "LESSSECURE=1 less -R +Gb1d -Ps'Backlog ?ltlines %lt-%lb?L/%L. .?e(END):?pB%pB\\%..'"
/set general.pager = Press Tab here and change +Gb to +Gb1d
/set general.date_change_line = "%a %e %b %Y"
/set general.plugin_autoload += "fancy-prompt.lua"
/set attributes.userhost = "\x1b[38;5;109m" /set attributes.userhost = "\x1b[38;5;109m"
/set attributes.join = "\x1b[38;5;108m" /set attributes.join = "\x1b[38;5;108m"
/set attributes.part = "\x1b[38;5;138m" /set attributes.part = "\x1b[38;5;138m"
@@ -184,7 +181,7 @@ configurations accordingly, but I consider it rather messy and unnecessary.
Contributing and Support Contributing and Support
------------------------ ------------------------
Use https://git.janouch.name/p/uirc3 to report any bugs, request features, Use https://git.janouch.name/p/xK to report any bugs, request features,
or submit pull requests. `git send-email` is tolerated. If you want to discuss or submit pull requests. `git send-email` is tolerated. If you want to discuss
the project, feel free to join me at ircs://irc.janouch.name, channel #dev. the project, feel free to join me at ircs://irc.janouch.name, channel #dev.

Submodule liberty updated: 1b9d89cab3...f545be725d

View File

@@ -1,7 +1,7 @@
-- --
-- fancy-prompt.lua: the fancy multiline prompt you probably want -- fancy-prompt.lua: the fancy multiline prompt you probably want
-- --
-- Copyright (c) 2016, Přemysl Eric Janouch <p@janouch.name> -- Copyright (c) 2016 - 2022, Přemysl Eric Janouch <p@janouch.name>
-- --
-- Permission to use, copy, modify, and/or distribute this software for any -- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted. -- purpose with or without fee is hereby granted.
@@ -40,7 +40,7 @@ xC.hook_prompt (function (hook)
if buffer == current then if buffer == current then
current_n = i current_n = i
elseif buffer.new_messages_count ~= buffer.new_unimportant_count then elseif buffer.new_messages_count ~= buffer.new_unimportant_count then
if active ~= "" then active = active .. "," end active = active .. ","
if buffer.highlighted then if buffer.highlighted then
active = active .. "!" active = active .. "!"
bg_color = "224" bg_color = "224"
@@ -48,7 +48,6 @@ xC.hook_prompt (function (hook)
active = active .. i active = active .. i
end end
end end
if active ~= "" then active = "(" .. active .. ")" end
local x = current_n .. ":" .. current.name local x = current_n .. ":" .. current.name
if chan and chan.users_len ~= 0 then if chan and chan.users_len ~= 0 then
local params = "" local params = ""
@@ -56,25 +55,34 @@ xC.hook_prompt (function (hook)
params = params .. " +" .. mode .. " " .. param params = params .. " +" .. mode .. " " .. param
end end
local modes = chan.no_param_modes .. params:sub (3) local modes = chan.no_param_modes .. params:sub (3)
if modes ~= "" then x = x .. "(+" .. modes .. ")" end if modes ~= "" then
x = x .. "(+" .. modes .. ")"
end
x = x .. "{" .. chan.users_len .. "}" x = x .. "{" .. chan.users_len .. "}"
end end
if current.hide_unimportant then x = x .. "<H>" end if current.hide_unimportant then
x = x .. "<H>"
local lines, cols = xC.get_screen_size () end
x = x .. " " .. active .. string.rep (" ", cols) if active ~= "" then
x = x .. " (" .. active:sub (2) .. ")"
end
-- Readline 7.0.003 seems to be broken and completely corrupts the prompt. -- Readline 7.0.003 seems to be broken and completely corrupts the prompt.
-- However 8.0.004 seems to be fine with these, as is libedit 20191231-3.1. -- However 8.0.004 seems to be fine with these, as is libedit 20191231-3.1.
--x = x:gsub("[\128-\255]", "?") --x = x:gsub("[\128-\255]", "?")
-- Cut off extra characters and apply formatting, including the hack. -- Align to the terminal's width and apply formatting, including the hack.
-- FIXME: this doesn't count with full-width or zero-width characters. local lines, cols = xC.get_screen_size ()
-- We might want to export wcwidth() above term_from_utf8 somehow. local trailing, width = " ", xC.measure (x)
local overflow = utf8.offset (x, cols - 1) while cols > 0 and width >= cols do
if overflow then x = x:sub (1, overflow) end x = x:sub (1, utf8.offset (x, -1) - 1)
trailing, width = ">", xC.measure (x)
end
x = "\x01\x1b[0;4;1;38;5;16m\x1b[48;5;" .. bg_color .. "m\x02" .. x = "\x01\x1b[0;4;1;38;5;16m\x1b[48;5;" .. bg_color .. "m\x02" ..
x .. "\x01\x1b[0;4;1;7;38;5;" .. bg_color .. "m\x02 \x01\x1b[0;1m\x02" x .. string.rep (" ", cols - width - 1) ..
"\x01\x1b[0;4;1;7;38;5;" .. bg_color .. "m\x02" ..
trailing .. "\x01\x1b[0;1m\x02"
local user_prefix = function (chan, user) local user_prefix = function (chan, user)
for i, chan_user in ipairs (chan.users) do for i, chan_user in ipairs (chan.users) do

View File

@@ -1,7 +1,7 @@
-- --
-- utm-filter.lua: filter out Google Analytics bullshit from URLs -- utm-filter.lua: filter out Google Analytics bullshit etc. from URLs
-- --
-- Copyright (c) 2015, Přemysl Eric Janouch <p@janouch.name> -- Copyright (c) 2015 - 2021, Přemysl Eric Janouch <p@janouch.name>
-- --
-- Permission to use, copy, modify, and/or distribute this software for any -- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted. -- purpose with or without fee is hereby granted.
@@ -19,6 +19,10 @@
local banned = { local banned = {
gclid = 1, gclid = 1,
-- Alas, Facebook no longer uses this parameter, see:
-- https://news.ycombinator.com/item?id=32117489
fbclid = 1,
utm_source = 1, utm_source = 1,
utm_medium = 1, utm_medium = 1,
utm_term = 1, utm_term = 1,

12
xB.adoc
View File

@@ -1,8 +1,8 @@
xB(1) xB(1)
===== =====
:doctype: manpage :doctype: manpage
:manmanual: uirc3 Manual :manmanual: xK Manual
:mansource: uirc3 {release-version} :mansource: xK {release-version}
Name Name
---- ----
@@ -60,14 +60,14 @@ using the IRC protocol. (Caveat: the standard C library doesn't automatically
flush FILE streams for pipes on newlines.) A special *XB* command is introduced flush FILE streams for pipes on newlines.) A special *XB* command is introduced
for RPC, with the following subcommands: for RPC, with the following subcommands:
*XB get_config* _key_:: *XB get_config* __key__::
Request the value of the given configuration option. If no such option Request the value of the given configuration option. If no such option
exists, the value will be empty. The response will be delivered in exists, the value will be empty. The response will be delivered in
the following format: the following format:
+ +
``` ....
XB :value XB :value
``` ....
+ +
This is particularly useful for retrieving the *prefix* string. This is particularly useful for retrieving the *prefix* string.
@@ -100,5 +100,5 @@ _/usr/share/xB/plugins/_::
Reporting bugs Reporting bugs
-------------- --------------
Use https://git.janouch.name/p/uirc3 to report bugs, request features, Use https://git.janouch.name/p/xK to report bugs, request features,
or submit pull requests. or submit pull requests.

15
xC.adoc
View File

@@ -1,8 +1,8 @@
xC(1) xC(1)
===== =====
:doctype: manpage :doctype: manpage
:manmanual: uirc3 Manual :manmanual: xK Manual
:mansource: uirc3 {release-version} :mansource: xK {release-version}
Name Name
---- ----
@@ -25,9 +25,9 @@ Options
other formatting marks to ANSI codes retrieved from the *terminfo*(5) other formatting marks to ANSI codes retrieved from the *terminfo*(5)
database: database:
+ +
``` ....
printf '\x02bold\x02\n' | xC -f printf '\x02bold\x02\n' | xC -f
``` ....
+ +
This feature may be used to preview server MOTD files. This feature may be used to preview server MOTD files.
@@ -105,7 +105,7 @@ _~/.config/xC/xC.conf_::
as the */set* command, to make changes in it. as the */set* command, to make changes in it.
_~/.local/share/xC/logs/_:: _~/.local/share/xC/logs/_::
When enabled by *behaviour.logging*, log files are stored here. When enabled by *general.logging*, log files are stored here.
_~/.local/share/xC/plugins/_:: _~/.local/share/xC/plugins/_::
_/usr/local/share/xC/plugins/_:: _/usr/local/share/xC/plugins/_::
@@ -114,12 +114,11 @@ _/usr/share/xC/plugins/_::
Bugs Bugs
---- ----
The editline (libedit) frontend is more of a proof of concept that mostly seems The editline (libedit) frontend may exhibit some unexpected behaviour.
to work but exhibits bugs that are not our fault.
Reporting bugs Reporting bugs
-------------- --------------
Use https://git.janouch.name/p/uirc3 to report bugs, request features, Use https://git.janouch.name/p/xK to report bugs, request features,
or submit pull requests. or submit pull requests.
See also See also

563
xC.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
xD(1) xD(1)
===== =====
:doctype: manpage :doctype: manpage
:manmanual: uirc3 Manual :manmanual: xK Manual
:mansource: uirc3 {release-version} :mansource: xK {release-version}
Name Name
---- ----
@@ -49,5 +49,5 @@ _/etc/xdg/xD/xD.conf_::
Reporting bugs Reporting bugs
-------------- --------------
Use https://git.janouch.name/p/uirc3 to report bugs, request features, Use https://git.janouch.name/p/xK to report bugs, request features,
or submit pull requests. or submit pull requests.

26
xD.c
View File

@@ -1,7 +1,7 @@
/* /*
* xD.c: an IRC daemon * xD.c: an IRC daemon
* *
* Copyright (c) 2014 - 2021, Přemysl Eric Janouch <p@janouch.name> * Copyright (c) 2014 - 2022, Přemysl Eric Janouch <p@janouch.name>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted. * purpose with or without fee is hereby granted.
@@ -2932,6 +2932,29 @@ irc_handle_links (const struct irc_message *msg, struct client *c)
irc_send_reply (c, IRC_RPL_ENDOFLINKS, mask); irc_send_reply (c, IRC_RPL_ENDOFLINKS, mask);
} }
static void
irc_handle_wallops (const struct irc_message *msg, struct client *c)
{
if (msg->params.len < 1)
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
if (!(c->mode & IRC_USER_MODE_OPERATOR))
RETURN_WITH_REPLY (c, IRC_ERR_NOPRIVILEGES);
const char *message = msg->params.vector[0];
// Our interpretation: anonymize the sender,
// and target all users who want to receive these messages
struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
struct client *target;
while ((target = str_map_iter_next (&iter)))
{
if (target != c && !(target->mode & IRC_USER_MODE_RX_WALLOPS))
continue;
client_send (target, ":%s WALLOPS :%s", c->ctx->server_name, message);
}
}
static void static void
irc_handle_kill (const struct irc_message *msg, struct client *c) irc_handle_kill (const struct irc_message *msg, struct client *c)
{ {
@@ -2994,6 +3017,7 @@ irc_register_handlers (struct server_context *ctx)
{ "ADMIN", true, irc_handle_admin, 0, 0 }, { "ADMIN", true, irc_handle_admin, 0, 0 },
{ "STATS", true, irc_handle_stats, 0, 0 }, { "STATS", true, irc_handle_stats, 0, 0 },
{ "LINKS", true, irc_handle_links, 0, 0 }, { "LINKS", true, irc_handle_links, 0, 0 },
{ "WALLOPS", true, irc_handle_wallops, 0, 0 },
{ "MODE", true, irc_handle_mode, 0, 0 }, { "MODE", true, irc_handle_mode, 0, 0 },
{ "PRIVMSG", true, irc_handle_privmsg, 0, 0 }, { "PRIVMSG", true, irc_handle_privmsg, 0, 0 },