From: Kyle Fuller Date: Sat, 2 Jul 2016 10:59:29 +0000 (+0100) Subject: Send notifications for actions (`/me`) X-Git-Tag: 1.1.0~9^2 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=8bcbc7ee0f672082e992c38f14c158f1d783f123;p=znc-palaver.git Send notifications for actions (`/me`) --- diff --git a/palaver.cpp b/palaver.cpp index 67326d6..04a169c 100644 --- a/palaver.cpp +++ b/palaver.cpp @@ -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) {