summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-03-19 19:13:41 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-03-19 19:13:41 +0100
commit63b474013ef683dad09fa64c2a701031d34300ca (patch)
tree5a19aaa1f1fbf6e757f31f9f3d27e4c4c2d77456 /src
parent9b380a935b9fe07daf7e1e1f0ad12a41519bb10c (diff)
downloadweechat-63b474013ef683dad09fa64c2a701031d34300ca.zip
irc: add command /allpv (task #13111)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-command.c82
1 files changed, 80 insertions, 2 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index ff3569459..22807ebee 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -268,7 +268,7 @@ irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
}
/*
- * Executes a command on all channels.
+ * Executes a command on all channels (or queries).
*
* If server is NULL, executes command on all channels of all connected servers.
* Special variables $server/$channel/$nick are replaced in command.
@@ -276,6 +276,7 @@ irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
void
irc_command_exec_all_channels (struct t_irc_server *server,
+ int channel_type,
const char *exclude_channels,
const char *command)
{
@@ -316,7 +317,7 @@ irc_command_exec_all_channels (struct t_irc_server *server,
{
next_channel = ptr_channel->next_channel;
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ if (ptr_channel->type == channel_type)
{
excluded = 0;
if (channels)
@@ -399,6 +400,59 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_buffer_set (NULL, "hotlist", "-");
irc_command_exec_all_channels ((current_server) ? ptr_server : NULL,
+ IRC_CHANNEL_TYPE_CHANNEL,
+ ptr_exclude_channels,
+ ptr_command);
+ weechat_buffer_set (NULL, "hotlist", "+");
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * Callback for command "/allpv": executes a command on all privates of all
+ * connected servers.
+ */
+
+int
+irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ int i, current_server;
+ const char *ptr_exclude_channels, *ptr_command;
+
+ IRC_BUFFER_GET_SERVER(buffer);
+
+ /* make C compiler happy */
+ (void) data;
+
+ if (argc < 2)
+ return WEECHAT_RC_ERROR;
+
+ current_server = 0;
+ ptr_exclude_channels = NULL;
+ ptr_command = argv_eol[1];
+ for (i = 1; i < argc; i++)
+ {
+ if (weechat_strcasecmp (argv[i], "-current") == 0)
+ {
+ current_server = 1;
+ ptr_command = argv_eol[i + 1];
+ }
+ else if (weechat_strncasecmp (argv[i], "-exclude=", 9) == 0)
+ {
+ ptr_exclude_channels = argv[i] + 9;
+ ptr_command = argv_eol[i + 1];
+ }
+ else
+ break;
+ }
+
+ if (ptr_command && ptr_command[0])
+ {
+ weechat_buffer_set (NULL, "hotlist", "-");
+ irc_command_exec_all_channels ((current_server) ? ptr_server : NULL,
+ IRC_CHANNEL_TYPE_PRIVATE,
ptr_exclude_channels,
ptr_command);
weechat_buffer_set (NULL, "hotlist", "+");
@@ -5621,6 +5675,30 @@ irc_command_init ()
" /allchan -exclude=#weechat,#linux* msg * hello"),
NULL, &irc_command_allchan, NULL);
weechat_hook_command (
+ "allpv",
+ N_("execute a command on all private buffers of all connected servers"),
+ N_("[-current] [-exclude=<nick>[,<nick>...]] <command> "
+ "[<arguments>]"),
+ N_(" -current: execute command for private buffers of current server "
+ "only\n"
+ " -exclude: exclude some nicks ('*' is allowed at beginning or "
+ "end of nick name, to exclude many nicks)\n"
+ " command: command to execute\n"
+ "arguments: arguments for command (special variables $nick, $channel "
+ "and $server are replaced by their value)\n"
+ "\n"
+ "Examples:\n"
+ " execute '/me is testing' on all private buffers:\n"
+ " /allpv me is testing\n"
+ " say 'hello' everywhere but not for nick foo:\n"
+ " /allpv -exclude=foo msg * hello\n"
+ " say 'hello' everywhere but not for nick foo and nicks beginning "
+ "with bar:\n"
+ " /allpv -exclude=foo,bar* msg * hello\n"
+ " close all private buffers:\n"
+ " /allpv close"),
+ NULL, &irc_command_allpv, NULL);
+ weechat_hook_command (
"allserv",
N_("execute a command on all connected servers"),
N_("[-exclude=<server>[,<server>...]] "