From 4be3cbfb5a759d868eac6c8060967ebf0f0af456 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 Mar 2023 19:06:45 +0300 Subject: =?UTF-8?q?fixes=20#3394=20(Telegram:=20=D0=BD=D0=B5=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=BD=D0=B0=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D1=82=D1=8C=20=D0=B2=20=D0=BF=D1=80=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=20=D0=B8=D0=B7=20=D0=B3=D1=80=D1=83=D0=BF=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/groupchat.cpp | 24 ++++++++++++++++++++++++ protocols/Telegram/src/proto.h | 2 ++ protocols/Telegram/src/stdafx.h | 1 + 3 files changed, 27 insertions(+) (limited to 'protocols/Telegram') diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 0aa21fb752..76fb694a5c 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -151,6 +151,7 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam) break; case GC_USER_PRIVMESS: + Chat_SendPrivateMessage(gch); break; case GC_USER_LOGMENU: @@ -163,6 +164,29 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam) return 1; } +void CTelegramProto::Chat_SendPrivateMessage(GCHOOK *gch) +{ + MCONTACT hContact; + TD::int53 userId = _wtoi64(gch->ptszUID); + auto *pUser = FindUser(userId); + if (pUser == nullptr || pUser->hContact == INVALID_CONTACT_ID) { + PROTOSEARCHRESULT psr = { sizeof(psr) }; + psr.id.w = (wchar_t *)gch->ptszUID; + psr.firstName.w = (wchar_t *)gch->ptszNick; + + hContact = AddToList(PALF_TEMPORARY, &psr); + if (hContact == 0) + return; + + setWString(hContact, "Nick", gch->ptszNick); + Contact::Hide(hContact); + db_set_dw(hContact, "Ignore", "Mask1", 0); + } + else hContact = pUser->hContact; + + CallService(MS_MSG_SENDMESSAGE, hContact, 0); +} + ///////////////////////////////////////////////////////////////////////////////////////// int CTelegramProto::GcMenuHook(WPARAM, LPARAM lParam) diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 6df28c5d99..f4635d44f6 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -214,6 +214,8 @@ class CTelegramProto : public PROTO void InitGroupChat(TG_USER *pUser, const TD::chat *pChat, bool bUpdateMembers); void StartGroupChat(td::ClientManager::Response &response, void *pUserData); + + void Chat_SendPrivateMessage(GCHOOK *gch); // Search TD::array m_searchIds; diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h index b16b91840c..f2a60d704e 100644 --- a/protocols/Telegram/src/stdafx.h +++ b/protocols/Telegram/src/stdafx.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3