Save own username for message echoing

master
C. McEnroe 2020-02-05 00:40:24 -05:00
parent 37ec1e8232
commit 7414a8a11c
3 changed files with 6 additions and 2 deletions

1
chat.h
View File

@ -73,6 +73,7 @@ extern struct Self {
char *chanTypes; char *chanTypes;
char *prefixes; char *prefixes;
char *nick; char *nick;
char *user;
enum Color color; enum Color color;
} self; } self;

View File

@ -23,7 +23,7 @@ void command(size_t id, char *input) {
ircFormat("PRIVMSG %s :%s\r\n", idNames[id], input); ircFormat("PRIVMSG %s :%s\r\n", idNames[id], input);
struct Message msg = { struct Message msg = {
.nick = self.nick, .nick = self.nick,
// TODO: .user, .user = self.user,
.cmd = "PRIVMSG", .cmd = "PRIVMSG",
.params[0] = idNames[id], .params[0] = idNames[id],
.params[1] = input, .params[1] = input,

View File

@ -187,7 +187,10 @@ static void handleJoin(struct Message *msg) {
require(msg, true, 1); require(msg, true, 1);
size_t id = idFor(msg->params[0]); size_t id = idFor(msg->params[0]);
if (self.nick && !strcmp(msg->nick, self.nick)) { if (self.nick && !strcmp(msg->nick, self.nick)) {
if (!self.user) {
set(&self.user, msg->user);
self.color = hash(msg->user); self.color = hash(msg->user);
}
idColors[id] = hash(msg->params[0]); idColors[id] = hash(msg->params[0]);
uiShowID(id); uiShowID(id);
} }