From 1338ad89ee45bdb681c531476dca00a377d7d033 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 3 Dec 2023 17:14:30 +0300 Subject: PROTO_INTERFACE::SendMsg: second parameter became a reply event id --- protocols/Telegram/src/groupchat.cpp | 2 +- protocols/Telegram/src/proto.cpp | 11 +++++++++-- protocols/Telegram/src/proto.h | 4 ++-- protocols/Telegram/src/server.cpp | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 618f415922..c99302d435 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -205,7 +205,7 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam) rtrimw(gch->ptszText); Chat_UnescapeTags(gch->ptszText); if (auto *pUser = FindUser(userId)) - SendTextMessage(pUser->chatId, T2Utf(gch->ptszText)); + SendTextMessage(pUser->chatId, 0, T2Utf(gch->ptszText)); } break; diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 3f5037e65f..be2156be82 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -597,7 +597,7 @@ HANDLE CTelegramProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, ///////////////////////////////////////////////////////////////////////////////////////// -int CTelegramProto::SendMsg(MCONTACT hContact, const char *pszMessage) +int CTelegramProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *pszMessage) { ptrA szId(getStringA(hContact, DBKEY_ID)); if (szId == nullptr) @@ -608,7 +608,14 @@ int CTelegramProto::SendMsg(MCONTACT hContact, const char *pszMessage) if (pUser == nullptr) return 0; - int msgid = SendTextMessage(pUser->chatId, pszMessage); + TD::int53 iReplyId = 0; + if (hReplyEvent) { + DB::EventInfo dbei(hReplyEvent, false); + if (dbei) + iReplyId = dbei2id(dbei); + } + + int msgid = SendTextMessage(pUser->chatId, iReplyId, pszMessage); if (msgid != -1) m_arOwnMsg.insert(new TG_OWN_MESSAGE(hContact, (HANDLE)msgid, "")); diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index db995e49be..45839832a5 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -241,7 +241,7 @@ class CTelegramProto : public PROTO void SendMarkRead(void); int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler = nullptr); int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo); - int SendTextMessage(int64_t chatId, const char *pszMessage); + int SendTextMessage(TD::int53 chatId, TD::int53 replyId, const char *pszMessage); void ProcessAuth(TD::updateAuthorizationState *pObj); void ProcessBasicGroup(TD::updateBasicGroup *pObj); @@ -356,7 +356,7 @@ public: MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *pre) override; HANDLE SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) override; - int SendMsg(MCONTACT hContact, const char *pszMessage) override; + int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *pszMessage) override; int SetStatus(int iNewStatus) override; void OnBuildProtoMenu() override; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index bb92d2af7d..75e4fa0cdc 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -327,7 +327,7 @@ void CTelegramProto::OnSendMessage(td::ClientManager::Response &response) } } -int CTelegramProto::SendTextMessage(int64_t chatId, const char *pszMessage) +int CTelegramProto::SendTextMessage(int64_t chatId, TD::int53 replyId, const char *pszMessage) { auto pContent = TD::make_object(); pContent->text_ = formatBbcodes(pszMessage); @@ -335,6 +335,7 @@ int CTelegramProto::SendTextMessage(int64_t chatId, const char *pszMessage) auto *pMessage = new TD::sendMessage(); pMessage->chat_id_ = chatId; pMessage->input_message_content_ = std::move(pContent); + pMessage->reply_to_message_id_ = replyId; return SendQuery(pMessage, &CTelegramProto::OnSendMessage); } -- cgit v1.2.3