summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--handle.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/handle.c b/handle.c
index 44329ff..de9e73a 100644
--- a/handle.c
+++ b/handle.c
@@ -226,6 +226,37 @@ static void handlePart(struct Message *msg) {
 	);
 }
 
+static void handleNick(struct Message *msg) {
+	require(msg, true, 1);
+	if (self.nick && !strcmp(msg->nick, self.nick)) {
+		set(&self.nick, msg->params[0]);
+	}
+	size_t id;
+	while (None != (id = completeID(msg->nick))) {
+		uiFormat(
+			id, Cold, tagTime(msg),
+			"\3%02d%s\3\tis now known as \3%02d%s\3",
+			hash(msg->user), msg->nick, hash(msg->user), msg->params[0]
+		);
+	}
+	completeReplace(None, msg->nick, msg->params[0]);
+}
+
+static void handleQuit(struct Message *msg) {
+	require(msg, true, 0);
+	size_t id;
+	while (None != (id = completeID(msg->nick))) {
+		uiFormat(
+			id, Cold, tagTime(msg),
+			"\3%02d%s\3\tleaves%s%s",
+			hash(msg->user), msg->nick,
+			(msg->params[0] ? ": " : ""),
+			(msg->params[0] ? msg->params[0] : "")
+		);
+	}
+	completeRemove(None, msg->nick);
+}
+
 static void handleReplyNames(struct Message *msg) {
 	require(msg, false, 4);
 	size_t id = idFor(msg->params[2]);
@@ -288,22 +319,6 @@ static void handleTopic(struct Message *msg) {
 	}
 }
 
-static void handleNick(struct Message *msg) {
-	require(msg, true, 1);
-	if (self.nick && !strcmp(msg->nick, self.nick)) {
-		set(&self.nick, msg->params[0]);
-	}
-	size_t id;
-	completeReplace(None, msg->nick, msg->params[0]);
-	while (None != (id = completeID(msg->params[0]))) {
-		uiFormat(
-			id, Cold, tagTime(msg),
-			"\3%02d%s\3\tis now known as \3%02d%s\3",
-			hash(msg->user), msg->nick, hash(msg->user), msg->params[0]
-		);
-	}
-}
-
 static bool isAction(struct Message *msg) {
 	if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
 	msg->params[1] += 8;
@@ -403,6 +418,7 @@ static const struct Handler {
 	{ "PART", handlePart },
 	{ "PING", handlePing },
 	{ "PRIVMSG", handlePrivmsg },
+	{ "QUIT", handleQuit },
 	{ "TOPIC", handleTopic },
 };
 
'/src/commit/bin/hi.c?id=4bd9899913e57409409a05cd1b4b50a1773d4ee1&follow=1'>Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe