From d992c895d05a7d9539e694e30fd90a5778c93cb6 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 22 Oct 2018 16:47:41 +0300 Subject: [PATCH] Ignore unsuitable bots in getTopChats. GitOrigin-RevId: a669a09cddc1bd1e2f5fce7483346aad27ddc6e4 --- td/telegram/TopDialogManager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/td/telegram/TopDialogManager.cpp b/td/telegram/TopDialogManager.cpp index 34682cde2..63c1b43b9 100644 --- a/td/telegram/TopDialogManager.cpp +++ b/td/telegram/TopDialogManager.cpp @@ -290,6 +290,18 @@ void TopDialogManager::do_get_top_dialogs(GetTopDialogsQuery &&query) { LOG(INFO) << "Skip self " << user_id; continue; } + if (query.category == TopDialogCategory::BotInline || query.category == TopDialogCategory::BotPM) { + auto r_bot_info = G()->td().get_actor_unsafe()->contacts_manager_->get_bot_data(user_id); + if (r_bot_info.is_error()) { + LOG(INFO) << "Skip not a bot " << user_id; + continue; + } + if (query.category == TopDialogCategory::BotInline && + (r_bot_info.ok().username.empty() || !r_bot_info.ok().is_inline)) { + LOG(INFO) << "Skip not inline bot " << user_id; + continue; + } + } } result.push_back(dialog_id);