From: Shane Synan Date: Tue, 21 Jul 2020 02:12:30 +0000 (-0400) Subject: core: Implement invite-notify X-Git-Tag: 0.14-rc1~16 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e14649614fbbf9b386505a5d782b88b1ac313c1f core: Implement invite-notify Implement the "invite-notify" capability, making use of Quassel's existing "invite" handling to display an invite message. Update the Invite stringification to distinguish between an invite targeting the current user vs. targeting some other nickname. In the future, Quassel should make some sort of fancy invite notification interface. This still provides a benefit through standardization of existing notices. See https://ircv3.net/specs/extensions/invite-notify-3.2 --- diff --git a/src/common/irccap.h b/src/common/irccap.h index 0bcb66d2..9fb40e1f 100644 --- a/src/common/irccap.h +++ b/src/common/irccap.h @@ -86,6 +86,13 @@ namespace IrcCap { */ const QString EXTENDED_JOIN = "extended-join"; + /** + * Standardized invite notifications. + * + * https://ircv3.net/specs/extensions/invite-notify-3.2 + */ + const QString INVITE_NOTIFY = "invite-notify"; + /** * Additional metadata on a per-message basis * @@ -167,6 +174,7 @@ namespace IrcCap { CAP_NOTIFY, CHGHOST, EXTENDED_JOIN, + INVITE_NOTIFY, MESSAGE_TAGS, MULTI_PREFIX, SASL, diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index 6142fa86..220e6b12 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -361,6 +361,10 @@ void CoreSessionEventProcessor::processIrcEventChghost(IrcEvent* e) } } +// IRCv3 INVITE - ": INVITE " +// Example: :ChanServ!ChanServ@example.com INVITE Attila #channel +// +// See https://ircv3.net/specs/extensions/invite-notify-3.2 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent* e) { if (checkParamCount(e, 2)) { diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index 52f03be7..740310da 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -251,7 +251,18 @@ void EventStringifier::processIrcEventNumeric(IrcEventNumeric* e) void EventStringifier::processIrcEventInvite(IrcEvent* e) { - displayMsg(e, Message::Invite, tr("%1 invited you to channel %2").arg(e->nick(), e->params().at(1))); + if (!checkParamCount(e, 2)) + return; + + // TODO: provide a nicer UI for invite notifications + QString target = e->params().at(0); + QString channel = e->params().at(1); + if (e->network()->isMyNick(target)) { + displayMsg(e, Message::Invite, tr("%1 invited you to channel %2").arg(e->nick(), channel)); + } + else { + displayMsg(e, Message::Invite, tr("%1 invited %2 to channel %3").arg(e->nick(), target, channel)); + } } void EventStringifier::processIrcEventJoin(IrcEvent* e)