aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-18 21:12:55 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-18 21:12:55 +0100
commit4f22a68c5d1dfd0d1da8b44c3a9d60a7754633b7 (patch)
treef0200cbad80818e484cd43b99a7f461cd8a8b159
parent3e59c8d79ae39d8c1412c2bbf8dced6ded74af6f (diff)
Automatically operate on the current channel if just using "channel set".
-rw-r--r--doc/user-guide/commands.xml10
-rw-r--r--root_commands.c16
2 files changed, 17 insertions, 9 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
index 2f5c961a..ae2d76fb 100644
--- a/doc/user-guide/commands.xml
+++ b/doc/user-guide/commands.xml
@@ -210,10 +210,10 @@
</bitlbee-command>
<bitlbee-command name="set">
- <syntax>channel &lt;channel id&gt; set</syntax>
- <syntax>channel &lt;channel id&gt; set &lt;setting&gt;</syntax>
- <syntax>channel &lt;channel id&gt; set &lt;setting&gt; &lt;value&gt;</syntax>
- <syntax>channel &lt;channel id&gt; set -del &lt;setting&gt;</syntax>
+ <syntax>channel [&lt;channel id&gt;] set</syntax>
+ <syntax>channel [&lt;channel id&gt;] set &lt;setting&gt;</syntax>
+ <syntax>channel [&lt;channel id&gt;] set &lt;setting&gt; &lt;value&gt;</syntax>
+ <syntax>channel [&lt;channel id&gt;] set -del &lt;setting&gt;</syntax>
<description>
<para>
@@ -225,7 +225,7 @@
</para>
<para>
- The channel ID can be a number (see <emphasis>channel list</emphasis>), or (part of) its name, as long as it matches only one channel.
+ The channel ID can be a number (see <emphasis>channel list</emphasis>), or (part of) its name, as long as it matches only one channel. If you want to change settings of the current channel, you can omit the channel ID.
</para>
</description>
</bitlbee-command>
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 );