diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-06 23:03:02 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-06 23:03:02 +0100 |
commit | 70828a7dd146f8aad90193388566dce46fe928c3 (patch) | |
tree | 089364447932f1f253dfc0bc751f31500517f08a /src | |
parent | ab2e29fb0f73b1d607d2765ebebd2a34bfcfbc65 (diff) | |
download | weechat-70828a7dd146f8aad90193388566dce46fe928c3.zip |
irc: add option `-all` in command `/allchan`, do not execute command on parted channels by default (closes #2085)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-command.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 5a4747fcc..05f5a90fd 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -623,6 +623,7 @@ irc_command_exec_buffers (struct t_weelist *list_buffers, void irc_command_exec_all_channels (struct t_irc_server *server, int channel_type, + int all_channels, int parted_channels, int inclusive, const char *str_channels, @@ -663,7 +664,9 @@ irc_command_exec_all_channels (struct t_irc_server *server, parted = ((ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) && !ptr_channel->nicks) ? 1 : 0; - state_ok = (!parted_channels || parted); + state_ok = (all_channels + || (parted_channels && parted) + || (!parted_channels && !parted)); if ((ptr_channel->type == channel_type) && state_ok) { @@ -716,7 +719,7 @@ irc_command_exec_all_channels (struct t_irc_server *server, IRC_COMMAND_CALLBACK(allchan) { - int i, current_server, parted_channels, inclusive; + int i, current_server, all_channels, parted_channels, inclusive; const char *ptr_channels, *ptr_command; IRC_BUFFER_GET_SERVER(buffer); @@ -728,6 +731,7 @@ IRC_COMMAND_CALLBACK(allchan) WEECHAT_COMMAND_MIN_ARGS(2, ""); current_server = 0; + all_channels = 0; parted_channels = 0; ptr_channels = NULL; inclusive = 0; @@ -749,9 +753,16 @@ IRC_COMMAND_CALLBACK(allchan) current_server = 1; ptr_command = argv_eol[i + 1]; } + else if (weechat_strcmp (argv[i], "-all") == 0) + { + all_channels = 1; + parted_channels = 0; + ptr_command = argv_eol[i + 1]; + } else if (weechat_strcmp (argv[i], "-parted") == 0) { parted_channels = 1; + all_channels = 0; ptr_command = argv_eol[i + 1]; } else if (weechat_strncmp (argv[i], "-exclude=", 9) == 0) @@ -775,6 +786,7 @@ IRC_COMMAND_CALLBACK(allchan) weechat_buffer_set (NULL, "hotlist", "-"); irc_command_exec_all_channels ((current_server) ? ptr_server : NULL, IRC_CHANNEL_TYPE_CHANNEL, + all_channels, parted_channels, inclusive, ptr_channels, @@ -845,6 +857,7 @@ IRC_COMMAND_CALLBACK(allpv) weechat_buffer_set (NULL, "hotlist", "-"); irc_command_exec_all_channels ((current_server) ? ptr_server : NULL, IRC_CHANNEL_TYPE_PRIVATE, + 1, /* all channels */ 0, /* parted channels */ inclusive, ptr_channels, @@ -6894,11 +6907,13 @@ irc_command_init () "allchan", N_("execute a command on all channels of all connected servers"), /* TRANSLATORS: only text between angle brackets (eg: "<name>") must be translated */ - N_("[-current] [-parted] [-exclude=<channel>[,<channel>...]] <command>" - " || [-current] [-parted] -include=<channel>[,<channel>...] <command>"), + N_("[-current] [-parted|-all] [-exclude=<channel>[,<channel>...]] <command>" + " || [-current] [-parted|-all] -include=<channel>[,<channel>...] <command>"), WEECHAT_CMD_ARGS_DESC( N_("raw[-current]: execute command for channels of current server only"), - N_("raw[-parted]: execute on parted channels only"), + N_("raw[-parted]: execute command on parted channels " + "(by default: execute command on active channels only)"), + N_("raw[-all]: execute command on all channels (active and parted)"), N_("raw[-exclude]: exclude some channels (wildcard \"*\" is allowed)"), N_("raw[-include]: include only some channels (wildcard \"*\" is allowed)"), N_("command: command to execute (or text to send to buffer if " @@ -6924,7 +6939,7 @@ irc_command_init () N_(" /allchan -include=#linux* hello"), N_(" close all buffers with parted channels:"), AI(" /allchan -parted /close")), - "-current|-parted", &irc_command_allchan, NULL, NULL); + "-current|-parted|-all", &irc_command_allchan, NULL, NULL); weechat_hook_command ( "allpv", N_("execute a command on all private buffers of all connected servers"), |