From 7414a8a11cd8d16fea47e30513b3a5eaeb232ba1 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Wed, 5 Feb 2020 00:40:24 -0500 Subject: Save own username for message echoing --- chat.h | 1 + command.c | 2 +- handle.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chat.h b/chat.h index c8b31c2..90c7da8 100644 --- a/chat.h +++ b/chat.h @@ -73,6 +73,7 @@ extern struct Self { char *chanTypes; char *prefixes; char *nick; + char *user; enum Color color; } self; diff --git a/command.c b/command.c index ab05587..76d7d7b 100644 --- a/command.c +++ b/command.c @@ -23,7 +23,7 @@ void command(size_t id, char *input) { ircFormat("PRIVMSG %s :%s\r\n", idNames[id], input); struct Message msg = { .nick = self.nick, - // TODO: .user, + .user = self.user, .cmd = "PRIVMSG", .params[0] = idNames[id], .params[1] = input, diff --git a/handle.c b/handle.c index b5585ba..85783d7 100644 --- a/handle.c +++ b/handle.c @@ -187,7 +187,10 @@ static void handleJoin(struct Message *msg) { require(msg, true, 1); size_t id = idFor(msg->params[0]); if (self.nick && !strcmp(msg->nick, self.nick)) { - self.color = hash(msg->user); + if (!self.user) { + set(&self.user, msg->user); + self.color = hash(msg->user); + } idColors[id] = hash(msg->params[0]); uiShowID(id); } -- cgit 1.4.1-2-gfad0