diff options
author | George Hazan <ghazan@miranda.im> | 2017-02-08 21:59:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-02-08 21:59:17 +0300 |
commit | 19535676169fea739dec9b582ad1470c768faae9 (patch) | |
tree | 59dc056ee5a5aeb5da330ada4b58ee9714aa9c22 /protocols/Discord/src/dispatch.cpp | |
parent | 5b00b966c446a17b23e5ca38504c829e064e08b8 (diff) |
Discord: support for changing nick names in chats
Diffstat (limited to 'protocols/Discord/src/dispatch.cpp')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index fe581e61b9..e28f6f70d2 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -34,6 +34,7 @@ static handlers[] = // these structures must me sorted alphabetically { L"GUILD_CREATE", &CDiscordProto::OnCommandGuildCreate }, { L"GUILD_DELETE", &CDiscordProto::OnCommandGuildDelete }, { L"GUILD_MEMBER_REMOVE", &CDiscordProto::OnCommandGuildRemoveMember }, + { L"GUILD_MEMBER_UPDATE", &CDiscordProto::OnCommandGuildUpdateMember }, { L"GUILD_SYNC", &CDiscordProto::OnCommandGuildSync }, { L"MESSAGE_ACK", &CDiscordProto::OnCommandMessageAck }, @@ -260,6 +261,34 @@ void CDiscordProto::OnCommandGuildRemoveMember(const JSONNode &pRoot) } } +void CDiscordProto::OnCommandGuildUpdateMember(const JSONNode &pRoot) +{ + SnowFlake guildId = ::getId(pRoot["guild_id"]); + CMStringW wszUserId = pRoot["user"]["id"].as_mstring(); + CMStringW wszUserNick = pRoot["nick"].as_mstring(), wszOldNick; + + for (int i = 0; i < arUsers.getCount(); i++) { + CDiscordUser &pUser = arUsers[i]; + if (pUser.guildId != guildId) + continue; + + SESSION_INFO *si = pci->SM_FindSession(pUser.wszUsername, m_szModuleName); + if (si != nullptr) { + USERINFO *ui = pci->UM_FindUser(si->pUsers, wszUserId); + if (ui != nullptr) + wszOldNick = ui->pszNick; + } + + GCDEST gcd = { m_szModuleName, pUser.wszUsername, GC_EVENT_NICK }; + GCEVENT gce = { &gcd }; + gce.ptszUID = wszUserId; + gce.ptszNick = wszOldNick; + gce.ptszText = wszUserNick; + Chat_Event(&gce); + } +} + + ///////////////////////////////////////////////////////////////////////////////////////// // reading a new message |