Add chat flags to attachmentMenuBot.
This commit is contained in:
parent
2345933422
commit
e528558300
@ -2526,6 +2526,11 @@ attachmentMenuBotColor light_color:int32 dark_color:int32 = AttachmentMenuBotCol
|
|||||||
|
|
||||||
//@description Represents a bot added to attachment menu
|
//@description Represents a bot added to attachment menu
|
||||||
//@bot_user_id User identifier of the bot added to attachment menu
|
//@bot_user_id User identifier of the bot added to attachment menu
|
||||||
|
//@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
|
||||||
//@name Name for the bot in attachment menu
|
//@name Name for the bot in attachment menu
|
||||||
//@name_color Color to highlight selected name of the bot if appropriate; may be null
|
//@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
|
//@default_icon Default attachment menu icon for the bot in SVG format; may be null
|
||||||
@ -2534,7 +2539,7 @@ attachmentMenuBotColor light_color:int32 dark_color:int32 = AttachmentMenuBotCol
|
|||||||
//@android_icon Attachment menu icon for the bot in TGS format for the official Android 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
|
//@macos_icon Attachment menu 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
|
//@icon_color Color to highlight selected icon of the bot if appropriate; may be null
|
||||||
attachmentMenuBot bot_user_id:int53 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 = 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 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 = AttachmentMenuBot;
|
||||||
|
|
||||||
//@description Information about the message sent by answerWebAppQuery @inline_message_id Identifier of the sent inline message, if known
|
//@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;
|
sentWebAppMessage inline_message_id:string = SentWebAppMessage;
|
||||||
@ -3414,7 +3419,7 @@ internalLinkTypeActiveSessions = InternalLinkType;
|
|||||||
//@description The link is a link to an attachment menu bot to be opened in the specified chat. Process given chat_link to open corresponding chat.
|
//@description The link is a link to an attachment 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 attachment menu. Then use getAttachmentMenuBot to receive information about the bot.
|
//-Then call searchPublicChat with the given bot username, check that the user is a bot and can be added to attachment menu. Then use getAttachmentMenuBot to receive information about the bot.
|
||||||
//-If the bot isn't added to attachment menu, then user needs to confirm adding the bot to attachment menu. If user confirms adding, then use toggleBotIsAddedToAttachmentMenu to add it.
|
//-If the bot isn't added to attachment menu, then user needs to confirm adding the bot to attachment menu. If user confirms adding, then use toggleBotIsAddedToAttachmentMenu to add it.
|
||||||
//-If attachment menu bots can't be used in the current chat, show an error to the user. If the bot is added to attachment menu, then use openWebApp with the given URL
|
//-If the attachment menu bot can't be used in the opened chat, show an error to the user. If the bot is added to attachment 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
|
//@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
|
||||||
internalLinkTypeAttachmentMenuBot chat_link:InternalLinkType bot_username:string url:string = InternalLinkType;
|
internalLinkTypeAttachmentMenuBot chat_link:InternalLinkType bot_username:string url:string = InternalLinkType;
|
||||||
|
|
||||||
@ -4211,7 +4216,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
|
//@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;
|
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 be shown in attachment menu only in private chats. The bots must not be shown on scheduled messages screen
|
//@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
|
||||||
updateAttachmentMenuBots bots:vector<attachmentMenuBot> = Update;
|
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
|
//@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
|
||||||
|
@ -290,7 +290,11 @@ void AttachMenuManager::AttachMenuBotColor::parse(ParserT &parser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const AttachMenuManager::AttachMenuBot &lhs, const AttachMenuManager::AttachMenuBot &rhs) {
|
bool operator==(const AttachMenuManager::AttachMenuBot &lhs, const AttachMenuManager::AttachMenuBot &rhs) {
|
||||||
return lhs.user_id_ == rhs.user_id_ && lhs.name_ == rhs.name_ &&
|
return lhs.user_id_ == rhs.user_id_ && lhs.supports_self_dialog_ == rhs.supports_self_dialog_ &&
|
||||||
|
lhs.supports_user_dialogs_ == rhs.supports_user_dialogs_ &&
|
||||||
|
lhs.supports_bot_dialogs_ == rhs.supports_bot_dialogs_ &&
|
||||||
|
lhs.supports_group_dialogs_ == rhs.supports_group_dialogs_ &&
|
||||||
|
lhs.supports_broadcast_dialogs_ == rhs.supports_broadcast_dialogs_ && lhs.name_ == rhs.name_ &&
|
||||||
lhs.default_icon_file_id_ == rhs.default_icon_file_id_ &&
|
lhs.default_icon_file_id_ == rhs.default_icon_file_id_ &&
|
||||||
lhs.ios_static_icon_file_id_ == rhs.ios_static_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.ios_animated_icon_file_id_ == rhs.ios_animated_icon_file_id_ &&
|
||||||
@ -310,6 +314,7 @@ void AttachMenuManager::AttachMenuBot::store(StorerT &storer) const {
|
|||||||
bool has_macos_icon_file_id = macos_icon_file_id_.is_valid();
|
bool has_macos_icon_file_id = macos_icon_file_id_.is_valid();
|
||||||
bool has_name_color = name_color_ != AttachMenuBotColor();
|
bool has_name_color = name_color_ != AttachMenuBotColor();
|
||||||
bool has_icon_color = icon_color_ != AttachMenuBotColor();
|
bool has_icon_color = icon_color_ != AttachMenuBotColor();
|
||||||
|
bool has_support_flags = true;
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_ios_static_icon_file_id);
|
STORE_FLAG(has_ios_static_icon_file_id);
|
||||||
STORE_FLAG(has_ios_animated_icon_file_id);
|
STORE_FLAG(has_ios_animated_icon_file_id);
|
||||||
@ -318,6 +323,12 @@ void AttachMenuManager::AttachMenuBot::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(is_added_);
|
STORE_FLAG(is_added_);
|
||||||
STORE_FLAG(has_name_color);
|
STORE_FLAG(has_name_color);
|
||||||
STORE_FLAG(has_icon_color);
|
STORE_FLAG(has_icon_color);
|
||||||
|
STORE_FLAG(has_support_flags);
|
||||||
|
STORE_FLAG(supports_self_dialog_);
|
||||||
|
STORE_FLAG(supports_user_dialogs_);
|
||||||
|
STORE_FLAG(supports_bot_dialogs_);
|
||||||
|
STORE_FLAG(supports_group_dialogs_);
|
||||||
|
STORE_FLAG(supports_broadcast_dialogs_);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
td::store(user_id_, storer);
|
td::store(user_id_, storer);
|
||||||
td::store(name_, storer);
|
td::store(name_, storer);
|
||||||
@ -350,6 +361,7 @@ void AttachMenuManager::AttachMenuBot::parse(ParserT &parser) {
|
|||||||
bool has_macos_icon_file_id;
|
bool has_macos_icon_file_id;
|
||||||
bool has_name_color;
|
bool has_name_color;
|
||||||
bool has_icon_color;
|
bool has_icon_color;
|
||||||
|
bool has_support_flags;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_ios_static_icon_file_id);
|
PARSE_FLAG(has_ios_static_icon_file_id);
|
||||||
PARSE_FLAG(has_ios_animated_icon_file_id);
|
PARSE_FLAG(has_ios_animated_icon_file_id);
|
||||||
@ -358,6 +370,12 @@ void AttachMenuManager::AttachMenuBot::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(is_added_);
|
PARSE_FLAG(is_added_);
|
||||||
PARSE_FLAG(has_name_color);
|
PARSE_FLAG(has_name_color);
|
||||||
PARSE_FLAG(has_icon_color);
|
PARSE_FLAG(has_icon_color);
|
||||||
|
PARSE_FLAG(has_support_flags);
|
||||||
|
PARSE_FLAG(supports_self_dialog_);
|
||||||
|
PARSE_FLAG(supports_user_dialogs_);
|
||||||
|
PARSE_FLAG(supports_bot_dialogs_);
|
||||||
|
PARSE_FLAG(supports_group_dialogs_);
|
||||||
|
PARSE_FLAG(supports_broadcast_dialogs_);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
td::parse(user_id_, parser);
|
td::parse(user_id_, parser);
|
||||||
td::parse(name_, parser);
|
td::parse(name_, parser);
|
||||||
@ -380,6 +398,12 @@ void AttachMenuManager::AttachMenuBot::parse(ParserT &parser) {
|
|||||||
if (has_icon_color) {
|
if (has_icon_color) {
|
||||||
td::parse(icon_color_, parser);
|
td::parse(icon_color_, parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!has_support_flags) {
|
||||||
|
supports_self_dialog_ = true;
|
||||||
|
supports_user_dialogs_ = true;
|
||||||
|
supports_bot_dialogs_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttachMenuManager::AttachMenuBotsLogEvent {
|
class AttachMenuManager::AttachMenuBotsLogEvent {
|
||||||
@ -540,12 +564,12 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
|
|||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
// ok
|
|
||||||
break;
|
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
|
// ok
|
||||||
|
break;
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
return promise.set_error(Status::Error(400, "Web apps can be opened only in private chats"));
|
return promise.set_error(Status::Error(400, "Web apps can't be opened in secret chats"));
|
||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@ -696,7 +720,28 @@ Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto &peer_type : bot->peer_types_) {
|
||||||
|
switch (peer_type->get_id()) {
|
||||||
|
case telegram_api::attachMenuPeerTypeSameBotPM::ID:
|
||||||
|
attach_menu_bot.supports_self_dialog_ = true;
|
||||||
|
break;
|
||||||
|
case telegram_api::attachMenuPeerTypeBotPM::ID:
|
||||||
|
attach_menu_bot.supports_bot_dialogs_ = true;
|
||||||
|
break;
|
||||||
|
case telegram_api::attachMenuPeerTypePM::ID:
|
||||||
|
attach_menu_bot.supports_user_dialogs_ = true;
|
||||||
|
break;
|
||||||
|
case telegram_api::attachMenuPeerTypeChat::ID:
|
||||||
|
attach_menu_bot.supports_group_dialogs_ = true;
|
||||||
|
break;
|
||||||
|
case telegram_api::attachMenuPeerTypeBroadcast::ID:
|
||||||
|
attach_menu_bot.supports_broadcast_dialogs_ = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!attach_menu_bot.default_icon_file_id_.is_valid()) {
|
if (!attach_menu_bot.default_icon_file_id_.is_valid()) {
|
||||||
return Status::Error(PSLICE() << "Have no default icon for " << user_id);
|
return Status::Error(PSLICE() << "Have no default icon for " << user_id);
|
||||||
}
|
}
|
||||||
@ -897,10 +942,11 @@ td_api::object_ptr<td_api::attachmentMenuBot> AttachMenuManager::get_attachment_
|
|||||||
};
|
};
|
||||||
|
|
||||||
return td_api::make_object<td_api::attachmentMenuBot>(
|
return td_api::make_object<td_api::attachmentMenuBot>(
|
||||||
td_->contacts_manager_->get_user_id_object(bot.user_id_, "get_attachment_menu_bot_object"), bot.name_,
|
td_->contacts_manager_->get_user_id_object(bot.user_id_, "get_attachment_menu_bot_object"),
|
||||||
get_attach_menu_bot_color_object(bot.name_color_), get_file(bot.default_icon_file_id_),
|
bot.supports_self_dialog_, bot.supports_user_dialogs_, bot.supports_bot_dialogs_, bot.supports_group_dialogs_,
|
||||||
get_file(bot.ios_static_icon_file_id_), get_file(bot.ios_animated_icon_file_id_),
|
bot.supports_broadcast_dialogs_, bot.name_, get_attach_menu_bot_color_object(bot.name_color_),
|
||||||
get_file(bot.android_icon_file_id_), get_file(bot.macos_icon_file_id_),
|
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_),
|
||||||
get_attach_menu_bot_color_object(bot.icon_color_));
|
get_attach_menu_bot_color_object(bot.icon_color_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,11 @@ class AttachMenuManager final : public Actor {
|
|||||||
struct AttachMenuBot {
|
struct AttachMenuBot {
|
||||||
bool is_added_ = false;
|
bool is_added_ = false;
|
||||||
UserId user_id_;
|
UserId user_id_;
|
||||||
|
bool supports_self_dialog_ = false;
|
||||||
|
bool supports_user_dialogs_ = false;
|
||||||
|
bool supports_bot_dialogs_ = false;
|
||||||
|
bool supports_group_dialogs_ = false;
|
||||||
|
bool supports_broadcast_dialogs_ = false;
|
||||||
string name_;
|
string name_;
|
||||||
AttachMenuBotColor name_color_;
|
AttachMenuBotColor name_color_;
|
||||||
FileId default_icon_file_id_;
|
FileId default_icon_file_id_;
|
||||||
|
Loading…
Reference in New Issue
Block a user