summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Discord/src/dispatch.cpp33
-rw-r--r--protocols/Discord/src/proto.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index 995efac43a..604d82a01b 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -34,6 +34,8 @@ static handlers[] = // these structures must me sorted alphabetically
{ L"CHANNEL_CREATE", &CDiscordProto::OnCommandChannelCreated },
{ L"CHANNEL_DELETE", &CDiscordProto::OnCommandChannelDeleted },
+ { L"CHANNEL_RECIPIENT_ADD", &CDiscordProto::OnCommandChannelUserAdded },
+ { L"CHANNEL_RECIPIENT_REMOVE", &CDiscordProto::OnCommandChannelUserLeft },
{ L"CHANNEL_UPDATE", &CDiscordProto::OnCommandChannelUpdated },
{ L"GUILD_CREATE", &CDiscordProto::OnCommandGuildCreated },
@@ -115,6 +117,37 @@ void CDiscordProto::OnCommandChannelDeleted(const JSONNode &pRoot)
}
}
+void CDiscordProto::OnCommandChannelUserAdded(const JSONNode &pRoot)
+{
+ CDiscordUser *pUser = FindUserByChannel(::getId(pRoot["channel_id"]));
+ if (pUser == nullptr || pUser->si == nullptr)
+ return;
+
+ auto nUser = pRoot["user"];
+ CMStringW wszUserId = nUser["id"].as_mstring();
+ CMStringW wszNick = getNick(nUser);
+
+ GCEVENT gce = { pUser->si, GC_EVENT_JOIN };
+ gce.pszUID.w = wszUserId;
+ gce.pszNick.w = wszNick;
+ gce.time = time(0);
+ Chat_Event(&gce);
+}
+
+void CDiscordProto::OnCommandChannelUserLeft(const JSONNode &pRoot)
+{
+ CDiscordUser *pUser = FindUserByChannel(::getId(pRoot["channel_id"]));
+ if (pUser == nullptr || pUser->si == nullptr)
+ return;
+
+ CMStringW wszUserId = pRoot["user"]["id"].as_mstring();
+
+ GCEVENT gce = { pUser->si, GC_EVENT_PART };
+ gce.pszUID.w = wszUserId;
+ gce.time = time(0);
+ Chat_Event(&gce);
+}
+
void CDiscordProto::OnCommandChannelUpdated(const JSONNode &pRoot)
{
CDiscordUser *pUser = FindUserByChannel(::getId(pRoot["id"]));
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 38bf253ae1..0392907394 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -481,6 +481,8 @@ public:
void OnCommandChannelCreated(const JSONNode &json);
void OnCommandChannelDeleted(const JSONNode &json);
void OnCommandChannelUpdated(const JSONNode &json);
+ void OnCommandChannelUserAdded(const JSONNode &json);
+ void OnCommandChannelUserLeft(const JSONNode &json);
void OnCommandGuildCreated(const JSONNode &json);
void OnCommandGuildDeleted(const JSONNode &json);
void OnCommandGuildMemberAdded(const JSONNode &json);