hirc

IRC client
Log | Files | Refs

commit 6737120229329a34a360a717ddd0d15aaa7944d6
parent 866c4e56f467b9de3fd984255782c9e990319037
Author: hhvn <dev@hhvn.uk>
Date:   Thu, 10 Mar 2022 20:12:41 +0000

Add ERR_NOSUCHNICK to channel if MODE is used

Diffstat:
Msrc/commands.c | 4++++
Msrc/config.c | 6+++---
Msrc/handle.c | 16++++++++++++++++
Msrc/struct.h | 2++
4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -547,6 +547,8 @@ command_mode) { } if (modes) { + if (chan == channel->name) + expect_set(server, Expect_nosuchnick, chan); ircprintf(server, "MODE %s %s\r\n", chan, modes); } else { expect_set(server, Expect_channelmodeis, chan); @@ -1608,6 +1610,8 @@ modelset(char *cmd, struct Server *server, struct Channel *channel, args = p; } + + expect_set(server, Expect_nosuchnick, channel->name); } COMMAND( diff --git a/src/config.c b/src/config.c @@ -917,17 +917,17 @@ struct Config config[] = { .description = { "Format of RPL_NOUSERS (395) numeric", NULL}}, {"format.err.nosuchnick", 1, Val_string, - .str = "${2-}", + .str = "No such nick: ${2}", .strhandle = config_redraws, .description = { "Format of ERR_NOSUCHNICK (401) numeric", NULL}}, {"format.err.nosuchserver", 1, Val_string, - .str = "${2-}", + .str = "No such server: ${2}", .strhandle = config_redraws, .description = { "Format of ERR_NOSUCHSERVER (402) numeric", NULL}}, {"format.err.nosuchchannel", 1, Val_string, - .str = "${2-}", + .str = "No such channel: ${2}", .strhandle = config_redraws, .description = { "Format of ERR_NOSUCHCHANNEL (403) numeric", NULL}}, diff --git a/src/handle.c b/src/handle.c @@ -44,6 +44,7 @@ HANDLER(handle_RPL_TOPICWHOTIME); HANDLER(handle_RPL_NAMREPLY); HANDLER(handle_RPL_ENDOFNAMES); HANDLER(handle_RPL_ENDOFMOTD); +HANDLER(handle_ERR_NOSUCHNICK); HANDLER(handle_ERR_NICKNAMEINUSE); HANDLER(handle_RPL_AWAY); @@ -74,6 +75,7 @@ struct Handler handlers[] = { { "353", handle_RPL_NAMREPLY }, { "366", handle_RPL_ENDOFNAMES }, { "376", handle_RPL_ENDOFMOTD }, + { "401", handle_ERR_NOSUCHNICK }, { "433", handle_ERR_NICKNAMEINUSE }, { NULL, NULL }, }; @@ -238,6 +240,7 @@ handle_MODE) { if ((chan = chan_get(&server->channels, *(msg->params+1), -1)) == NULL) chan = chan_add(server, &server->channels, *(msg->params+1), 0); + expect_set(server, Expect_nosuchnick, NULL); hist_addp(server->history, msg, Activity_status, HIST_LOG); hist_addp(chan->history, msg, Activity_status, HIST_DFL); ircprintf(server, "MODE %s\r\n", chan->name); /* Get full mode via RPL_CHANNELMODEIS @@ -417,6 +420,19 @@ handle_RPL_ENDOFNAMES) { } HANDLER( +handle_ERR_NOSUCHNICK) { + char *expectation; + struct Channel *chan = NULL; + + if ((expectation = expect_get(server, Expect_nosuchnick)) != NULL) { + chan = chan_get(&server->channels, expectation, -1); + expect_set(server, Expect_nosuchnick, NULL); + } + + hist_addp(chan ? chan->history : server->history, msg, Activity_error, HIST_DFL); +} + +HANDLER( handle_ERR_NICKNAMEINUSE) { char nick[64]; /* should be limited to 9 chars, but newer servers *shrug*/ struct Nick *nnick; diff --git a/src/struct.h b/src/struct.h @@ -116,6 +116,8 @@ enum Expect { Expect_topicwhotime, Expect_channelmodeis, Expect_nicknameinuse, + Expect_nosuchnick, /* currently set by commands that send MODE + and subsequently unset by handle_mode */ Expect_last, };