From f43428d4d862f9850f33f029eb1d7a936a8c96f6 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 29 Apr 2024 16:46:51 +0300 Subject: [PATCH] Add shorthands for getChatMember with self for bots. --- td/telegram/ChatManager.cpp | 6 ++++++ td/telegram/DialogParticipantManager.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/td/telegram/ChatManager.cpp b/td/telegram/ChatManager.cpp index 89d7927fe..d8f03a2ab 100644 --- a/td/telegram/ChatManager.cpp +++ b/td/telegram/ChatManager.cpp @@ -8115,6 +8115,12 @@ void ChatManager::get_chat_participant(ChatId chat_id, UserId user_id, Promiseauth_manager_->is_bot() && user_id == td_->user_manager_->get_my_id()) { + // bots don't need inviter information + reload_chat(chat_id, Auto(), "get_chat_participant"); + return promise.set_value(DialogParticipant{DialogId(user_id), user_id, c->date, c->status}); + } + auto chat_full = get_chat_full_force(chat_id, "get_chat_participant"); if (chat_full == nullptr || (td_->auth_manager_->is_bot() && is_chat_full_outdated(chat_full, c, chat_id, true))) { auto query_promise = PromiseCreator::lambda( diff --git a/td/telegram/DialogParticipantManager.cpp b/td/telegram/DialogParticipantManager.cpp index 52679e144..3dc211abe 100644 --- a/td/telegram/DialogParticipantManager.cpp +++ b/td/telegram/DialogParticipantManager.cpp @@ -1611,6 +1611,15 @@ void DialogParticipantManager::get_channel_participant(ChannelId channel_id, Dia } } + if (td_->auth_manager_->is_bot() && participant_dialog_id == td_->dialog_manager_->get_my_dialog_id() && + td_->chat_manager_->have_channel(channel_id)) { + // bots don't need inviter information + td_->chat_manager_->reload_channel(channel_id, Auto(), "get_channel_participant"); + return promise.set_value(DialogParticipant{participant_dialog_id, participant_dialog_id.get_user_id(), + td_->chat_manager_->get_channel_date(channel_id), + td_->chat_manager_->get_channel_status(channel_id)}); + } + auto on_result_promise = PromiseCreator::lambda([actor_id = actor_id(this), channel_id, participant_dialog_id, promise = std::move(promise)](Result r_dialog_participant) mutable {