summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-08-12 23:00:42 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-08-12 23:00:42 +0200
commit809fd4ab7479a05261aa0a93f8cc7066bfef243d (patch)
tree617f64fdaab79658cdb34d8196c4c481515bb3e9
parent776c334128210c1040ca321689a3c389df33b80c (diff)
downloadxK-809fd4ab7479a05261aa0a93f8cc7066bfef243d.tar.gz
xK-809fd4ab7479a05261aa0a93f8cc7066bfef243d.tar.xz
xK-809fd4ab7479a05261aa0a93f8cc7066bfef243d.zip
kike: send NICK notification back to ourselves
Also cleanup.
-rw-r--r--kike.c14
1 files 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);
}