diff options
| author | George Hazan <george.hazan@gmail.com> | 2024-05-03 20:19:06 +0300 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2024-05-03 20:19:06 +0300 | 
| commit | fc06fc0a10dba14724cd278f8356520e4e71080e (patch) | |
| tree | cea6b0c54a3c2b181388cf553c5c65b80b951d99 /protocols/Discord | |
| parent | 9f3a948b5f6d983b06e272ca7db2dbdbaf652a83 (diff) | |
fixes #4396 (Discord: добавление и удаление нового участника в чат отражается лишь после переподключения)
Diffstat (limited to 'protocols/Discord')
| -rw-r--r-- | protocols/Discord/src/dispatch.cpp | 33 | ||||
| -rw-r--r-- | protocols/Discord/src/proto.h | 2 | 
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);
 | 
