mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 03:03:12 +02:00
irc: add command /cap (closes #8)
This commit is contained in:
@@ -1071,6 +1071,48 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for command "/cap": client capability negotiation.
|
||||
*
|
||||
* Docs on capability negotiation:
|
||||
* https://tools.ietf.org/html/draft-mitchell-irc-capabilities-01
|
||||
* http://ircv3.net/specs/core/capability-negotiation-3.1.html
|
||||
* http://ircv3.net/specs/core/capability-negotiation-3.2.html
|
||||
*/
|
||||
|
||||
int
|
||||
irc_command_cap (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
IRC_COMMAND_CHECK_SERVER("cap", 1);
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"CAP %s%s%s",
|
||||
argv[1],
|
||||
(argv_eol[2]) ? " :" : "",
|
||||
(argv_eol[2]) ? argv_eol[2] : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* by default, show supported capabilities and capabilities currently
|
||||
* enabled
|
||||
*/
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"CAP LS");
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"CAP LIST");
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connects to one server.
|
||||
*
|
||||
@@ -6091,6 +6133,40 @@ irc_command_init ()
|
||||
"\n"
|
||||
"Without argument, this command display ban list for current channel."),
|
||||
"%(irc_channel_nicks_hosts)", &irc_command_ban, NULL);
|
||||
weechat_hook_command (
|
||||
"cap",
|
||||
N_("client capability negotiation"),
|
||||
N_("ls || list || req|ack [<capability> [<capability>...]]"
|
||||
" || clear || end"),
|
||||
N_(" ls: list the capabilities supported by the server\n"
|
||||
" list: list the capabilities currently enabled\n"
|
||||
" req: request a capability\n"
|
||||
" ack: acknowledge capabilities which require client-side "
|
||||
"acknowledgement\n"
|
||||
"clear: clear the capabilities currently enabled\n"
|
||||
" end: end the capability negotiation\n"
|
||||
"\n"
|
||||
"Without argument, \"ls\" and \"list\" are sent.\n"
|
||||
"\n"
|
||||
"Capabilities supported by WeeChat are: "
|
||||
"account-notify, away-notify, extended-join, "
|
||||
"multi-prefix, server-time, userhost-in-names.\n"
|
||||
"\n"
|
||||
"The capabilities to automatically enable on servers can be set "
|
||||
"in option irc.server_default.capabilities (or by server in "
|
||||
"option irc.server.xxx.capabilities).\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" /cap\n"
|
||||
" /cap req multi-prefix\n"
|
||||
" /cap clear"),
|
||||
"ls"
|
||||
" || list"
|
||||
" || req " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
|
||||
" || ack " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
|
||||
" || clear"
|
||||
" || end",
|
||||
&irc_command_cap, NULL);
|
||||
weechat_hook_command (
|
||||
"connect",
|
||||
N_("connect to IRC server(s)"),
|
||||
|
||||
@@ -43,6 +43,12 @@ struct t_irc_channel;
|
||||
return WEECHAT_RC_OK; \
|
||||
}
|
||||
|
||||
/* list of supported capabilities (for completion in command /cap) */
|
||||
#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
|
||||
"account-notify|away-notify|extended-join|" \
|
||||
"multi-prefix|server-time|userhost-in-names" \
|
||||
"|%*"
|
||||
|
||||
extern void irc_command_away_server (struct t_irc_server *server,
|
||||
const char *arguments,
|
||||
int reset_unread_marker);
|
||||
|
||||
@@ -1731,10 +1731,9 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
option_name, "string",
|
||||
/* TRANSLATORS: please keep words "client capabilities" between brackets if translation is different (see fr.po) */
|
||||
N_("comma-separated list of client capabilities to enable for "
|
||||
"server if they are available; capabilities supported by "
|
||||
"WeeChat are: account-notify, away-notify, extended-join, "
|
||||
"multi-prefix, server-time, userhost-in-names (example: "
|
||||
"\"away-notify,multi-prefix\")"),
|
||||
"server if they are available (see /help cap for a list of "
|
||||
"capabilities supported by WeeChat) "
|
||||
"(example: \"away-notify,multi-prefix\")"),
|
||||
NULL, 0, 0,
|
||||
default_value, value,
|
||||
null_value_allowed,
|
||||
|
||||
Reference in New Issue
Block a user