about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-05-06 20:25:16 -0400
committerJune McEnroe <june@causal.agency>2022-05-08 16:38:00 -0400
commit6cfb1ad301136446811b9bf09a47e27cc0f11278 (patch)
tree2067c6d3807ae6d81dda0d0d8886fef9be69ad79
parentSanitize leading dots from log path components (diff)
downloadcatgirl-6cfb1ad301136446811b9bf09a47e27cc0f11278.tar.gz
catgirl-6cfb1ad301136446811b9bf09a47e27cc0f11278.zip
Write unknown replies to Network with Ice heat
-rw-r--r--handle.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/handle.c b/handle.c
index 388a122..0baddf2 100644
--- a/handle.c
+++ b/handle.c
@@ -127,6 +127,15 @@ static void handleErrorGeneric(struct Message *msg) {
 	}
 }
 
+static void handleReplyGeneric(struct Message *msg) {
+	char buf[1024];
+	char *ptr = buf, *end = &buf[sizeof(buf)];
+	for (uint i = 1; i < ParamCap && msg->params[i]; ++i) {
+		ptr = seprintf(ptr, end, "%s%s", (i > 1 ? " " : ""), msg->params[i]);
+	}
+	if (ptr != buf) uiWrite(Network, Ice, tagTime(msg), buf);
+}
+
 static void handleErrorNicknameInUse(struct Message *msg) {
 	require(msg, false, 2);
 	if (!strcmp(self.nick, "*")) {
@@ -232,6 +241,7 @@ static void handleAuthenticate(struct Message *msg) {
 static void handleReplyLoggedIn(struct Message *msg) {
 	(void)msg;
 	ircFormat("CAP END\r\n");
+	handleReplyGeneric(msg);
 }
 
 static void handleErrorSASLFail(struct Message *msg) {
@@ -255,9 +265,11 @@ static void handleReplyWelcome(struct Message *msg) {
 		replies[ReplyNamesAuto] += count;
 	}
 	commandCompleteAdd();
+	handleReplyGeneric(msg);
 }
 
 static void handleReplyISupport(struct Message *msg) {
+	handleReplyGeneric(msg);
 	for (uint i = 1; i < ParamCap; ++i) {
 		if (!msg->params[i]) break;
 		char *key = strsep(&msg->params[i], "=");
@@ -1403,5 +1415,7 @@ void handle(struct Message *msg) {
 		if (handler->reply < 0) replies[abs(handler->reply)]--;
 	} else if (strcmp(msg->cmd, "400") >= 0 && strcmp(msg->cmd, "599") <= 0) {
 		handleErrorGeneric(msg);
+	} else if (isdigit(msg->cmd[0])) {
+		handleReplyGeneric(msg);
 	}
 }