hirc

IRC client
Log | Files | Refs

commit 19437612b2a89d0949bcdef4ac9210f06270f0c1
parent 8fc327cec768c29f0582ce3e0f9136f3013e041d
Author: hhvn <dev@hhvn.uk>
Date:   Thu, 21 Apr 2022 19:51:44 +0100

motd.removedash option

Diffstat:
Msrc/config.c | 6++++++
Msrc/handle.c | 22++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -201,6 +201,12 @@ struct Config config[] = { .description = { "Send an audible bell on highlights or messages.", "Often triggers some other form of action in graphical environments.", NULL}}, + {"motd.removedash", 1, Val_bool, + .num = 1, + .numhandle = config_redrawl, + .description = { + "Remove dash characters often prepended to RPL_MOTD replies.", + "This setting only affects messages recieved after it is set.", NULL}}, {"completion.hchar", 1, Val_string, .str = ",", .strhandle = NULL, diff --git a/src/handle.c b/src/handle.c @@ -45,6 +45,7 @@ HANDLER(handle_RPL_TOPICWHOTIME); HANDLER(handle_RPL_INVITING); HANDLER(handle_RPL_NAMREPLY); HANDLER(handle_RPL_ENDOFNAMES); +HANDLER(handle_RPL_MOTD); HANDLER(handle_RPL_ENDOFMOTD); HANDLER(handle_ERR_NOSUCHNICK); HANDLER(handle_ERR_NICKNAMEINUSE); @@ -79,6 +80,8 @@ struct Handler handlers[] = { { "341", handle_RPL_INVITING }, { "353", handle_RPL_NAMREPLY }, { "366", handle_RPL_ENDOFNAMES }, + { "372", handle_RPL_MOTD }, + { "375", handle_RPL_MOTD }, /* RPL_MOTDSTART, but handle it the same way as RPL_MOTD */ { "376", handle_RPL_ENDOFMOTD }, { "401", handle_ERR_NOSUCHNICK }, { "433", handle_ERR_NICKNAMEINUSE }, @@ -643,6 +646,25 @@ handle_RPL_WELCOME) { } HANDLER( +handle_RPL_MOTD) { + char *text; + + if (config_getl("motd.removedash")) { + text = msg->raw; + if (*text == ':') + text++; + if ((text = strchr(text, ':'))) { + text++; + if (strncmp(text, "- ", CONSTLEN("- ")) == 0) + memmove(text, text + 2, strlen(text + 2) + 1); + else if (strncmp(text, "-", CONSTLEN("-")) == 0) + memmove(text, text + 1, strlen(text + 1) + 1); + } + } + hist_addp(server->history, msg, Activity_status, HIST_DFL); +} + +HANDLER( handle_RPL_ENDOFMOTD) { /* If server doesn't support RPL_WELCOME, use RPL_ENDOFMOTD to set status */ if (server->status != ConnStatus_connected) {