From 5dda5661ae95ff14ccf587fa8294ba7153160d9f Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Mon, 10 Aug 2015 07:32:03 +0200 Subject: degesch: send after-connect joins more cleverly --- degesch.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/degesch.c b/degesch.c index 3e31eb5..2332690 100644 --- a/degesch.c +++ b/degesch.c @@ -3897,18 +3897,40 @@ on_irc_autojoin_timeout (void *user_data) { struct server *s = user_data; - // TODO: split autojoin at commas and make a joined set with regular rejoins + // Since we may not have information from RPL_ISUPPORT yet, + // it's our safest bet to send the channels one at a time + + struct str_map joins_sent; + str_map_init (&joins_sent); + + // We don't know the casemapping yet either, however ASCII should do + joins_sent.key_xfrm = tolower_ascii_strxfrm; + + // First join autojoin channels in their given order const char *autojoin = get_config_string (s->config, "autojoin"); if (autojoin) - irc_send (s, "JOIN :%s", autojoin); + { + struct str_vector v; + str_vector_init (&v); + split_str (autojoin, ',', &v); + for (size_t i = 0; i < v.len; i++) + { + irc_send (s, "JOIN :%s", v.vector[i]); + str_map_set (&joins_sent, v.vector[i], (void *) 1); + } + str_vector_free (&v); + } + // Then also rejoin any channels from the last disconnect struct str_map_iter iter; str_map_iter_init (&iter, &s->irc_channels); - struct channel *channel; while ((channel = str_map_iter_next (&iter))) - if (!channel->left_manually) + if (!channel->left_manually + && !str_map_find (&joins_sent, channel->name)) irc_send (s, "JOIN :%s", channel->name); + + str_map_free (&joins_sent); } // --- Server I/O -------------------------------------------------------------- -- cgit v1.2.3-70-g09d2