From e3b1e2a24f8e2be58f88ffa86e9d0f6ba32bf5cb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 May 2024 16:39:53 +0300 Subject: fixes #4399 completely --- protocols/Discord/src/dispatch.cpp | 17 +++++++++++------ protocols/Discord/src/groupchat.cpp | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 3691836d98..01e976be2b 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -473,8 +473,11 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) } else { CMStringW wszText = PrepareMessageText(pRoot), wszMentioned; + SnowFlake mentionId = 0; + for (auto &it : pRoot["mentions"]) { wszMentioned = getName(it); + mentionId = _wtoi64(it["id"].as_mstring()); break; } @@ -485,15 +488,17 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) return; case 1: // user was added to chat - wszText.Format(TranslateT("%s added %s to the group"), getName(pRoot["author"]).c_str(), wszMentioned.c_str()); + if (mentionId != userId) + wszText.Format(TranslateT("%s added %s to the group"), getName(pRoot["author"]).c_str(), wszMentioned.c_str()); + else + wszText.Format(TranslateT("%s joined the group"), wszMentioned.c_str()); break; case 2: // user was removed from chat - wszText.Format(TranslateT("%s removed %s from the group"), getName(pRoot["author"]).c_str(), wszMentioned.c_str()); - break; - - case 3: // user left chat - wszText.Format(TranslateT("%s left group"), wszMentioned.c_str()); + if (mentionId != userId) + wszText.Format(TranslateT("%s removed %s from the group"), getName(pRoot["author"]).c_str(), wszMentioned.c_str()); + else + wszText.Format(TranslateT("%s left the group"), wszMentioned.c_str()); break; } diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp index 81543fa174..b65bc0dffd 100644 --- a/protocols/Discord/src/groupchat.cpp +++ b/protocols/Discord/src/groupchat.cpp @@ -210,7 +210,7 @@ public: void CDiscordProto::LeaveChat(CDiscordUser *pChat) { - CMStringA szUrl(FORMAT, "/channels/%S", pChat->wszUsername.c_str()); + CMStringA szUrl(FORMAT, "/channels/%S?silent=false", pChat->wszUsername.c_str()); Push(new AsyncHttpRequest(this, REQUEST_DELETE, szUrl, nullptr)); } -- cgit v1.2.3