aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-06-28 10:37:11 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-06-28 10:37:11 +0100
commit58646d9244557320ec811ee0b67519027170eede (patch)
tree8a384343e35895a7742a6e34117274a46d8ebc66 /irc_commands.c
parenta670aeb34e4f3c4a1fd910aa5944fed4f9c20d7a (diff)
Allow joining multiple channels at once. Although BitlBee doesn't advertise
support for this, irssi tries to do this anyway.
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 30518a99..bcb2fef2 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -127,30 +127,49 @@ static void irc_cmd_pong( irc_t *irc, char **cmd )
static void irc_cmd_join( irc_t *irc, char **cmd )
{
- irc_channel_t *ic;
-
- if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL )
- ic = irc_channel_new( irc, cmd[1] );
+ char *comma, *s = cmd[1];
- if( ic == NULL )
+ while( s )
{
- irc_send_num( irc, 479, "%s :Invalid channel name", cmd[1] );
- return;
+ irc_channel_t *ic;
+
+ if( ( comma = strchr( s, ',' ) ) )
+ *comma = '\0';
+
+ if( ( ic = irc_channel_by_name( irc, s ) ) == NULL )
+ ic = irc_channel_new( irc, s );
+
+ if( ic == NULL )
+ {
+ irc_send_num( irc, 479, "%s :Invalid channel name", s );
+ goto next;
+ }
+
+ if( ic->flags & IRC_CHANNEL_JOINED )
+ /* Dude, you're already there...
+ RFC doesn't have any reply for that though? */
+ goto next;
+
+ if( ic->f->join && !ic->f->join( ic ) )
+ /* The story is: FALSE either means the handler
+ showed an error message, or is doing some work
+ before the join should be confirmed. (In the
+ latter case, the caller should take care of that
+ confirmation.) TRUE means all's good, let the
+ user join the channel right away. */
+ goto next;
+
+ irc_channel_add_user( ic, irc->user );
+
+next:
+ if( comma )
+ {
+ s = comma + 1;
+ *comma = ',';
+ }
+ else
+ break;
}
-
- if( ic->flags & IRC_CHANNEL_JOINED )
- return; /* Dude, you're already there...
- RFC doesn't have any reply for that though? */
-
- if( ic->f->join && !ic->f->join( ic ) )
- /* The story is: FALSE either means the handler showed an error
- message, or is doing some work before the join should be
- confirmed. (In the latter case, the caller should take care
- of that confirmation.)
- TRUE means all's good, let the user join the channel right away. */
- return;
-
- irc_channel_add_user( ic, irc->user );
}
static void irc_cmd_names( irc_t *irc, char **cmd )