summary refs log tree commit diff
path: root/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'handle.c')
-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 },
 };
 
-bit than size_t anyway, and it eliminates some helper functions. Also don't error when reading an empty save file. 2020-02-11Set self.nick to * initiallyJune McEnroe Allows removing a bunch of checks that self.nick is set, and it's what the server usually calls you before registration. Never highlight notices as mentions. 2020-02-11Define ColorCap instead of hardcoding 100June McEnroe 2020-02-11Move hash to top of chat.hJune McEnroe 2020-02-11Move base64 out of chat.hJune McEnroe 2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe 2020-02-11Fix whois idle unit calculationJune McEnroe Rookie mistake. 2020-02-11Cast towupper to wchar_tJune McEnroe For some reason it takes and returns wint_t... 2020-02-11Cast set but unused variables to voidJune McEnroe 2020-02-11Declare strlcatJune McEnroe 2020-02-11Check if VDSUSP existsJune McEnroe 2020-02-11Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe