From 49e7758046391bb9c49faf37020c27523f913b57 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 9 Dec 2023 18:11:33 +0300 Subject: =?UTF-8?q?fixes=20#4027=20(Telegram:=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=85=D0=BE=D0=B4=D0=B5=20=D0=B2=20=D1=81=D1=83=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=83=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=BE=D0=B2=20=D0=BF=D0=BE=D1=8F=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D1=8E=D1=82=D1=81=D1=8F=20=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=8D=D1=82=D0=BE=D0=B9=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/server.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index c84cec8f95..4b91e3fae8 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -938,7 +938,6 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj) return; } - auto *pu = AddUser(pUser->id_, false); std::string szFirstName = pUser->first_name_, szLastName = pUser->last_name_; if (szLastName.empty()) { size_t p = szFirstName.rfind(' '); @@ -948,6 +947,20 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj) } } + // if that's just a bot, keep it as a virtual contact in memory + if (typeID == TD::userTypeBot::ID) { + auto *pu = AddFakeUser(pUser->id_, false); + if (pu->hContact == INVALID_CONTACT_ID) { + pu->wszFirstName = Utf2T(szFirstName.c_str()); + pu->wszLastName = Utf2T(szLastName.c_str()); + if (pUser->usernames_) + pu->wszNick = Utf2T(pUser->usernames_->editable_username_.c_str()); + return; + } + } + + auto *pu = AddUser(pUser->id_, false); + setUString(pu->hContact, "FirstName", szFirstName.c_str()); setUString(pu->hContact, "LastName", szLastName.c_str()); if (pu->hContact) -- cgit v1.2.3