core: Implement invite-notify
authorShane Synan <digitalcircuit36939@gmail.com>
Tue, 21 Jul 2020 02:12:30 +0000 (22:12 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 28 Nov 2020 12:42:31 +0000 (13:42 +0100)
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

src/common/irccap.h
src/core/coresessioneventprocessor.cpp
src/core/eventstringifier.cpp

index 0bcb66d..9fb40e1 100644 (file)
@@ -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,
index 6142fa8..220e6b1 100644 (file)
@@ -361,6 +361,10 @@ void CoreSessionEventProcessor::processIrcEventChghost(IrcEvent* e)
     }
 }
 
+// IRCv3 INVITE - ":<inviter> INVITE <target> <channel>"
+// 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)) {
index 52f03be..740310d 100644 (file)
@@ -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)