From 61bede8805730a66f98af53eb753ae1ca4fe7ff8 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 30 Dec 2015 16:57:44 +0200 Subject: [PATCH 1/2] irc: add support for IRCv3.2 invite-notify irc: add nick tag to numeric 341 for consistency --- src/plugins/irc/irc-protocol.c | 54 ++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 2aa4e10d7..f40f0f010 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -720,6 +720,11 @@ IRC_PROTOCOL_CALLBACK(generic_error) * * Message looks like: * :nick!user@host INVITE mynick :#channel + * + * With invite-notify capability + * (http://ircv3.net/specs/extensions/invite-notify-3.2.html): + * : INVITE + * :ChanServ!ChanServ@example.com INVITE Attila #channel */ IRC_PROTOCOL_CALLBACK(invite) @@ -730,18 +735,41 @@ IRC_PROTOCOL_CALLBACK(invite) if (ignored) return WEECHAT_RC_OK; - weechat_printf_date_tags ( - irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL), - date, - irc_protocol_tags (command, "notify_highlight", nick, address), - _("%sYou have been invited to %s%s%s by %s%s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - (argv[3][0] == ':') ? argv[3] + 1 : argv[3], - IRC_COLOR_RESET, - irc_nick_color_for_msg (server, 1, NULL, nick), - nick, - IRC_COLOR_RESET); + if (irc_server_strcasecmp (server, argv[2], server->nick) == 0) + { + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL), + date, + irc_protocol_tags (command, "notify_highlight", nick, address), + _("%sYou have been invited to %s%s%s by %s%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + (argv[3][0] == ':') ? argv[3] + 1 : argv[3], + IRC_COLOR_RESET, + irc_nick_color_for_msg (server, 1, NULL, nick), + nick, + IRC_COLOR_RESET); + } + else + { + /* CAP invite-notify */ + /* imitate numeric 341 output */ + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL), + date, + irc_protocol_tags (command, NULL, nick, address), + _("%s%s%s%s has invited %s%s%s to %s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_msg (server, 1, NULL, nick), + nick, + IRC_COLOR_RESET, + irc_nick_color_for_msg (server, 1, NULL, argv[2]), + argv[2], + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + (argv[3][0] == ':') ? argv[3] + 1 : argv[3], + IRC_COLOR_RESET); + } return WEECHAT_RC_OK; } @@ -3768,7 +3796,7 @@ IRC_PROTOCOL_CALLBACK(341) weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL), date, - irc_protocol_tags (command, "irc_numeric", NULL, address), + irc_protocol_tags (command, "irc_numeric", argv[2], address), _("%s%s%s%s has invited %s%s%s to %s%s%s"), weechat_prefix ("network"), irc_nick_color_for_msg (server, 1, NULL, argv[2]), From d4296a02c02661a0faa1923e449a4d728db8e252 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Sun, 5 Nov 2017 13:42:28 +0200 Subject: [PATCH 2/2] irc: add invite-notify capability to help and completion --- src/plugins/irc/irc-command.c | 2 +- src/plugins/irc/irc-command.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index bb76d7216..4ee939ab4 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -6161,7 +6161,7 @@ irc_command_init () "\n" "Capabilities supported by WeeChat are: " "account-notify, away-notify, cap-notify, extended-join, " - "multi-prefix, server-time, userhost-in-names.\n" + "invite-notify, 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 " diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index 236167ed8..86206d990 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -46,7 +46,7 @@ struct t_irc_channel; /* list of supported capabilities (for completion in command /cap) */ #define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \ "account-notify|away-notify|cap-notify|extended-join|" \ - "multi-prefix|server-time|userhost-in-names|%*" + "invite-notify|multi-prefix|server-time|userhost-in-names|%*" extern void irc_command_away_server (struct t_irc_server *server, const char *arguments,