about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-24 18:22:41 -0500
committerJune McEnroe <june@causal.agency>2019-12-24 18:22:41 -0500
commit29829ff4759830afa18c24b38679cdb8bb453103 (patch)
tree6f1a85f30386ee29c8cfb073b365206bfc2c96a0
parentHandle quit (diff)
downloadlitterbox-29829ff4759830afa18c24b38679cdb8bb453103.tar.gz
litterbox-29829ff4759830afa18c24b38679cdb8bb453103.zip
Handle topic
-rw-r--r--litterbox.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/litterbox.c b/litterbox.c
index 2cbd059..4677566 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -381,6 +381,16 @@ static void handleQuit(struct Message *msg) {
 	clearJoins(msg->nick, NULL);
 }
 
+static void handleTopic(struct Message *msg) {
+	require(msg, 1);
+	insertContext(msg->params[0], false);
+	insertName(msg->nick, msg->user, msg->host);
+	insertEvent(
+		msg->time, Topic, msg->params[0],
+		msg->nick, msg->user, msg->host, NULL, msg->params[1]
+	);
+}
+
 static void handlePing(struct Message *msg) {
 	require(msg, 1);
 	format("PONG :%s\r\n", msg->params[0]);
@@ -402,6 +412,7 @@ static const struct {
 	{ "PING", false, handlePing },
 	{ "PRIVMSG", true, handlePrivmsg },
 	{ "QUIT", true, handleQuit },
+	{ "TOPIC", true, handleTopic },
 };
 
 static void handle(struct Message msg) {