Send notifications for actions (`/me`)
authorKyle Fuller <redacted>
Sat, 2 Jul 2016 10:59:29 +0000 (11:59 +0100)
committerKyle Fuller <redacted>
Sat, 2 Jul 2016 10:59:29 +0000 (11:59 +0100)
palaver.cpp

index 67326d6a19078fd4cfb3c514d0d576bba0d31acc..04a169c13f81fec9a55ab32cb6cfc9f632277879 100644 (file)
@@ -652,7 +652,7 @@ public:
 
 #pragma mark - Notifications
 
-       void SendNotification(CModule& module, const CString& sSender, const CString& sNotification, const CChan *pChannel) {
+       void SendNotification(CModule& module, const CString& sSender, const CString& sNotification, const CChan *pChannel, CString sIntent = "") {
                ++m_uiBadge;
 
                MCString mcsHeaders;
@@ -671,6 +671,9 @@ public:
                        const CString sNetworkID = GetNetworkID(*module.GetNetwork());
                        sJSON += ",\"network\": \"" + sNetworkID.Replace_n("\"", "\\\"") + "\"";
                }
+               if (!sIntent.empty()) {
+                       sJSON += ",\"intent\": \"" + sIntent + "\"";
+               }
                sJSON += "}";
 
                PLVHTTPSocket *pSocket = new PLVHTTPSocket(&module, "POST", GetPushEndpoint(), mcsHeaders, sJSON);
@@ -989,7 +992,7 @@ public:
 
 #pragma mark -
 
-       void ParseMessage(CNick& Nick, CString& sMessage, CChan *pChannel = NULL) {
+       void ParseMessage(CNick& Nick, CString& sMessage, CChan *pChannel = NULL, CString sIntent = "") {
                if (m_pNetwork->IsUserOnline() == false) {
 #if defined VERSION_MAJOR && defined VERSION_MINOR && VERSION_MAJOR >= 1 && VERSION_MINOR >= 2
                        CString sCleanMessage = sMessage.StripControls_n();
@@ -1017,7 +1020,7 @@ public:
                                        }
 
                                        if (bMention) {
-                                               device.SendNotification(*this, Nick.GetNick(), sCleanMessage, pChannel);
+                                               device.SendNotification(*this, Nick.GetNick(), sCleanMessage, pChannel, sIntent);
                                        }
                                }
                        }
@@ -1029,6 +1032,11 @@ public:
                return CONTINUE;
        }
 
+       virtual EModRet OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage) {
+               ParseMessage(Nick, sMessage, &Channel, "ACTION");
+               return CONTINUE;
+       }
+
        virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) {
                ParseMessage(Nick, sMessage, NULL);
                return CONTINUE;
@@ -1044,6 +1052,11 @@ public:
                return CONTINUE;
        }
 
+       virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage) {
+               ParseMessage(Nick, sMessage, NULL, "ACTION");
+               return CONTINUE;
+       }
+
 #pragma mark - Commands
 
        void HandleTestCommand(const CString& sLine) {
git clone https://git.99rst.org/PROJECT