From 6c0438fc6938c6f091c195d03fbd0ab82959e550 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 7 Apr 2022 20:38:22 +0300 Subject: [PATCH] Minor fixes. --- td/generate/scheme/td_api.tl | 2 +- td/telegram/AttachMenuManager.cpp | 5 +++++ td/telegram/AttachMenuManager.h | 2 +- td/telegram/BotMenuButton.cpp | 7 +++++-- td/telegram/ContactsManager.cpp | 9 +++++++-- td/telegram/DialogParticipant.h | 1 - td/telegram/DialogParticipantFilter.cpp | 2 +- td/telegram/DialogParticipantFilter.h | 5 +---- td/telegram/ReplyMarkup.hpp | 4 +++- 9 files changed, 24 insertions(+), 13 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 309936480..962c4199c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3342,7 +3342,7 @@ internalLinkTypeActiveSessions = InternalLinkType; //@description The link is a link to an attach menu bot to be opened in the specified chat. Process given chat_link to open corresponding chat. //-Then call searchPublicChat with the given bot username, check that the user is a bot and can be added to attach menu. Then use getAttachMenuBot to receive information about the bot. //-If the bot isn't added to attach menu, then user needs to confirm adding the bot to attach menu. If user confirms adding, then use toggleBotIsAddedToAttachMenu to add it. -//-If attach menu bots can't be used in the current chat, show an error to the user. If the bot is added to attach menu, then use openWebApp with the given url +//-If attach menu bots can't be used in the current chat, show an error to the user. If the bot is added to attach menu, then use openWebApp with the given URL //@chat_link An internal link pointing to a chat; may be null if the current chat needs to be kept @bot_username Username of the bot @url URL to be passed to openWebApp internalLinkTypeAttachMenuBot chat_link:InternalLinkType bot_username:string url:string = InternalLinkType; diff --git a/td/telegram/AttachMenuManager.cpp b/td/telegram/AttachMenuManager.cpp index 54570204a..ab865a3ea 100644 --- a/td/telegram/AttachMenuManager.cpp +++ b/td/telegram/AttachMenuManager.cpp @@ -14,17 +14,22 @@ #include "td/telegram/DocumentsManager.h" #include "td/telegram/files/FileId.hpp" #include "td/telegram/files/FileManager.h" +#include "td/telegram/Global.h" #include "td/telegram/logevent/LogEvent.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/StateManager.h" #include "td/telegram/Td.h" #include "td/telegram/TdDb.h" +#include "td/telegram/TdParameters.h" #include "td/telegram/ThemeManager.h" #include "td/utils/algorithm.h" #include "td/utils/buffer.h" +#include "td/utils/logging.h" #include "td/utils/misc.h" #include "td/utils/Random.h" +#include "td/utils/Slice.h" +#include "td/utils/SliceBuilder.h" #include "td/utils/tl_helpers.h" namespace td { diff --git a/td/telegram/AttachMenuManager.h b/td/telegram/AttachMenuManager.h index eac36b2bb..bdab90481 100644 --- a/td/telegram/AttachMenuManager.h +++ b/td/telegram/AttachMenuManager.h @@ -18,7 +18,7 @@ #include "td/actor/Timeout.h" #include "td/utils/common.h" -#include "td/utils/FlatHashSet.h" +#include "td/utils/FlatHashMap.h" #include "td/utils/Status.h" namespace td { diff --git a/td/telegram/BotMenuButton.cpp b/td/telegram/BotMenuButton.cpp index dd3aea3cd..cf8c8b828 100644 --- a/td/telegram/BotMenuButton.cpp +++ b/td/telegram/BotMenuButton.cpp @@ -14,6 +14,9 @@ #include "td/telegram/Td.h" #include "td/utils/buffer.h" +#include "td/utils/logging.h" +#include "td/utils/SliceBuilder.h" +#include "td/utils/Status.h" namespace td { @@ -26,7 +29,7 @@ class SetBotMenuButtonQuery final : public Td::ResultHandler { void send(UserId user_id, telegram_api::object_ptr input_bot_menu_button) { auto input_user = user_id.is_valid() ? td_->contacts_manager_->get_input_user(user_id).move_as_ok() - : tl_object_ptr(); + : make_tl_object(); send_query(G()->net_query_creator().create( telegram_api::bots_setBotMenuButton(std::move(input_user), std::move(input_bot_menu_button)))); } @@ -58,7 +61,7 @@ class GetBotMenuButtonQuery final : public Td::ResultHandler { void send(UserId user_id) { auto input_user = user_id.is_valid() ? td_->contacts_manager_->get_input_user(user_id).move_as_ok() - : tl_object_ptr(); + : make_tl_object(); send_query(G()->net_query_creator().create(telegram_api::bots_getBotMenuButton(std::move(input_user)))); } diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 8af1dd5c3..163a40dfc 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -11568,8 +11568,13 @@ void ContactsManager::on_update_user_full_menu_button(UserFull *user_full, UserI CHECK(user_full != nullptr); CHECK(bot_menu_button != nullptr); auto new_button = get_bot_menu_button(std::move(bot_menu_button)); - if (user_full->menu_button == nullptr ? new_button != nullptr - : new_button == nullptr || *user_full->menu_button != *new_button) { + bool is_changed; + if (user_full->menu_button == nullptr) { + is_changed = (new_button != nullptr); + } else { + is_changed = (new_button == nullptr || *user_full->menu_button != *new_button); + } + if (is_changed) { user_full->menu_button = std::move(new_button); user_full->is_changed = true; } diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index 33833a3e3..61316e3a9 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -8,7 +8,6 @@ #include "td/telegram/ChannelType.h" #include "td/telegram/DialogId.h" -#include "td/telegram/MessageId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/telegram/UserId.h" diff --git a/td/telegram/DialogParticipantFilter.cpp b/td/telegram/DialogParticipantFilter.cpp index 8fbdddaa0..f7a0801bb 100644 --- a/td/telegram/DialogParticipantFilter.cpp +++ b/td/telegram/DialogParticipantFilter.cpp @@ -34,7 +34,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant } } -DialogParticipantFilter::DialogParticipantFilter(const tl_object_ptr &filter) { +DialogParticipantFilter::DialogParticipantFilter(const td_api::object_ptr &filter) { if (filter == nullptr) { type_ = Type::Members; return; diff --git a/td/telegram/DialogParticipantFilter.h b/td/telegram/DialogParticipantFilter.h index b330ab66f..3b3e7166c 100644 --- a/td/telegram/DialogParticipantFilter.h +++ b/td/telegram/DialogParticipantFilter.h @@ -6,11 +6,8 @@ // #pragma once -#include "td/telegram/DialogId.h" #include "td/telegram/MessageId.h" #include "td/telegram/td_api.h" -#include "td/telegram/telegram_api.h" -#include "td/telegram/UserId.h" #include "td/utils/common.h" #include "td/utils/StringBuilder.h" @@ -28,7 +25,7 @@ class DialogParticipantFilter { friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantFilter &filter); public: - explicit DialogParticipantFilter(const tl_object_ptr &filter); + explicit DialogParticipantFilter(const td_api::object_ptr &filter); td_api::object_ptr get_supergroup_members_filter_object(const string &query) const; diff --git a/td/telegram/ReplyMarkup.hpp b/td/telegram/ReplyMarkup.hpp index 657505217..50d0997c8 100644 --- a/td/telegram/ReplyMarkup.hpp +++ b/td/telegram/ReplyMarkup.hpp @@ -28,11 +28,13 @@ void store(KeyboardButton button, StorerT &storer) { template void parse(KeyboardButton &button, ParserT &parser) { - bool has_url = false; + bool has_url; if (parser.version() >= static_cast(Version::AddKeyboardButtonFlags)) { BEGIN_PARSE_FLAGS(); PARSE_FLAG(has_url); END_PARSE_FLAGS(); + } else { + has_url = false; } parse(button.type, parser); parse(button.text, parser);