summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-02 03:43:18 -0500
committerJune McEnroe <june@causal.agency>2020-02-02 03:43:18 -0500
commitdce7891331fcf3b86095b64bea8853942dfd667c (patch)
treed7508354df4c3ee1093ddd41bccb70fd87859a16
parentRemove style string macros (diff)
downloadcatgirl-dce7891331fcf3b86095b64bea8853942dfd667c.tar.gz
catgirl-dce7891331fcf3b86095b64bea8853942dfd667c.zip
Add extremely basid handlePrivmsg
Diffstat (limited to '')
-rw-r--r--handle.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/handle.c b/handle.c
index ef61129..da635b4 100644
--- a/handle.c
+++ b/handle.c
@@ -193,6 +193,18 @@ static void handleJoin(struct Message *msg) {
 	);
 }
 
+static void handlePrivmsg(struct Message *msg) {
+	require(msg, true, 2);
+	bool query = self.nick && !strcmp(msg->params[0], self.nick);
+	size_t id = idFor(query ? msg->nick : msg->params[0]);
+	if (query) idColors[id] = hash(msg->user);
+	uiFormat(
+		id, Warm, tagTime(msg),
+		"\3%d<%s>\3 %s",
+		hash(msg->user), msg->nick, msg->params[1]
+	);
+}
+
 static void handlePing(struct Message *msg) {
 	require(msg, false, 1);
 	ircFormat("PONG :%s\r\n", msg->params[0]);
@@ -215,6 +227,7 @@ static const struct Handler {
 	{ "CAP", handleCap },
 	{ "JOIN", handleJoin },
 	{ "PING", handlePing },
+	{ "PRIVMSG", handlePrivmsg },
 };
 
 static int compar(const void *cmd, const void *_handler) {