mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
irc: add completion with modelist numbers for commands /unban and /unquiet
This commit is contained in:
@@ -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"),
|
||||
|
||||
@@ -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;
|
||||
@@ -463,6 +463,50 @@ irc_completion_modelist_cb (const void *pointer, void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
Reference in New Issue
Block a user