AmendHub

Download:

jcs

/

wallops

/

amendments

/

108

irc: Update query nicks when they change


jcs made amendment 108 2 months ago
--- irc.c Mon Sep 16 09:46:22 2024 +++ irc.c Mon Sep 16 10:15:57 2024 @@ -661,15 +661,15 @@ irc_process_server(struct irc_connection *conn) return true; } if (strcmp(msg.cmd, "NICK") == 0) { - user = irc_parse_user(msg.source); + struct chatter_tab *tab; + user = irc_parse_user(msg.source); if (strcasecmp(user->nick, conn->nick) == 0) { chatter_printf(conn->chatter, conn, NULL, "$B*** %s$0 is now known as $B%s$0", user->nick, msg.msg); irc_change_user_nick(conn, NULL, user, msg.msg); } - SLIST_FOREACH(channel, &conn->channels_list, list) { if (!irc_nick_is_in_channel(channel, user->nick)) continue; @@ -680,7 +680,14 @@ irc_process_server(struct irc_connection *conn) user->nick, msg.msg); irc_change_user_nick(conn, channel, user, msg.msg); } - /* TODO: if any query windows for this nick, update them */ + SLIST_FOREACH(tab, &conn->chatter->tabs_list, list) { + if (tab->query_nick[0] && + strcasecmp(tab->query_nick, user->nick) == 0) { + strlcpy(tab->query_nick, user->nick, + sizeof(user->nick)); + conn->chatter->need_tab_bar_redraw = true; + } + } return true; } if (strcmp(msg.cmd, "NOTICE") == 0) { @@ -889,13 +896,20 @@ irc_process_server(struct irc_connection *conn) if ((channel = irc_find_channel(conn, msg.arg[1]))) strlcpy(channel->topic, msg.msg, sizeof(channel->topic)); return true; - case 333: + case 333: { /* TOPIC creator */ + unsigned long ts; + user = irc_parse_user(msg.arg[2]); + + /* TODO: convert unix to mac time, strftime */ + sscanf(msg.arg[3], "%ld", &ts); + chatter_printf(conn->chatter, conn, msg.arg[1], "$B***$0 Topic set by $B%s$0", user->nick); return true; + } case 338: case 378: /* WHOIS host */