summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2016-01-26 09:00:29 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2016-01-26 09:00:29 +0100
commitc7a3d2822cc9f32d394843296ecff259273d2827 (patch)
tree603d5d76d1814b3fe810fb205c35fed871f21d2e /src
parent18287781f627c1dd5acb62d7cc83efeb392e7abc (diff)
parenteba160ca6df194913d80df67c19e929b9428d77e (diff)
downloadirssi-c7a3d2822cc9f32d394843296ecff259273d2827.zip
Merge pull request #399 from LemonBoy/bots
Change when the autocmds are sent.
Diffstat (limited to 'src')
-rw-r--r--src/core/channels.c31
-rw-r--r--src/core/channels.h1
-rw-r--r--src/irc/core/irc-channels-setup.c6
3 files changed, 32 insertions, 6 deletions
diff --git a/src/core/channels.c b/src/core/channels.c
index 9af8b844..9c3b92ba 100644
--- a/src/core/channels.c
+++ b/src/core/channels.c
@@ -233,23 +233,46 @@ static int match_nick_flags(SERVER_REC *server, NICK_REC *nick, char flag)
void channel_send_autocommands(CHANNEL_REC *channel)
{
CHANNEL_SETUP_REC *rec;
- NICK_REC *nick;
- char **bots, **bot;
g_return_if_fail(IS_CHANNEL(channel));
if (channel->session_rejoin)
- return;
+ return;
rec = channel_setup_find(channel->name, channel->server->connrec->chatnet);
if (rec == NULL || rec->autosendcmd == NULL || !*rec->autosendcmd)
return;
+ /* if the autosendcmd alone (with no -bots parameter) has been
+ * specified then send it right after joining the channel, when
+ * the WHO list hasn't been yet retrieved.
+ * Depending on the value of the 'channel_max_who_sync' option
+ * the WHO list might not be retrieved after the join event. */
+
if (rec->botmasks == NULL || !*rec->botmasks) {
/* just send the command. */
eval_special_string(rec->autosendcmd, "", channel->server, channel);
- return;
}
+}
+
+void channel_send_botcommands(CHANNEL_REC *channel)
+{
+ CHANNEL_SETUP_REC *rec;
+ NICK_REC *nick;
+ char **bots, **bot;
+
+ g_return_if_fail(IS_CHANNEL(channel));
+
+ if (channel->session_rejoin)
+ return;
+
+ rec = channel_setup_find(channel->name, channel->server->connrec->chatnet);
+ if (rec == NULL || rec->autosendcmd == NULL || !*rec->autosendcmd)
+ return;
+
+ /* this case has already been handled by channel_send_autocommands */
+ if (rec->botmasks == NULL || !*rec->botmasks)
+ return;
/* find first available bot.. */
bots = g_strsplit(rec->botmasks, " ", -1);
diff --git a/src/core/channels.h b/src/core/channels.h
index 0839d69b..bd136fe2 100644
--- a/src/core/channels.h
+++ b/src/core/channels.h
@@ -31,6 +31,7 @@ void channel_change_visible_name(CHANNEL_REC *channel, const char *name);
/* Send the auto send command to channel */
void channel_send_autocommands(CHANNEL_REC *channel);
+void channel_send_botcommands(CHANNEL_REC *channel);
void channels_init(void);
void channels_deinit(void);
diff --git a/src/irc/core/irc-channels-setup.c b/src/irc/core/irc-channels-setup.c
index 2320352d..bbbc095c 100644
--- a/src/irc/core/irc-channels-setup.c
+++ b/src/irc/core/irc-channels-setup.c
@@ -24,10 +24,12 @@
void irc_channels_setup_init(void)
{
- signal_add("channel wholist", (SIGNAL_FUNC) channel_send_autocommands);
+ signal_add("channel wholist", (SIGNAL_FUNC) channel_send_botcommands);
+ signal_add("channel joined", (SIGNAL_FUNC) channel_send_autocommands);
}
void irc_channels_setup_deinit(void)
{
- signal_remove("channel wholist", (SIGNAL_FUNC) channel_send_autocommands);
+ signal_remove("channel wholist", (SIGNAL_FUNC) channel_send_botcommands);
+ signal_remove("channel joined", (SIGNAL_FUNC) channel_send_autocommands);
}