summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-23 19:07:27 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-23 19:07:27 +0300
commitffc1007914c3ffdc4cf322828907f35dd4101773 (patch)
treec08aad656e11561403be6ddb1568da27e8e7c015 /protocols
parent35c6f6ccbb11f24a1385c5296a0f2b32c0b90dc9 (diff)
Discord: now we can write messages into guild chats
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/src/groupchat.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp
index 1285a40245..607d6152c6 100644
--- a/protocols/Discord/src/groupchat.cpp
+++ b/protocols/Discord/src/groupchat.cpp
@@ -17,8 +17,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-int CDiscordProto::GroupchatEventHook(WPARAM, LPARAM)
+int CDiscordProto::GroupchatEventHook(WPARAM, LPARAM lParam)
{
+ GCHOOK *gch = (GCHOOK*)lParam;
+ if (gch == NULL)
+ return 0;
+
+ if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName))
+ return 0;
+
+ CDiscordUser *pUser = FindUserByChannel(_wtoi64(gch->pDest->ptszID));
+ if (pUser == NULL)
+ return 0;
+
+ switch (gch->pDest->iType) {
+ case GC_USER_MESSAGE:
+ if (gch->ptszText && mir_wstrlen(gch->ptszText) > 0) {
+ rtrimw(gch->ptszText);
+
+ if (m_bOnline) {
+ wchar_t *wszText = NEWWSTR_ALLOCA(gch->ptszText);
+ Chat_UnescapeTags(wszText);
+
+ JSONNode body; body << WCHAR_PARAM("content", wszText);
+ CMStringA szUrl(FORMAT, "/channels/%lld/messages", pUser->channelId);
+ Push(new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveMessage, &body));
+ }
+ }
+ break;
+
+ case GC_USER_PRIVMESS:
+ case GC_USER_LOGMENU:
+ case GC_USER_NICKLISTMENU:
+ break;
+ }
+
return 0;
}