summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-03 23:00:31 -0400
committerJune McEnroe <june@causal.agency>2018-08-03 23:00:53 -0400
commit9f17adce8005dfb7a005dc327cafa13ca4c7b379 (patch)
treed58cfa15cc0a2d09d271178fb466e1af4ce54f16
parentUse a wide pad for the topic (diff)
downloadcatgirl-9f17adce8005dfb7a005dc327cafa13ca4c7b379.tar.gz
catgirl-9f17adce8005dfb7a005dc327cafa13ca4c7b379.zip
Track own username
So that we can colour our own messages correctly.
-rw-r--r--chat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/chat.c b/chat.c
index 003c19d..c0a8231 100644
--- a/chat.c
+++ b/chat.c
@@ -167,7 +167,6 @@ static void uiChat(const char *line) {
 	waddch(ui.chat, '\n');
 	uiAdd(ui.chat, line);
 }
-
 static void uiFmt(const char *format, ...) {
 	char *buf;
 	va_list ap;
@@ -194,6 +193,7 @@ static struct {
 	struct tls *tls;
 	bool verbose;
 	char *nick;
+	char *user;
 	char *chan;
 } client;
 
@@ -247,6 +247,10 @@ static void handleJoin(char *prefix, char *params) {
 	char *nick = prift(&prefix);
 	char *user = prift(&prefix);
 	char *chan = shift(&params);
+	if (!strcmp(nick, client.nick) && strcmp(user, client.user)) {
+		free(client.user);
+		client.user = strdup(user);
+	}
 	uiFmt(
 		"\3%d%s\3 arrived in \3%d%s\3",
 		color(user), nick, color(chan), chan
@@ -500,8 +504,9 @@ int main(int argc, char *argv[]) {
 		getnstr(buf, sizeof(buf) - 1);
 		client.nick = strdup(buf);
 	}
-	erase();
+	client.user = strdup(client.nick);
 
+	erase();
 	uiInit();
 	uiChat("Traveling...");
 	uiDraw();
@@ -538,7 +543,7 @@ int main(int argc, char *argv[]) {
 
 	if (webPass) webirc(webPass);
 	clientFmt("NICK %s\r\n", client.nick);
-	clientFmt("USER %s x x :%s\r\n", client.nick, client.nick);
+	clientFmt("USER %s 0 * :%s\r\n", client.user, client.nick);
 
 	struct pollfd fds[2] = {
 		{ .fd = STDIN_FILENO, .events = POLLIN },
y tagging from hilexJune McEnroe 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe 2021-01-12Split fields by tab onlyJune McEnroe 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe