diff options
author | Timo Sirainen <cras@irssi.org> | 2002-03-17 02:50:12 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-03-17 02:50:12 +0000 |
commit | 500ae5773e3088d7b7c37f6404a5964744ab75af (patch) | |
tree | d635ce65f3d5eafef2b46c790ba52e6cd34a2935 /src/irc | |
parent | 0c48fff77e7ac6e373bfb378f19fd493d40e6721 (diff) | |
download | irssi-500ae5773e3088d7b7c37f6404a5964744ab75af.zip |
If autojoining to !channel failed because it didn't exist, create it by
joining to !!channel
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2627 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/channel-events.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 4df87fa9..81a87f26 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -56,6 +56,32 @@ static void event_cannot_join(IRC_SERVER_REC *server, const char *data) g_free(params); } +static void event_no_such_channel(IRC_SERVER_REC *server, const char *data) +{ + CHANNEL_REC *chanrec; + CHANNEL_SETUP_REC *setup; + char *params, *channel; + + params = event_get_params(data, 2, NULL, &channel); + chanrec = *channel == '!' && channel[1] != '\0' ? + channel_find(SERVER(server), channel) : NULL; + g_free(params); + + if (chanrec != NULL) { + /* !channel didn't exist, so join failed */ + setup = channel_setup_find(chanrec->name, + chanrec->server->connrec->chatnet); + if (setup != NULL && setup->autojoin) { + /* it's autojoin channel though, + so create it */ + irc_send_cmdv(server, "JOIN !%s", chanrec->name); + return; + } + } + + event_cannot_join(server, data); +} + static void event_duplicate_channel(IRC_SERVER_REC *server, const char *data) { CHANNEL_REC *chanrec; @@ -310,7 +336,7 @@ void channel_events_init(void) { settings_add_bool("misc", "join_auto_chans_on_invite", TRUE); - signal_add_first("event 403", (SIGNAL_FUNC) event_cannot_join); /* no such channel */ + signal_add_first("event 403", (SIGNAL_FUNC) event_no_such_channel); /* no such channel */ signal_add_first("event 405", (SIGNAL_FUNC) event_cannot_join); /* too many channels */ signal_add_first("event 407", (SIGNAL_FUNC) event_duplicate_channel); /* duplicate channel */ signal_add_first("event 442", (SIGNAL_FUNC) event_cannot_join); /* not on that channel (dalnet) */ @@ -334,7 +360,7 @@ void channel_events_init(void) void channel_events_deinit(void) { - signal_remove("event 403", (SIGNAL_FUNC) event_cannot_join); /* no such channel */ + signal_remove("event 403", (SIGNAL_FUNC) event_no_such_channel); /* no such channel */ signal_remove("event 405", (SIGNAL_FUNC) event_cannot_join); /* too many channels */ signal_remove("event 407", (SIGNAL_FUNC) event_duplicate_channel); /* duplicate channel */ signal_remove("event 442", (SIGNAL_FUNC) event_cannot_join); /* not on that channel (dalnet) */ |