summaryrefslogtreecommitdiff
path: root/protocols/Discord
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-11-28 17:34:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-11-28 17:34:51 +0300
commit1a5dc583b048727752b8f72df676ec408908041f (patch)
tree5204a5dbcbe84ed7cff02bff9e6ee32ff8598c3f /protocols/Discord
parent4f961df4a3bb6577a0024e341adb9fed6d965edf (diff)
user typing notification for Discord group chats
Diffstat (limited to 'protocols/Discord')
-rw-r--r--protocols/Discord/src/dispatch.cpp28
-rw-r--r--protocols/Discord/src/groupchat.cpp4
2 files changed, 23 insertions, 9 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index fee35b6c06..45fba1fb94 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -532,22 +532,32 @@ void CDiscordProto::OnCommandReady(const JSONNode &pRoot)
void CDiscordProto::OnCommandTyping(const JSONNode &pRoot)
{
- SnowFlake userId = ::getId(pRoot["user_id"]);
SnowFlake channelId = ::getId(pRoot["channel_id"]);
- debugLogA("user typing notification: userid=%lld, channelid=%lld", userId, channelId);
+ debugLogA("user typing notification: channelid=%lld", channelId);
- CDiscordUser *pUser = FindUser(userId);
- if (pUser == nullptr) {
- debugLogA("user with id=%lld is not found", userId);
+ CDiscordUser *pChannel = FindUserByChannel(channelId);
+ if (pChannel == nullptr) {
+ debugLogA("channel with id=%lld is not found", channelId);
return;
}
- if (pUser->channelId == channelId) {
- debugLogA("user is typing in his private channel");
- CallService(MS_PROTO_CONTACTISTYPING, pUser->hContact, 20);
+ // both private groupchats & guild channels are chat rooms for Miranda
+ if (pChannel->pGuild) {
+ debugLogA("user is typing in a group channel");
+
+ CMStringW wszUerId = pRoot["user_id"].as_mstring();
+ ProcessGuildUser(pChannel->pGuild, pRoot); // never returns null
+
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TYPING };
+ gce.pszID.w = pChannel->wszUsername;
+ gce.pszUID.w = wszUerId;
+ gce.dwItemData = 1;
+ gce.time = time(0);
+ Chat_Event(&gce);
}
else {
- debugLogA("user is typing in a group channel, skipped");
+ debugLogA("user is typing in his private channel");
+ CallService(MS_PROTO_CONTACTISTYPING, pChannel->hContact, 20);
}
}
diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp
index 8c68d1276f..4e4c69e949 100644
--- a/protocols/Discord/src/groupchat.cpp
+++ b/protocols/Discord/src/groupchat.cpp
@@ -225,6 +225,10 @@ int CDiscordProto::GroupchatEventHook(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
Chat_ProcessNickMenu(gch);
break;
+
+ case GC_USER_TYPNOTIFY:
+ UserIsTyping(gch->si->hContact, (int)gch->dwData);
+ break;
}
return 1;