summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-29 22:53:00 -0400
committerJune McEnroe <june@causal.agency>2019-10-29 22:53:00 -0400
commita1df359f57b0b17f8a9e4661a3c9e04861eb5d53 (patch)
treec21459e1ec71460ce2f35e82b6fc017caf77e525
parentClarify some documentation (diff)
downloadpounce-a1df359f57b0b17f8a9e4661a3c9e04861eb5d53.tar.gz
pounce-a1df359f57b0b17f8a9e4661a3c9e04861eb5d53.zip
Update self origin on nick change
Diffstat (limited to '')
-rw-r--r--state.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/state.c b/state.c
index b1f84ad..f51a09b 100644
--- a/state.c
+++ b/state.c
@@ -259,7 +259,16 @@ static bool originSelf(const char *origin) {
 
 static void handleNick(struct Message *msg) {
 	require(msg, true, 1);
-	if (originSelf(msg->origin)) set(&self.nick, msg->params[0]);
+	if (!originSelf(msg->origin)) return;
+	set(&self.nick, msg->params[0]);
+
+	char *rest = strchr(self.origin, '!');
+	assert(rest);
+	size_t size = strlen(self.nick) + strlen(rest) + 1;
+	char *origin = malloc(size);
+	if (!origin) err(EX_OSERR, "malloc");
+	snprintf(origin, size, "%s%s", self.nick, rest);
+	set(&self.origin, origin);
 }
 
 static void handleJoin(struct Message *msg) {