From 3c5e1c95a4091c26de8cc47e9cf222b74cec4fb3 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 25 Feb 2020 02:12:35 -0500 Subject: Add /mode, /except, /invex and handle lists replies --- handle.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'handle.c') diff --git a/handle.c b/handle.c index 2dc4654..f1fc75d 100644 --- a/handle.c +++ b/handle.c @@ -606,6 +606,50 @@ static void handleReplyEndOfBanList(struct Message *msg) { if (replies.ban) replies.ban--; } +static void onList(const char *list, struct Message *msg) { + uint id = idFor(msg->params[1]); + if (msg->params[3] && msg->params[4]) { + char since[sizeof("0000-00-00 00:00:00")]; + time_t time = strtol(msg->params[4], NULL, 10); + strftime(since, sizeof(since), "%F %T", localtime(&time)); + uiFormat( + id, Cold, tagTime(msg), + "On the \3%02d%s\3 %s list since %s by \3%02d%s\3: %s", + hash(msg->params[1]), msg->params[1], list, + since, completeColor(id, msg->params[3]), msg->params[3], + msg->params[2] + ); + } else { + uiFormat( + id, Cold, tagTime(msg), + "On the \3%02d%s\3 %s list: %s", + hash(msg->params[1]), msg->params[1], list, msg->params[2] + ); + } +} + +static void handleReplyExceptList(struct Message *msg) { + require(msg, false, 3); + if (!replies.excepts) return; + onList("except", msg); +} + +static void handleReplyEndOfExceptList(struct Message *msg) { + (void)msg; + if (replies.excepts) replies.excepts--; +} + +static void handleReplyInviteList(struct Message *msg) { + require(msg, false, 3); + if (!replies.invex) return; + onList("invite", msg); +} + +static void handleReplyEndOfInviteList(struct Message *msg) { + (void)msg; + if (replies.invex) replies.invex--; +} + static void handleReplyList(struct Message *msg) { require(msg, false, 4); if (!replies.list) return; @@ -881,6 +925,10 @@ static const struct Handler { { "331", handleReplyNoTopic }, { "332", handleReplyTopic }, { "341", handleReplyInviting }, + { "346", handleReplyInviteList }, + { "347", handleReplyEndOfInviteList }, + { "348", handleReplyExceptList }, + { "349", handleReplyEndOfExceptList }, { "353", handleReplyNames }, { "366", handleReplyEndOfNames }, { "367", handleReplyBanList }, -- cgit 1.4.1