Support showing attachment menu bots in side menu.

This commit is contained in:
levlam 2023-09-07 16:45:42 +03:00
parent 604f39c295
commit 3983615646
3 changed files with 33 additions and 15 deletions

View File

@ -3613,25 +3613,28 @@ speechRecognitionResultError error:error = SpeechRecognitionResult;
//@description Describes a color to highlight a bot added to attachment menu @light_color Color in the RGB24 format for light themes @dark_color Color in the RGB24 format for dark themes
attachmentMenuBotColor light_color:int32 dark_color:int32 = AttachmentMenuBotColor;
//@description Represents a bot, which can be added to attachment menu
//@bot_user_id User identifier of the bot added to attachment menu
//@description Represents a bot, which can be added to attachment or side menu
//@bot_user_id User identifier of the bot
//@supports_self_chat True, if the bot supports opening from attachment menu in the chat with the bot
//@supports_user_chats True, if the bot supports opening from attachment menu in private chats with ordinary users
//@supports_bot_chats True, if the bot supports opening from attachment menu in private chats with other bots
//@supports_group_chats True, if the bot supports opening from attachment menu in basic group and supergroup chats
//@supports_channel_chats True, if the bot supports opening from attachment menu in channel chats
//@supports_settings True, if the bot supports "settings_button_pressed" event
//@request_write_access True, if the user must be asked for the permission to the bot to send them messages
//@request_write_access True, if the user must be asked for the permission to send messages to the bot
//@show_in_attachment_menu True, if the bot must be shown in the attachment menu
//@show_in_side_menu True, if the bot must be shown in the side menu menu
//@show_disclaimer_in_side_menu True, if a disclaimer, why the bot is shown in the side menu, is needed
//@name Name for the bot in attachment menu
//@name_color Color to highlight selected name of the bot if appropriate; may be null
//@default_icon Default attachment menu icon for the bot in SVG format; may be null
//@ios_static_icon Attachment menu icon for the bot in SVG format for the official iOS app; may be null
//@ios_animated_icon Attachment menu icon for the bot in TGS format for the official iOS app; may be null
//@android_icon Attachment menu icon for the bot in TGS format for the official Android app; may be null
//@macos_icon Attachment menu icon for the bot in TGS format for the official native macOS app; may be null
//@default_icon Default icon for the bot in SVG format; may be null
//@ios_static_icon Icon for the bot in SVG format for the official iOS app; may be null
//@ios_animated_icon Icon for the bot in TGS format for the official iOS app; may be null
//@android_icon Icon for the bot in TGS format for the official Android app; may be null
//@macos_icon Icon for the bot in TGS format for the official native macOS app; may be null
//@icon_color Color to highlight selected icon of the bot if appropriate; may be null
//@web_app_placeholder Default placeholder for opened Web Apps in SVG format; may be null
attachmentMenuBot bot_user_id:int53 supports_self_chat:Bool supports_user_chats:Bool supports_bot_chats:Bool supports_group_chats:Bool supports_channel_chats:Bool supports_settings:Bool request_write_access:Bool name:string name_color:attachmentMenuBotColor default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file icon_color:attachmentMenuBotColor web_app_placeholder:file = AttachmentMenuBot;
attachmentMenuBot bot_user_id:int53 supports_self_chat:Bool supports_user_chats:Bool supports_bot_chats:Bool supports_group_chats:Bool supports_channel_chats:Bool supports_settings:Bool request_write_access:Bool show_in_attachment_menu:Bool show_in_side_menu:Bool show_disclaimer_in_side_menu:Bool name:string name_color:attachmentMenuBotColor default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file icon_color:attachmentMenuBotColor web_app_placeholder:file = AttachmentMenuBot;
//@description Information about the message sent by answerWebAppQuery @inline_message_id Identifier of the sent inline message, if known
sentWebAppMessage inline_message_id:string = SentWebAppMessage;
@ -5969,7 +5972,7 @@ updateTermsOfService terms_of_service_id:string terms_of_service:termsOfService
//@description The list of users nearby has changed. The update is guaranteed to be sent only 60 seconds after a successful searchChatsNearby request @users_nearby The new list of users nearby
updateUsersNearby users_nearby:vector<chatNearby> = Update;
//@description The list of bots added to attachment menu has changed @bots The new list of bots added to attachment menu. The bots must not be shown on scheduled messages screen
//@description The list of bots added to attachment or side menu has changed @bots The new list of bots. The bots must not be shown on scheduled messages screen
updateAttachmentMenuBots bots:vector<attachmentMenuBot> = Update;
//@description A message was sent by an opened Web App, so the Web App needs to be closed @web_app_launch_id Identifier of Web App launch
@ -7564,10 +7567,10 @@ reportStory story_sender_chat_id:int53 story_id:int32 reason:ReportReason text:s
activateStoryStealthMode = Ok;
//@description Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier
//@description Returns information about a bot that can be added to attachment or side menu @bot_user_id Bot's user identifier
getAttachmentMenuBot bot_user_id:int53 = AttachmentMenuBot;
//@description Adds or removes a bot to attachment menu. Bot can be added to attachment menu, only if userTypeBot.can_be_added_to_attachment_menu == true
//@description Adds or removes a bot to attachment and side menu. Bot can be added to the menu, only if userTypeBot.can_be_added_to_attachment_menu == true
//@bot_user_id Bot's user identifier
//@is_added Pass true to add the bot to attachment menu; pass false to remove the bot from attachment menu
//@allow_write_access Pass true if the current user allowed the bot to send them messages. Ignored if is_added is false

View File

@ -415,7 +415,9 @@ bool operator==(const AttachMenuManager::AttachMenuBot &lhs, const AttachMenuMan
lhs.supports_group_dialogs_ == rhs.supports_group_dialogs_ &&
lhs.supports_broadcast_dialogs_ == rhs.supports_broadcast_dialogs_ &&
lhs.supports_settings_ == rhs.supports_settings_ && lhs.request_write_access_ == rhs.request_write_access_ &&
lhs.name_ == rhs.name_ && lhs.default_icon_file_id_ == rhs.default_icon_file_id_ &&
lhs.show_in_attach_menu_ == rhs.show_in_attach_menu_ && lhs.show_in_side_menu_ == rhs.show_in_side_menu_ &&
lhs.side_menu_disclaimer_needed_ == rhs.side_menu_disclaimer_needed_ && lhs.name_ == rhs.name_ &&
lhs.default_icon_file_id_ == rhs.default_icon_file_id_ &&
lhs.ios_static_icon_file_id_ == rhs.ios_static_icon_file_id_ &&
lhs.ios_animated_icon_file_id_ == rhs.ios_animated_icon_file_id_ &&
lhs.android_icon_file_id_ == rhs.android_icon_file_id_ && lhs.macos_icon_file_id_ == rhs.macos_icon_file_id_ &&
@ -456,6 +458,9 @@ void AttachMenuManager::AttachMenuBot::store(StorerT &storer) const {
STORE_FLAG(has_placeholder_file_id);
STORE_FLAG(has_cache_version);
STORE_FLAG(request_write_access_);
STORE_FLAG(show_in_attach_menu_);
STORE_FLAG(show_in_side_menu_);
STORE_FLAG(side_menu_disclaimer_needed_);
END_STORE_FLAGS();
td::store(user_id_, storer);
td::store(name_, storer);
@ -515,6 +520,9 @@ void AttachMenuManager::AttachMenuBot::parse(ParserT &parser) {
PARSE_FLAG(has_placeholder_file_id);
PARSE_FLAG(has_cache_version);
PARSE_FLAG(request_write_access_);
PARSE_FLAG(show_in_attach_menu_);
PARSE_FLAG(show_in_side_menu_);
PARSE_FLAG(side_menu_disclaimer_needed_);
END_PARSE_FLAGS();
td::parse(user_id_, parser);
td::parse(name_, parser);
@ -994,6 +1002,9 @@ Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
}
attach_menu_bot.supports_settings_ = bot->has_settings_;
attach_menu_bot.request_write_access_ = bot->request_write_access_;
attach_menu_bot.show_in_attach_menu_ = bot->show_in_attach_menu_;
attach_menu_bot.show_in_side_menu_ = bot->show_in_side_menu_;
attach_menu_bot.side_menu_disclaimer_needed_ = bot->side_menu_disclaimer_needed_;
if (!attach_menu_bot.default_icon_file_id_.is_valid()) {
return Status::Error(PSLICE() << "Have no default icon for " << user_id);
}
@ -1252,7 +1263,8 @@ td_api::object_ptr<td_api::attachmentMenuBot> AttachMenuManager::get_attachment_
return td_api::make_object<td_api::attachmentMenuBot>(
td_->contacts_manager_->get_user_id_object(bot.user_id_, "get_attachment_menu_bot_object"),
bot.supports_self_dialog_, bot.supports_user_dialogs_, bot.supports_bot_dialogs_, bot.supports_group_dialogs_,
bot.supports_broadcast_dialogs_, bot.supports_settings_, bot.request_write_access_, bot.name_,
bot.supports_broadcast_dialogs_, bot.supports_settings_, bot.request_write_access_, bot.show_in_attach_menu_,
bot.show_in_side_menu_, bot.side_menu_disclaimer_needed_, bot.name_,
get_attach_menu_bot_color_object(bot.name_color_), get_file(bot.default_icon_file_id_),
get_file(bot.ios_static_icon_file_id_), get_file(bot.ios_animated_icon_file_id_),
get_file(bot.android_icon_file_id_), get_file(bot.macos_icon_file_id_),

View File

@ -106,6 +106,9 @@ class AttachMenuManager final : public Actor {
bool supports_broadcast_dialogs_ = false;
bool supports_settings_ = false;
bool request_write_access_ = false;
bool show_in_attach_menu_ = false;
bool show_in_side_menu_ = false;
bool side_menu_disclaimer_needed_ = false;
string name_;
AttachMenuBotColor name_color_;
FileId default_icon_file_id_;
@ -116,7 +119,7 @@ class AttachMenuManager final : public Actor {
AttachMenuBotColor icon_color_;
FileId placeholder_file_id_;
static constexpr uint32 CACHE_VERSION = 2;
static constexpr uint32 CACHE_VERSION = 3;
uint32 cache_version_ = 0;
template <class StorerT>