diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-08-24 10:02:38 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-08-24 10:02:38 +0200 |
commit | 350938181b1bfb5b8854a9e0ace387fa10afb73d (patch) | |
tree | 99bcd7ca41e47a4fdb65f7c4017aa51424ec14d4 /src/plugins | |
parent | f68896fdd396d5ee0c97430757411a37f5c597d3 (diff) | |
download | weechat-350938181b1bfb5b8854a9e0ace387fa10afb73d.zip |
irc: add command /cap (closes #8)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-command.c | 76 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.h | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 7 |
3 files changed, 85 insertions, 4 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 3edb5433a..a78970e6b 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1072,6 +1072,48 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, } /* + * 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. * * Returns: @@ -6092,6 +6134,40 @@ irc_command_init () "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)"), N_("<server> [<server>...] [-<option>[=<value>]] [-no<option>] " diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index acedfa926..358bc6385 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -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); diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 6828834fe..fa879e4f8 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -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, |