summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-command.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-10-19 12:28:48 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-10-19 12:28:48 +0200
commit08ebcc877f0cf3b18d136029b34b435cef3ae280 (patch)
tree253bcaf611c2a120a87aad661a058251f631342d /src/plugins/irc/irc-command.c
parent7075849ac325dcb4cc5f09521296465ba8df1da7 (diff)
downloadweechat-08ebcc877f0cf3b18d136029b34b435cef3ae280.zip
Improve mask used by command /kickban
Diffstat (limited to 'src/plugins/irc/irc-command.c')
-rw-r--r--src/plugins/irc/irc-command.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 2cfc761bc..363a127b7 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1636,7 +1636,8 @@ int
irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
- char *pos_channel, *pos_nick, *nick_only, *pos_comment, *pos;
+ char *pos_channel, *pos_nick, *nick_only, *pos_comment, *pos, *mask;
+ int length;
IRC_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("kickban", 1);
@@ -1679,10 +1680,6 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_OK;
}
}
-
- /* set ban for nick(+host) on channel */
- irc_server_sendf (ptr_server, 0, "MODE %s +b %s",
- pos_channel, pos_nick);
/* kick nick from channel */
nick_only = strdup (pos_nick);
@@ -1694,6 +1691,37 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
pos = strchr (nick_only, '!');
if (pos)
pos[0] = '\0';
+
+ if (strcmp (nick_only, "*") == 0)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%s%s: mask must begin with nick"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ return WEECHAT_RC_OK;
+ }
+
+ /* set ban for nick(+host) on channel */
+ if (strchr (pos_nick, '@'))
+ {
+ length = strlen (pos_nick) + 16;
+ mask = malloc (length + 1);
+ if (mask)
+ {
+ pos = strchr (pos_nick, '!');
+ snprintf (mask, length, "*!%s",
+ (pos) ? pos + 1 : pos_nick);
+ irc_server_sendf (ptr_server, 0, "MODE %s +b %s",
+ pos_channel, mask);
+ free (mask);
+ }
+ }
+ else
+ {
+ irc_server_sendf (ptr_server, 0, "MODE %s +b %s",
+ pos_channel, pos_nick);
+ }
+
+ /* kick nick */
irc_server_sendf (ptr_server, 0, "KICK %s %s%s%s",
pos_channel,
nick_only,
@@ -3971,7 +3999,13 @@ irc_command_init ()
N_("[channel] nickname [comment]"),
N_(" channel: channel where user is\n"
"nickname: nickname to kick and ban\n"
- " comment: comment for kick"),
+ " comment: comment for kick\n\n"
+ "It is possible to kick/ban with a mask, nick "
+ "will be extracted from mask and replaced by "
+ "\"*\", for example:\n"
+ " /kickban toto!*@host.com\n"
+ " will ban \"*!*@host.com\" and then kick "
+ "\"toto\"."),
"%(irc_channel_nicks_hosts) %-", &irc_command_kickban, NULL);
weechat_hook_command ("kill",
N_("close client-server connection"),