summary refs log tree commit diff
path: root/state.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--state.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/state.c b/state.c
index 48f7185..e86cf01 100644
--- a/state.c
+++ b/state.c
@@ -104,6 +104,20 @@ static void handleReplyISupport(struct Message msg) {
 	}
 }
 
+static bool self(struct Message msg) {
+	assert(nick);
+	size_t len = strlen(nick);
+	if (strncmp(msg.origin, nick, len)) return false;
+	if (strlen(msg.origin) < len || msg.origin[len] != '!') return false;
+	return true;
+}
+
+static void handleNick(struct Message msg) {
+	if (!msg.origin) errx(EX_PROTOCOL, "NICK without origin");
+	if (!msg.params[0]) errx(EX_PROTOCOL, "NICK without new nick");
+	if (self(msg)) set(&nick, msg.params[0]);
+}
+
 static void handleError(struct Message msg) {
 	errx(EX_UNAVAILABLE, "%s", msg.params[0]);
 }
@@ -119,6 +133,7 @@ static const struct {
 	{ "005", handleReplyISupport },
 	{ "CAP", handleCap },
 	{ "ERROR", handleError },
+	{ "NICK", handleNick },
 };
 
 void stateParse(char *line) {
td>June McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe 2019-02-17Always split spans after newlinesJune McEnroe 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe233ce41d17e582bb1fff14af8f5a42f3c83c9d&follow=1'>Use char literals consistentlyJune McEnroe