diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-10 07:32:03 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-10 07:35:42 +0200 |
commit | 5dda5661ae95ff14ccf587fa8294ba7153160d9f (patch) | |
tree | 40672ff87024d1c1d069f7a2162dd534d02172cb /degesch.c | |
parent | 628facf286d6d4b708e5e6bda653379c7dffb8d4 (diff) | |
download | xK-5dda5661ae95ff14ccf587fa8294ba7153160d9f.tar.gz xK-5dda5661ae95ff14ccf587fa8294ba7153160d9f.tar.xz xK-5dda5661ae95ff14ccf587fa8294ba7153160d9f.zip |
degesch: send after-connect joins more cleverly
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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 -------------------------------------------------------------- |