5 Commits

Author SHA1 Message Date
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
11 changed files with 104 additions and 51 deletions

12
.gitignore vendored
View File

@@ -3,9 +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
/uirc3.cflags /xK.cflags
/uirc3.cxxflags /xK.cxxflags

View File

@@ -1,6 +1,6 @@
# Ubuntu 18.04 LTS and OpenBSD 6.4 # Ubuntu 18.04 LTS and OpenBSD 6.4
cmake_minimum_required (VERSION 3.10) cmake_minimum_required (VERSION 3.10)
project (uirc3 VERSION 1.5.0 LANGUAGES C) 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)
@@ -196,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/
@@ -229,7 +229,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>")

9
NEWS
View File

@@ -1,3 +1,12 @@
Unreleased
* xC: improved backlog helper integration capabilities
* 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" 1.5.0 (2021-12-21) "The Show Must Go On"
* xC: made it possible to pass the cursor position to external editors, * xC: made it possible to pass the cursor position to external editors,

View File

@@ -1,11 +1,11 @@
uirc3 xK
===== ==
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.
They have these potentially interesting properties: They come with these potentially interesting properties:
- supporting IRCv3, SOCKS, IPv6, TLS (including client certificates) - supporting IRCv3, SOCKS, IPv6, TLS (including client certificates)
- lean on dependencies - lean on dependencies
@@ -14,18 +14,18 @@ They have these potentially interesting properties:
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 core of the project. It has most of the stuff you'd expect of It has most of the stuff you'd expect of an IRC client, such as being
an IRC client, such as being multiserver, a powerful configuration system, multiserver, a powerful configuration system, integrated help, text formatting,
integrated help, text formatting, automatic splitting of overlong messages, automatic splitting of overlong messages, multiline editing, bracketed paste
multiline editing, bracketed paste support, decent word wrapping, autocomplete, support, decent word wrapping, autocomplete, logging, CTCP queries, auto-away,
logging, CTCP queries, auto-away, command aliases, and basic support for Lua command aliases, and basic support for Lua scripting. As a unique bonus,
scripting. As a unique bonus, you can launch a full text editor from within. you can launch a full text editor from within.
xD xD
-- --
@@ -79,9 +79,9 @@ Additionally for 'xC': curses, libffi, lua >= 5.3 (optional),
Avoid libedit if you can, in general it works but at the moment history is Avoid libedit if you can, in general it works but at the moment history is
acting up and I have no clue about fixing it. acting up and I have no clue about fixing it.
$ git clone --recursive https://git.janouch.name/p/uirc3.git $ git clone --recursive https://git.janouch.name/p/xK.git
$ mkdir uirc3/build $ mkdir xK/build
$ cd uirc3/build $ cd xK/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \ $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWANT_READLINE=ON -DWANT_LIBEDIT=OFF -DWANT_LUA=ON -DWANT_READLINE=ON -DWANT_LIBEDIT=OFF -DWANT_LUA=ON
$ make $ make
@@ -93,7 +93,7 @@ To install the application, you can do either the usual:
Or you can try telling CMake to make a package for you: Or you can try telling CMake to make a package for you:
$ cpack -G DEB # also supported: RPM, FreeBSD $ cpack -G DEB # also supported: RPM, FreeBSD
# dpkg -i uirc3-*.deb # dpkg -i xK-*.deb
Usage Usage
----- -----
@@ -179,7 +179,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

@@ -18,6 +18,9 @@
-- A list of useless URL parameters that don't affect page function -- A list of useless URL parameters that don't affect page function
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, fbclid = 1,
utm_source = 1, utm_source = 1,

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
---- ----
@@ -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.

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
---- ----
@@ -119,7 +119,7 @@ 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

42
xC.c
View File

@@ -2480,9 +2480,11 @@ static struct config_schema g_config_behaviour[] =
.default_ = "1000", .default_ = "1000",
.on_change = on_config_backlog_limit_change }, .on_change = on_config_backlog_limit_change },
{ .name = "backlog_helper", { .name = "backlog_helper",
.comment = "Shell command to display a buffer's history", .comment = "Shell command to page buffer history (args: name [path])",
.type = CONFIG_ITEM_STRING, .type = CONFIG_ITEM_STRING,
.default_ = "\"LESSSECURE=1 less -M -R +Gb\"" }, .default_ = "`name=$(echo \"$1\" | sed 's/[%?:.]/\\\\&/g'); "
"prompt='?f%F:'$name'. ?db- page %db?L of %D. .(?eEND:?PB%PB\\%..)'; "
"LESSSECURE=1 less +Gb -Ps\"$prompt\" \"${2:--R}\"`" },
{ .name = "backlog_helper_strip_formatting", { .name = "backlog_helper_strip_formatting",
.comment = "Strip formatting from backlog helper input", .comment = "Strip formatting from backlog helper input",
.type = CONFIG_ITEM_BOOLEAN, .type = CONFIG_ITEM_BOOLEAN,
@@ -7488,6 +7490,16 @@ irc_handle_topic (struct server *s, const struct irc_message *msg)
} }
} }
static void
irc_handle_wallops (struct server *s, const struct irc_message *msg)
{
if (!msg->prefix || msg->params.len < 1)
return;
const char *message = msg->params.vector[0];
log_server (s, s->buffer, 0, "<#n> #m", msg->prefix, message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static struct irc_handler g_irc_handlers[] = static struct irc_handler g_irc_handlers[] =
@@ -7511,6 +7523,7 @@ static struct irc_handler g_irc_handlers[] =
{ "QUIT", irc_handle_quit }, { "QUIT", irc_handle_quit },
{ "TAGMSG", irc_handle_tagmsg }, { "TAGMSG", irc_handle_tagmsg },
{ "TOPIC", irc_handle_topic }, { "TOPIC", irc_handle_topic },
{ "WALLOPS", irc_handle_wallops },
}; };
static bool static bool
@@ -13355,15 +13368,19 @@ input_editor_cleanup (struct app_context *ctx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void static void
launch_backlog_helper (struct app_context *ctx, int backlog_fd) launch_backlog_helper (struct app_context *ctx, int backlog_fd,
const char *name, const char *path)
{ {
hard_assert (!ctx->running_backlog_helper); hard_assert (!ctx->running_backlog_helper);
switch (spawn_helper_child (ctx)) switch (spawn_helper_child (ctx))
{ {
case 0: case 0:
dup2 (backlog_fd, STDIN_FILENO); dup2 (backlog_fd, STDIN_FILENO);
execl ("/bin/sh", "/bin/sh", "-c", get_config_string char *localized_name =
(ctx->config.root, "behaviour.backlog_helper"), NULL); iconv_xstrdup (ctx->term_from_utf8, (char *) name, -1, NULL);
execl ("/bin/sh", "/bin/sh", "-c",
get_config_string (ctx->config.root, "behaviour.backlog_helper"),
PROGRAM_NAME, localized_name, path, NULL);
print_error ("%s: %s", print_error ("%s: %s",
"Failed to launch backlog helper", strerror (errno)); "Failed to launch backlog helper", strerror (errno));
_exit (EXIT_FAILURE); _exit (EXIT_FAILURE);
@@ -13408,7 +13425,7 @@ display_backlog (struct app_context *ctx, int flush_opts)
rewind (backlog); rewind (backlog);
set_cloexec (fileno (backlog)); set_cloexec (fileno (backlog));
launch_backlog_helper (ctx, fileno (backlog)); launch_backlog_helper (ctx, fileno (backlog), buffer->name, NULL);
fclose (backlog); fclose (backlog);
return true; return true;
} }
@@ -13436,24 +13453,25 @@ on_display_full_log (int count, int key, void *user_data)
(void) key; (void) key;
struct app_context *ctx = user_data; struct app_context *ctx = user_data;
char *path = buffer_get_log_path (ctx->current_buffer); struct buffer *buffer = ctx->current_buffer;
char *path = buffer_get_log_path (buffer);
FILE *full_log = fopen (path, "rb"); FILE *full_log = fopen (path, "rb");
free (path);
if (!full_log) if (!full_log)
{ {
log_global_error (ctx, "Failed to open log file for #s: #l", log_global_error (ctx, "Failed to open log file for #s: #l",
ctx->current_buffer->name, strerror (errno)); ctx->current_buffer->name, strerror (errno));
free (path);
return false; return false;
} }
if (ctx->current_buffer->log_file) if (buffer->log_file)
// The regular flush will log any error eventually // The regular flush will log any error eventually
(void) fflush (ctx->current_buffer->log_file); (void) fflush (buffer->log_file);
set_cloexec (fileno (full_log)); set_cloexec (fileno (full_log));
launch_backlog_helper (ctx, fileno (full_log)); launch_backlog_helper (ctx, fileno (full_log), buffer->name, path);
fclose (full_log); fclose (full_log);
free (path);
return true; return true;
} }

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.

24
xD.c
View File

@@ -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 },