diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-command.c | 72 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 2 |
3 files changed, 59 insertions, 16 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); diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index bb5c5342a..6ea8c2f08 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -51,6 +51,7 @@ extern void irc_command_join_server (struct t_irc_server *server, int manual_join, int noswitch); extern void irc_command_mode_server (struct t_irc_server *server, + const char *command, struct t_irc_channel *channel, const char *arguments, int flags); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 3f4037319..707a4fb20 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -4419,7 +4419,7 @@ IRC_PROTOCOL_CALLBACK(366) if (!weechat_hashtable_has_key (ptr_channel->join_msg_received, command)) { - irc_command_mode_server (server, ptr_channel, NULL, + irc_command_mode_server (server, "MODE", ptr_channel, NULL, IRC_SERVER_SEND_OUTQ_PRIO_LOW); irc_channel_check_away (server, ptr_channel); } |