diff options
author | June McEnroe <june@causal.agency> | 2020-02-08 00:36:23 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-08 00:36:23 -0500 |
commit | f14175ebede46eb9e1fbf239a5c3b349951d34fc (patch) | |
tree | 35bef12542d496a7e6a8fecf16469d7724078b09 | |
parent | Handle NAMES reply (diff) | |
download | catgirl-f14175ebede46eb9e1fbf239a5c3b349951d34fc.tar.gz catgirl-f14175ebede46eb9e1fbf239a5c3b349951d34fc.zip |
Handle QUIT
Diffstat (limited to '')
-rw-r--r-- | handle.c | 48 |
1 files 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 }, }; |