kike: send NICK notification back to ourselves

Also cleanup.
This commit is contained in:
Přemysl Eric Janouch 2014-08-12 23:00:42 +02:00
parent 776c334128
commit 809fd4ab74
1 changed files with 5 additions and 9 deletions

12
kike.c
View File

@ -668,17 +668,14 @@ 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)))
if (target != c)
client_send (target, "%s", message);
}
@ -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);
}