summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-22 14:32:20 -0400
committerJune McEnroe <june@causal.agency>2020-03-22 14:32:20 -0400
commiteb6316c2352f0b50db4167f66528dfaee396f0ff (patch)
treedb714261a1f81c43298020260f565944988df1c2
parentAdd /say (diff)
downloadcatgirl-eb6316c2352f0b50db4167f66528dfaee396f0ff.tar.gz
catgirl-eb6316c2352f0b50db4167f66528dfaee396f0ff.zip
Track own host, handle CHGHOST
-rw-r--r--catgirl.17
-rw-r--r--chat.h2
-rw-r--r--handle.c18
3 files changed, 26 insertions, 1 deletions
diff --git a/catgirl.1 b/catgirl.1
index 138b982..ad820ac 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -560,6 +560,13 @@ join = #ascii.town
 .Re
 .It
 .Rs
+.%A Christine Dodrill
+.%T IRCv3.2 chghost Extension
+.%I IRCv3 Working Group
+.%U https://ircv3.net/specs/extensions/chghost-3.2
+.Re
+.It
+.Rs
 .%A Daniel Oaks
 .%T IRC Formatting
 .%I ircdocs
diff --git a/chat.h b/chat.h
index 91d175f..468d864 100644
--- a/chat.h
+++ b/chat.h
@@ -97,6 +97,7 @@ extern struct Network {
 
 #define ENUM_CAP \
 	X("causal.agency/consumer", CapConsumer) \
+	X("chghost", CapChghost) \
 	X("extended-join", CapExtendedJoin) \
 	X("invite-notify", CapInviteNotify) \
 	X("multi-prefix", CapMultiPrefix) \
@@ -119,6 +120,7 @@ extern struct Self {
 	char *join;
 	char *nick;
 	char *user;
+	char *host;
 	enum Color color;
 	char *quit;
 } self;
diff --git a/handle.c b/handle.c
index fa3f36b..f079c00 100644
--- a/handle.c
+++ b/handle.c
@@ -280,10 +280,13 @@ static void handleJoin(struct Message *msg) {
 	require(msg, true, 1);
 	uint id = idFor(msg->params[0]);
 	if (!strcmp(msg->nick, self.nick)) {
-		if (!self.user) {
+		if (!self.user || strcmp(self.user, msg->user)) {
 			set(&self.user, msg->user);
 			self.color = hash(msg->user);
 		}
+		if (!self.host || strcmp(self.host, msg->host)) {
+			set(&self.host, msg->host);
+		}
 		idColors[id] = hash(msg->params[0]);
 		completeTouch(None, msg->params[0], idColors[id]);
 		if (replies.join) {
@@ -306,6 +309,18 @@ static void handleJoin(struct Message *msg) {
 	);
 }
 
+static void handleChghost(struct Message *msg) {
+	require(msg, true, 2);
+	if (strcmp(msg->nick, self.nick)) return;
+	if (!self.user || strcmp(self.user, msg->params[0])) {
+		set(&self.user, msg->params[0]);
+		self.color = hash(msg->params[0]);
+	}
+	if (!self.host || strcmp(self.host, msg->params[1])) {
+		set(&self.host, msg->params[1]);
+	}
+}
+
 static void handlePart(struct Message *msg) {
 	require(msg, true, 1);
 	uint id = idFor(msg->params[0]);
@@ -1076,6 +1091,7 @@ static const struct Handler {
 	{ "906", handleErrorSASLFail },
 	{ "AUTHENTICATE", handleAuthenticate },
 	{ "CAP", handleCap },
+	{ "CHGHOST", handleChghost },
 	{ "ERROR", handleError },
 	{ "INVITE", handleInvite },
 	{ "JOIN", handleJoin },
td> 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