From 4f22a68c5d1dfd0d1da8b44c3a9d60a7754633b7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Jul 2010 21:12:55 +0100 Subject: Automatically operate on the current channel if just using "channel set". --- root_commands.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 3b607d22..ddef9cde 100644 --- a/root_commands.c +++ b/root_commands.c @@ -549,15 +549,23 @@ static void cmd_channel( irc_t *irc, char **cmd ) return; } - MIN_ARGS( 2 ); - len = strlen( cmd[2] ); - if( ( ic = irc_channel_get( irc, cmd[1] ) ) == NULL ) { - irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); + /* If this doesn't match any channel, maybe this is the short + syntax (only works when used inside a channel). */ + if( ( len = strlen( cmd[1] ) ) && + g_strncasecmp( cmd[1], "set", len ) == 0 && + ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) ) + cmd_set_real( irc, cmd + 1, &ic->set, NULL ); + else + irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); + return; } + MIN_ARGS( 2 ); + len = strlen( cmd[2] ); + if( len >= 1 && g_strncasecmp( cmd[2], "set", len ) == 0 ) { cmd_set_real( irc, cmd + 2, &ic->set, NULL ); -- cgit v1.2.3