diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-03-25 08:38:42 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-03-25 08:38:42 +0200 |
commit | 126a8259248e477e3c9d8affd0f22b3197b790ee (patch) | |
tree | 0971dbe1fb1b92f19e0602d0bbdefd82f3dafa37 /src | |
parent | 5793181ead97ca3de0e50c502bf0f74e873f3e7d (diff) | |
download | weechat-126a8259248e477e3c9d8affd0f22b3197b790ee.zip |
irc: add completion with modelist numbers for commands /unban and /unquiet
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-command.c | 16 | ||||
-rw-r--r-- | src/plugins/irc/irc-completion.c | 62 |
2 files changed, 65 insertions, 13 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index aa0331828..65c48fd17 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -6975,17 +6975,21 @@ irc_command_init () weechat_hook_command ( "unban", N_("unban nicks or hosts"), - N_("[<channel>] <nick> [<nick>...]"), + N_("[<channel>] <nick>|<number> [<nick>|<number>...]"), N_("channel: channel name\n" - " nick: nick, host or ban number"), - "%(irc_modelist:b)", &irc_command_unban, NULL, NULL); + " nick: nick or host\n" + " number: ban number (as displayed in output of /ban)"), + "%(irc_modelist_masks:b)|%(irc_modelist_numbers:b)", + &irc_command_unban, NULL, NULL); weechat_hook_command ( "unquiet", N_("unquiet nicks or hosts"), - N_("[<channel>] <nick> [<nick>...]"), + N_("[<channel>] <nick>|<number> [<nick>|<number>...]"), N_("channel: channel name\n" - " nick: nick, host or quiet number"), - "%(irc_modelist:q)", &irc_command_unquiet, NULL, NULL); + " nick: nick or host\n" + " number: quiet number (as displayed in output of /quiet)"), + "%(irc_modelist_masks:q)|%(irc_modelist_numbers:q)", + &irc_command_unquiet, NULL, NULL); weechat_hook_command ( "userhost", N_("return a list of information about nicks"), diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index b0e0c2dd1..4e72a8570 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -422,14 +422,14 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data, } /* - * Adds modelist masks current channel to completion list. + * Adds modelist masks of current channel to completion list. */ int -irc_completion_modelist_cb (const void *pointer, void *data, - const char *completion_item, - struct t_gui_buffer *buffer, - struct t_gui_completion *completion) +irc_completion_modelist_masks_cb (const void *pointer, void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { char *pos; struct t_irc_modelist *ptr_modelist; @@ -464,6 +464,50 @@ irc_completion_modelist_cb (const void *pointer, void *data, } /* + * Adds modelist numbers of current channel to completion list. + */ + +int +irc_completion_modelist_numbers_cb (const void *pointer, void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + char *pos, str_number[32]; + struct t_irc_modelist *ptr_modelist; + struct t_irc_modelist_item *ptr_item; + + IRC_BUFFER_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) pointer; + (void) data; + + pos = strchr (completion_item, ':'); + if (pos) + pos++; + + if (pos && pos[0] && ptr_channel) + { + ptr_modelist = irc_modelist_search (ptr_channel, pos[0]); + if (ptr_modelist) + { + for (ptr_item = ptr_modelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + snprintf (str_number, sizeof (str_number), + "%d", ptr_item->number + 1); + weechat_hook_completion_list_add (completion, + str_number, + 0, WEECHAT_LIST_POS_END); + } + } + } + + return WEECHAT_RC_OK; +} + +/* * Adds topic of current channel to completion list. */ @@ -801,10 +845,14 @@ irc_completion_init () weechat_hook_completion ("irc_channel_nicks_hosts", N_("nicks and hostnames of current IRC channel"), &irc_completion_channel_nicks_hosts_cb, NULL, NULL); - weechat_hook_completion ("irc_modelist", + weechat_hook_completion ("irc_modelist_masks", N_("modelist masks of current IRC channel; " "required argument: modelist mode"), - &irc_completion_modelist_cb, NULL, NULL); + &irc_completion_modelist_masks_cb, NULL, NULL); + weechat_hook_completion ("irc_modelist_numbers", + N_("modelist numbers of current IRC channel; " + "required argument: modelist mode"), + &irc_completion_modelist_numbers_cb, NULL, NULL); weechat_hook_completion ("irc_channel_topic", N_("topic of current IRC channel"), &irc_completion_channel_topic_cb, NULL, NULL); |