about summary refs log tree commit diff
path: root/handle.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-29 01:03:46 -0500
committerJune McEnroe <june@causal.agency>2020-02-29 01:03:46 -0500
commit8570a62235e5e9b6a6d719fd8b92cedc91a1d511 (patch)
tree209a365efebcec4457f4563a4308e6c5c8cdfdf4 /handle.c
parentAdd raw modes to mode message (diff)
downloadcatgirl-8570a62235e5e9b6a6d719fd8b92cedc91a1d511.tar.gz
catgirl-8570a62235e5e9b6a6d719fd8b92cedc91a1d511.zip
Implement the causal.agency/consumer capability
Diffstat (limited to 'handle.c')
-rw-r--r--handle.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/handle.c b/handle.c
index 58fdce2..0a1dedb 100644
--- a/handle.c
+++ b/handle.c
@@ -126,6 +126,10 @@ static void handleCap(struct Message *msg) {
 	enum Cap caps = capParse(msg->params[2]);
 	if (!strcmp(msg->params[1], "LS")) {
 		caps &= ~CapSASL;
+		if (caps & CapConsumer && self.pos) {
+			ircFormat("CAP REQ %s=%zu\r\n", CapNames[CapConsumerBit], self.pos);
+			caps &= ~CapConsumer;
+		}
 		if (caps) {
 			ircFormat("CAP REQ :%s\r\n", capList(caps));
 		} else {
@@ -1019,9 +1023,10 @@ void handle(struct Message msg) {
 	);
 	if (handler) {
 		handler->fn(&msg);
-		return;
-	}
-	if (strcmp(msg.cmd, "400") >= 0 && strcmp(msg.cmd, "599") <= 0) {
+	} else if (strcmp(msg.cmd, "400") >= 0 && strcmp(msg.cmd, "599") <= 0) {
 		handleErrorGeneric(&msg);
 	}
+	if (msg.tags[TagPos]) {
+		self.pos = strtoull(msg.tags[TagPos], NULL, 10);
+	}
 }