From f14175ebede46eb9e1fbf239a5c3b349951d34fc Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sat, 8 Feb 2020 00:36:23 -0500 Subject: Handle QUIT --- handle.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/handle.c b/handle.c index 44329ff..de9e73a 100644 --- a/handle.c +++ b/handle.c @@ -226,6 +226,37 @@ static void handlePart(struct Message *msg) { ); } +static void handleNick(struct Message *msg) { + require(msg, true, 1); + if (self.nick && !strcmp(msg->nick, self.nick)) { + set(&self.nick, msg->params[0]); + } + size_t id; + while (None != (id = completeID(msg->nick))) { + uiFormat( + id, Cold, tagTime(msg), + "\3%02d%s\3\tis now known as \3%02d%s\3", + hash(msg->user), msg->nick, hash(msg->user), msg->params[0] + ); + } + completeReplace(None, msg->nick, msg->params[0]); +} + +static void handleQuit(struct Message *msg) { + require(msg, true, 0); + size_t id; + while (None != (id = completeID(msg->nick))) { + uiFormat( + id, Cold, tagTime(msg), + "\3%02d%s\3\tleaves%s%s", + hash(msg->user), msg->nick, + (msg->params[0] ? ": " : ""), + (msg->params[0] ? msg->params[0] : "") + ); + } + completeRemove(None, msg->nick); +} + static void handleReplyNames(struct Message *msg) { require(msg, false, 4); size_t id = idFor(msg->params[2]); @@ -288,22 +319,6 @@ static void handleTopic(struct Message *msg) { } } -static void handleNick(struct Message *msg) { - require(msg, true, 1); - if (self.nick && !strcmp(msg->nick, self.nick)) { - set(&self.nick, msg->params[0]); - } - size_t id; - completeReplace(None, msg->nick, msg->params[0]); - while (None != (id = completeID(msg->params[0]))) { - uiFormat( - id, Cold, tagTime(msg), - "\3%02d%s\3\tis now known as \3%02d%s\3", - hash(msg->user), msg->nick, hash(msg->user), msg->params[0] - ); - } -} - static bool isAction(struct Message *msg) { if (strncmp(msg->params[1], "\1ACTION ", 8)) return false; msg->params[1] += 8; @@ -403,6 +418,7 @@ static const struct Handler { { "PART", handlePart }, { "PING", handlePing }, { "PRIVMSG", handlePrivmsg }, + { "QUIT", handleQuit }, { "TOPIC", handleTopic }, }; -- cgit 1.4.1-2-gfad0