summary refs log tree commit diff
path: root/handle.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-19 21:47:16 -0500
committerJune McEnroe <june@causal.agency>2020-02-19 21:47:16 -0500
commit56de4668acf0c18e4cd0e2a9c53bc4fc2db98306 (patch)
treec68f60818fb436ed8f73c3d1a158b88547ca957e /handle.c
parentFormat WHOIS signon date with %F %T (diff)
downloadcatgirl-56de4668acf0c18e4cd0e2a9c53bc4fc2db98306.tar.gz
catgirl-56de4668acf0c18e4cd0e2a9c53bc4fc2db98306.zip
Add /ban, /unban and handle ban list replies
Diffstat (limited to 'handle.c')
-rw-r--r--handle.c31
1 files changed, 31 insertions, 0 deletions
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 },