diff options
Diffstat (limited to 'src/plugins/irc/irc-command.c')
-rw-r--r-- | src/plugins/irc/irc-command.c | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 1e8a31b6f..4efd80849 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2822,21 +2822,24 @@ irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv, void irc_command_mode_server (struct t_irc_server *server, - struct t_irc_channel *channel, const char *arguments, + const char *command, + struct t_irc_channel *channel, + const char *arguments, int flags) { - if (server && (channel || arguments)) + if (server && command && (channel || arguments)) { if (channel && arguments) { irc_server_sendf (server, flags, NULL, - "MODE %s %s", - channel->name, arguments); + "%s %s %s", + command, channel->name, arguments); } else { irc_server_sendf (server, flags, NULL, - "MODE %s", + "%s %s", + command, (channel) ? channel->name : arguments); } } @@ -2870,13 +2873,14 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc, "mode"); return WEECHAT_RC_OK; } - irc_command_mode_server (ptr_server, ptr_channel, argv_eol[1], + irc_command_mode_server (ptr_server, "MODE", ptr_channel, + argv_eol[1], IRC_SERVER_SEND_OUTQ_PRIO_HIGH); } else { /* user gives channel, use arguments as-is */ - irc_command_mode_server (ptr_server, NULL, argv_eol[1], + irc_command_mode_server (ptr_server, "MODE", NULL, argv_eol[1], IRC_SERVER_SEND_OUTQ_PRIO_HIGH); } } @@ -2884,12 +2888,13 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc, { if (ptr_channel) { - irc_command_mode_server (ptr_server, ptr_channel, NULL, + irc_command_mode_server (ptr_server, "MODE", ptr_channel, NULL, IRC_SERVER_SEND_OUTQ_PRIO_HIGH); } else { - irc_command_mode_server (ptr_server, NULL, ptr_server->nick, + irc_command_mode_server (ptr_server, "MODE", NULL, + ptr_server->nick, IRC_SERVER_SEND_OUTQ_PRIO_HIGH); } } @@ -4195,11 +4200,48 @@ irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc, /* make C compiler happy */ (void) data; - if (argc < 3) - return WEECHAT_RC_ERROR; - - irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "SAMODE %s %s", argv[1], argv_eol[2]); + if (argc > 1) + { + if ((argv[1][0] == '+') || (argv[1][0] == '-')) + { + /* channel not specified, check we are on channel and use it */ + if (!ptr_channel) + { + weechat_printf (ptr_server->buffer, + _("%s%s: you must specify channel for \"%s\" " + "command if you're not in a channel"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "samode"); + return WEECHAT_RC_OK; + } + irc_command_mode_server (ptr_server, "SAMODE", ptr_channel, + argv_eol[1], + IRC_SERVER_SEND_OUTQ_PRIO_HIGH); + } + else + { + /* user gives channel, use arguments as-is */ + irc_command_mode_server (ptr_server, "SAMODE", NULL, argv_eol[1], + IRC_SERVER_SEND_OUTQ_PRIO_HIGH); + } + } + else + { + if (ptr_channel) + { + irc_command_mode_server (ptr_server, "SAMODE", ptr_channel, NULL, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH); + } + else + { + weechat_printf (ptr_server->buffer, + _("%s%s: you must specify channel for \"%s\" " + "command if you're not in a channel"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "samode"); + return WEECHAT_RC_OK; + } + } return WEECHAT_RC_OK; } @@ -6354,7 +6396,7 @@ irc_command_init () weechat_hook_command ( "samode", N_("change mode on channel, without having operator status"), - N_("<channel> <mode>"), + N_("[<channel>] <mode>"), N_("channel: channel name\n" " mode: mode for channel"), "%(irc_server_channels)", &irc_command_samode, NULL); |