diff options
| -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 --------------------------------------------------------------  | 
