From 809fd4ab7479a05261aa0a93f8cc7066bfef243d Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Tue, 12 Aug 2014 23:00:42 +0200 Subject: kike: send NICK notification back to ourselves Also cleanup. --- kike.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/kike.c b/kike.c index 0e5f2cb..cd2abc0 100644 --- a/kike.c +++ b/kike.c @@ -668,18 +668,15 @@ irc_send_to_roommates (struct client *c, const char *message) if (chan->modes & IRC_CHAN_MODE_QUIET || !channel_get_user (chan, c)) continue; - - // When we're unregistering, the str_map_find() will return zero, - // which will prevent sending the QUIT message to ourselves. for (struct channel_user *iter = chan->users; iter; iter = iter->next) - str_map_set (&targets, iter->c->nickname, - str_map_find (&c->ctx->users, iter->c->nickname)); + str_map_set (&targets, iter->c->nickname, iter->c); } str_map_iter_init (&iter, &targets); struct client *target; while ((target = str_map_iter_next (&iter))) - client_send (target, "%s", message); + if (target != c) + client_send (target, "%s", message); } // --- Clients (continued) ----------------------------------------------------- @@ -740,9 +737,6 @@ client_unregister (struct client *c, const char *reason) if (!c->registered) return; - // Make the user effectively non-existent - str_map_set (&c->ctx->users, c->nickname, NULL); - char *message = xstrdup_printf (":%s!%s@%s QUIT :%s", c->nickname, c->username, c->hostname, reason); irc_send_to_roommates (c, message); @@ -761,6 +755,7 @@ client_unregister (struct client *c, const char *reason) irc_channel_destroy_if_empty (c->ctx, chan); } + str_map_set (&c->ctx->users, c->nickname, NULL); free (c->nickname); c->nickname = NULL; c->registered = false; @@ -1055,6 +1050,7 @@ irc_handle_nick (const struct irc_message *msg, struct client *c) char *message = xstrdup_printf (":%s!%s@%s NICK :%s", c->nickname, c->username, c->hostname, nickname); irc_send_to_roommates (c, message); + client_send (c, "%s", message); free (message); } -- cgit v1.2.3-70-g09d2