summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-26 22:37:18 -0400
committerJune McEnroe <june@causal.agency>2019-10-26 22:37:18 -0400
commited4a5d35864edac6da02a2ca3970f45b1279911b (patch)
tree42c08d0b937085ebe746ecd0b1d057a92fe13ae5
parentWait for AUTHENTICATE + from server (diff)
downloadpounce-ed4a5d35864edac6da02a2ca3970f45b1279911b.tar.gz
pounce-ed4a5d35864edac6da02a2ca3970f45b1279911b.zip
Handle nick collision
-rw-r--r--state.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/state.c b/state.c
index ee3ae78..01829a4 100644
--- a/state.c
+++ b/state.c
@@ -162,6 +162,12 @@ static void handleReplyISupport(struct Message *msg) {
 	}
 }
 
+static void handleErrorNicknameInUse(struct Message *msg) {
+	if (self.nick) return;
+	if (!msg->params[1]) errx(EX_PROTOCOL, "ERR_NICKNAMEINUSE without nick");
+	serverFormat("NICK %s_\r\n", msg->params[1]);
+}
+
 static bool fromSelf(const struct Message *msg) {
 	if (!self.nick) return false;
 	size_t len = strlen(self.nick);
@@ -226,6 +232,7 @@ static const struct {
 	{ "004", handleReplyMyInfo },
 	{ "005", handleReplyISupport },
 	{ "332", handleReplyTopic },
+	{ "433", handleErrorNicknameInUse },
 	{ "AUTHENTICATE", handleAuthenticate },
 	{ "CAP", handleCap },
 	{ "ERROR", handleError },