summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-30 14:29:32 -0500
committerJune McEnroe <june@causal.agency>2020-12-30 14:29:32 -0500
commit8b6a476c35c4ee209dbaa3feced83aff4c02b5d5 (patch)
tree0224d206266e97b1dcc868c21599784a39cf2c8f
parentShow setnames like nick changes (diff)
downloadcatgirl-8b6a476c35c4ee209dbaa3feced83aff4c02b5d5.tar.gz
catgirl-8b6a476c35c4ee209dbaa3feced83aff4c02b5d5.zip
Add /whowas
-rw-r--r--catgirl.14
-rw-r--r--chat.h1
-rw-r--r--command.c8
-rw-r--r--handle.c28
4 files changed, 37 insertions, 4 deletions
diff --git a/catgirl.1 b/catgirl.1
index 3f65618..1c782cf 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd December 29, 2020
+.Dd December 30, 2020
 .Dt CATGIRL 1
 .Os
 .
@@ -339,6 +339,8 @@ Press
 twice to copy the current topic.
 .It Ic /whois Ar nick
 Query information about a user.
+.It Ic /whowas Ar nick
+Query past information about a user.
 .El
 .
 .Ss UI Commands
diff --git a/chat.h b/chat.h
index ccd8863..e1f6584 100644
--- a/chat.h
+++ b/chat.h
@@ -260,6 +260,7 @@ extern struct Replies {
 	uint topic;
 	uint who;
 	uint whois;
+	uint whowas;
 } replies;
 
 void handle(struct Message *msg);
diff --git a/command.c b/command.c
index bf5a2e3..de8d0ff 100644
--- a/command.c
+++ b/command.c
@@ -316,6 +316,13 @@ static void commandWhois(uint id, char *params) {
 	replies.whois += count;
 }
 
+static void commandWhowas(uint id, char *params) {
+	(void)id;
+	if (!params) return;
+	ircFormat("WHOWAS %s\r\n", params);
+	replies.whowas++;
+}
+
 static void commandNS(uint id, char *params) {
 	(void)id;
 	if (params) ircFormat("PRIVMSG NickServ :%s\r\n", params);
@@ -500,6 +507,7 @@ static const struct Handler {
 	{ "/uninvex", commandUninvex, 0 },
 	{ "/voice", commandVoice, 0 },
 	{ "/whois", commandWhois, 0 },
+	{ "/whowas", commandWhowas, 0 },
 	{ "/window", commandWindow, 0 },
 };
 
diff --git a/handle.c b/handle.c
index b648840..a771fa3 100644
--- a/handle.c
+++ b/handle.c
@@ -1058,12 +1058,12 @@ static void handleReplyWhoisUser(struct Message *msg) {
 
 static void handleReplyWhoisServer(struct Message *msg) {
 	require(msg, false, 4);
-	if (!replies.whois) return;
+	if (!replies.whois && !replies.whowas) return;
 	uiFormat(
 		Network, Warm, tagTime(msg),
-		"\3%02d%s\3\tis connected to %s (%s)",
+		"\3%02d%s\3\t%s connected to %s (%s)",
 		completeColor(Network, msg->params[1]), msg->params[1],
-		msg->params[2], msg->params[3]
+		(replies.whowas ? "was" : "is"), msg->params[2], msg->params[3]
 	);
 }
 
@@ -1135,6 +1135,26 @@ static void handleReplyEndOfWhois(struct Message *msg) {
 	replies.whois--;
 }
 
+static void handleReplyWhowasUser(struct Message *msg) {
+	require(msg, false, 6);
+	if (!replies.whowas) return;
+	completeTouch(Network, msg->params[1], hash(msg->params[2]));
+	uiFormat(
+		Network, Warm, tagTime(msg),
+		"\3%02d%s\3\twas %s!%s@%s (%s)",
+		hash(msg->params[2]), msg->params[1],
+		msg->params[1], msg->params[2], msg->params[3], msg->params[5]
+	);
+}
+
+static void handleReplyEndOfWhowas(struct Message *msg) {
+	require(msg, false, 2);
+	if (strcmp(msg->params[1], self.nick)) {
+		completeRemove(Network, msg->params[1]);
+	}
+	if (replies.whowas) replies.whowas--;
+}
+
 static void handleReplyAway(struct Message *msg) {
 	require(msg, false, 3);
 	// Might be part of a WHOIS response.
@@ -1300,6 +1320,7 @@ static const struct Handler {
 	{ "311", handleReplyWhoisUser },
 	{ "312", handleReplyWhoisServer },
 	{ "313", handleReplyWhoisGeneric },
+	{ "314", handleReplyWhowasUser },
 	{ "315", handleReplyEndOfWho },
 	{ "317", handleReplyWhoisIdle },
 	{ "318", handleReplyEndOfWhois },
@@ -1320,6 +1341,7 @@ static const struct Handler {
 	{ "366", handleReplyEndOfNames },
 	{ "367", handleReplyBanList },
 	{ "368", handleReplyEndOfBanList },
+	{ "369", handleReplyEndOfWhowas },
 	{ "372", handleReplyMOTD },
 	{ "378", handleReplyWhoisGeneric },
 	{ "379", handleReplyWhoisGeneric },
honest. After half of the Ruth Ozeki novel and now this, I need to get back to some genre fiction. 2022-07-26Rewrite glitch from new pngoJune McEnroe 2022-07-26Update Care with time-to-ID and piercingsJune McEnroe 2022-07-26Add -w to upJune McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe