From 56de4668acf0c18e4cd0e2a9c53bc4fc2db98306 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Wed, 19 Feb 2020 21:47:16 -0500 Subject: Add /ban, /unban and handle ban list replies --- handle.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'handle.c') diff --git a/handle.c b/handle.c index fd8b25f..4bfeb9f 100644 --- a/handle.c +++ b/handle.c @@ -424,6 +424,35 @@ static void handleTopic(struct Message *msg) { } } +static void handleReplyBanList(struct Message *msg) { + require(msg, false, 3); + if (!replies.ban) return; + 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), + "Banned in \3%02d%s\3 by \3%02d%s\3 since %s: %s", + hash(msg->params[1]), msg->params[1], + completeColor(id, msg->params[3]), msg->params[3], since, + msg->params[2] + ); + } else { + uiFormat( + id, Cold, tagTime(msg), + "Banned in \3%02d%s\3: %s", + hash(msg->params[1]), msg->params[1], msg->params[2] + ); + } +} + +static void handleReplyEndOfBanList(struct Message *msg) { + (void)msg; + if (replies.ban) replies.ban--; +} + static void handleInvite(struct Message *msg) { require(msg, true, 2); if (!strcmp(msg->params[0], self.nick)) { @@ -719,6 +748,8 @@ static const struct Handler { { "332", handleReplyTopic }, { "353", handleReplyNames }, { "366", handleReplyEndOfNames }, + { "367", handleReplyBanList }, + { "368", handleReplyEndOfBanList }, { "372", handleReplyMOTD }, { "378", handleReplyWhoisGeneric }, { "379", handleReplyWhoisGeneric }, -- cgit 1.4.1-2-gfad0