Fix "attachment menu" spelling.

This commit is contained in:
levlam 2022-04-14 22:56:27 +03:00
parent 42c6280321
commit ff6f165551
9 changed files with 88 additions and 84 deletions

View File

@ -372,8 +372,8 @@ userTypeDeleted = UserType;
//@is_inline True, if the bot supports inline queries
//@inline_query_placeholder Placeholder for inline queries (displayed on the application input field)
//@need_location True, if the location of the user is expected to be sent with every inline query to this bot
//@can_be_added_to_attach_menu True, if the bot can be added to attach menu
userTypeBot can_join_groups:Bool can_read_all_group_messages:Bool is_inline:Bool inline_query_placeholder:string need_location:Bool can_be_added_to_attach_menu:Bool = UserType;
//@can_be_added_to_attachment_menu True, if the bot can be added to attachment menu
userTypeBot can_join_groups:Bool can_read_all_group_messages:Bool is_inline:Bool inline_query_placeholder:string need_location:Bool can_be_added_to_attachment_menu:Bool = UserType;
//@description No information on the user besides the user identifier is available, yet this user has not been deleted. This object is extremely rare and must be handled like a deleted user. It is not possible to perform any actions on users of this type
userTypeUnknown = UserType;
@ -2517,20 +2517,20 @@ diceStickersSlotMachine background:sticker lever:sticker left_reel:sticker cente
importedContacts user_ids:vector<int53> importer_count:vector<int32> = ImportedContacts;
//@description Describes a color to highlight a bot added to attach menu @light_color Color in the RGB24 format for light themes @dark_color Color in the RGB24 format for dark themes
attachMenuBotColor light_color:int32 dark_color:int32 = AttachMenuBotColor;
//@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 added to attach menu
//@bot_user_id User identifier of the bot added to attach menu
//@name Name for the bot in attach menu
//@description Represents a bot added to attachment menu
//@bot_user_id User identifier of the bot added to 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
//@default_icon Default attach menu icon for the bot in SVG format; may be null
//@ios_static_icon Attach menu icon for the bot in SVG format for the official iOS app; may be null
//@ios_animated_icon Attach menu icon for the bot in TGS format for the official iOS app; may be null
//@android_icon Attach menu icon for the bot in TGS format for the official Android app; may be null
//@macos_icon Attach menu icon for the bot in TGS format for the official native macOS app; 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
//@icon_color Color to highlight selected icon of the bot if appropriate; may be null
attachMenuBot bot_user_id:int53 name:string name_color:attachMenuBotColor default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file icon_color:attachMenuBotColor = AttachMenuBot;
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;
//@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;
@ -3351,12 +3351,12 @@ chatReportReasonCustom = ChatReportReason;
//@description The link is a link to the active sessions section of the app. Use getActiveSessions to handle the link
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
//@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.
//-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
//@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;
internalLinkTypeAttachmentMenuBot chat_link:InternalLinkType bot_username:string url:string = InternalLinkType;
//@description The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode @code The authentication code
internalLinkTypeAuthenticationCode code:string = InternalLinkType;
@ -4144,8 +4144,8 @@ 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 attach menu has changed @bots The new list of bots added to attach menu. The bots must be shown in attach menu only in private chats. The bots must not be shown on scheduled messages screen
updateAttachMenuBots bots:vector<attachMenuBot> = 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
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
updateWebAppMessageSent web_app_launch_id:int64 = Update;
@ -4904,11 +4904,11 @@ getWebAppUrl bot_user_id:int53 url:string theme:themeParameters = HttpUrl;
//@bot_user_id Identifier of the target bot @button_text Text of the keyboardButtonTypeWebApp button, which opened the web app @data Received data
sendWebAppData bot_user_id:int53 button_text:string data:string = Ok;
//@description Informs TDLib that a web app is being opened from attach menu, a botMenuButton button, an internalLinkTypeAttachMenuBot link, or an inlineKeyboardButtonTypeWebApp button.
//@description Informs TDLib that a web app is being opened from attachment menu, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an inlineKeyboardButtonTypeWebApp button.
//-For each bot, a confirmation alert about data sent to the bot must be shown once
//@chat_id Identifier of the chat in which the web app is opened. Web apps can be opened only in private chats for now
//@bot_user_id Identifier of the bot, providing the web app
//@url The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, or an internalLinkTypeAttachMenuBot link, or an empty string otherwise
//@url The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, or an internalLinkTypeAttachmentMenuBot link, or an empty string otherwise
//@theme Preferred web app theme; pass null to use the default theme
//@reply_to_message_id Identifier of the replied message for the message sent by the web app; 0 if none
openWebApp chat_id:int53 bot_user_id:int53 url:string theme:themeParameters reply_to_message_id:int53 = WebAppInfo;
@ -5214,11 +5214,11 @@ toggleChatIsPinned chat_list:ChatList chat_id:int53 is_pinned:Bool = Ok;
setPinnedChats chat_list:ChatList chat_ids:vector<int53> = Ok;
//@description Returns information about a bot that can be added to attach menu @bot_user_id Bot's user identifier
getAttachMenuBot bot_user_id:int53 = AttachMenuBot;
//@description Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier
getAttachmentMenuBot bot_user_id:int53 = AttachmentMenuBot;
//@description Adds or removes a bot to attach menu. Bot can be added to attach menu, only if userTypeBot.can_be_added_to_attach_menu == true @bot_user_id Bot's user identifier @is_added Pass true to add the bot to attach menu; pass false to remove the bot from attach menu
toggleBotIsAddedToAttachMenu bot_user_id:int53 is_added:Bool = Ok;
//@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 @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
toggleBotIsAddedToAttachmentMenu bot_user_id:int53 is_added:Bool = Ok;
//@description Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates

View File

@ -236,7 +236,7 @@ class ToggleBotInAttachMenuQuery final : public Td::ResultHandler {
auto result = result_ptr.move_as_ok();
if (!result) {
LOG(ERROR) << "Failed to add a bot to attach menu";
LOG(ERROR) << "Failed to add a bot to attachment menu";
}
promise_.set_value(Unit());
}
@ -428,7 +428,7 @@ void AttachMenuManager::init() {
hash_ = attach_menu_bots_log_event.hash_;
attach_menu_bots_ = std::move(attach_menu_bots_log_event.attach_menu_bots_);
} else {
LOG(ERROR) << "Ignore invalid attach menu bots log event";
LOG(ERROR) << "Ignore invalid attachment menu bots log event";
}
}
}
@ -598,7 +598,7 @@ Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
auto parsed_document =
td_->documents_manager_->on_get_document(move_tl_object_as<telegram_api::document>(icon->icon_), DialogId());
if (parsed_document.type != expected_document_type) {
LOG(ERROR) << "Receive wrong attach menu bot icon \"" << name << "\" for " << user_id;
LOG(ERROR) << "Receive wrong attachment menu bot icon \"" << name << "\" for " << user_id;
continue;
}
bool expect_colors = false;
@ -624,17 +624,17 @@ Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
}
if (expect_colors) {
if (icon->colors_.empty()) {
LOG(ERROR) << "Have no colors for attach menu bot icon for " << user_id;
LOG(ERROR) << "Have no colors for attachment menu bot icon for " << user_id;
} else {
for (auto &color : icon->colors_) {
if (color->name_ != "light_icon" && color->name_ != "light_text" && color->name_ != "dark_icon" &&
color->name_ != "dark_text") {
LOG(ERROR) << "Receive unexpected attach menu color " << color->name_ << " for " << user_id;
LOG(ERROR) << "Receive unexpected attachment menu color " << color->name_ << " for " << user_id;
continue;
}
auto alpha = (color->color_ >> 24) & 0xFF;
if (alpha != 0 && alpha != 0xFF) {
LOG(ERROR) << "Receive alpha in attach menu color " << color->name_ << " for " << user_id;
LOG(ERROR) << "Receive alpha in attachment menu color " << color->name_ << " for " << user_id;
}
auto c = color->color_ & 0xFFFFFF;
switch (color->name_[6]) {
@ -665,7 +665,7 @@ Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
}
} else {
if (!icon->colors_.empty()) {
LOG(ERROR) << "Have unexpected colors for attach menu bot icon for " << user_id << " with name " << name;
LOG(ERROR) << "Have unexpected colors for attachment menu bot icon for " << user_id << " with name " << name;
}
}
}
@ -724,7 +724,7 @@ void AttachMenuManager::on_reload_attach_menu_bots(
continue;
}
if (!r_attach_menu_bot.ok().is_added_) {
LOG(ERROR) << "Receive non-added attach menu bot " << r_attach_menu_bot.ok().user_id_;
LOG(ERROR) << "Receive non-added attachment menu bot " << r_attach_menu_bot.ok().user_id_;
new_hash = 0;
continue;
}
@ -760,12 +760,12 @@ void AttachMenuManager::remove_bot_from_attach_menu(UserId user_id) {
}
void AttachMenuManager::get_attach_menu_bot(UserId user_id,
Promise<td_api::object_ptr<td_api::attachMenuBot>> &&promise) {
Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise) {
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(user_id));
if (!bot_data.can_be_added_to_attach_menu) {
return promise.set_error(Status::Error(400, "The bot can't be added to attach menu"));
return promise.set_error(Status::Error(400, "The bot can't be added to attachment menu"));
}
auto query_promise =
@ -779,7 +779,7 @@ void AttachMenuManager::get_attach_menu_bot(UserId user_id,
void AttachMenuManager::on_get_attach_menu_bot(
UserId user_id, Result<telegram_api::object_ptr<telegram_api::attachMenuBotsBot>> &&result,
Promise<td_api::object_ptr<td_api::attachMenuBot>> &&promise) {
Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
TRY_RESULT_PROMISE(promise, bot, std::move(result));
@ -803,7 +803,7 @@ void AttachMenuManager::on_get_attach_menu_bot(
}
}
if (!is_found) {
LOG(INFO) << "Add missing attach menu bot " << user_id;
LOG(INFO) << "Add missing attachment menu bot " << user_id;
}
hash_ = 0;
attach_menu_bots_.insert(attach_menu_bots_.begin(), attach_menu_bot);
@ -813,7 +813,7 @@ void AttachMenuManager::on_get_attach_menu_bot(
} else {
remove_bot_from_attach_menu(user_id);
}
promise.set_value(get_attach_menu_bot_object(attach_menu_bot));
promise.set_value(get_attachment_menu_bot_object(attach_menu_bot));
}
void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, Promise<Unit> &&promise) {
@ -835,7 +835,7 @@ void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool
if (is_added) {
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(user_id));
if (!bot_data.can_be_added_to_attach_menu) {
return promise.set_error(Status::Error(400, "The bot can't be added to attach menu"));
return promise.set_error(Status::Error(400, "The bot can't be added to attachment menu"));
}
} else {
remove_bot_from_attach_menu(user_id);
@ -853,7 +853,7 @@ void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool
td_->create_handler<ToggleBotInAttachMenuQuery>(std::move(query_promise))->send(std::move(input_user), is_added);
}
td_api::object_ptr<td_api::attachMenuBot> AttachMenuManager::get_attach_menu_bot_object(
td_api::object_ptr<td_api::attachmentMenuBot> AttachMenuManager::get_attachment_menu_bot_object(
const AttachMenuBot &bot) const {
auto get_file = [td = td_](FileId file_id) -> td_api::object_ptr<td_api::file> {
if (!file_id.is_valid()) {
@ -862,31 +862,31 @@ td_api::object_ptr<td_api::attachMenuBot> AttachMenuManager::get_attach_menu_bot
return td->file_manager_->get_file_object(file_id);
};
auto get_attach_menu_bot_color_object =
[](const AttachMenuBotColor &color) -> td_api::object_ptr<td_api::attachMenuBotColor> {
[](const AttachMenuBotColor &color) -> td_api::object_ptr<td_api::attachmentMenuBotColor> {
if (color == AttachMenuBotColor()) {
return nullptr;
}
return td_api::make_object<td_api::attachMenuBotColor>(color.light_color_, color.dark_color_);
return td_api::make_object<td_api::attachmentMenuBotColor>(color.light_color_, color.dark_color_);
};
return td_api::make_object<td_api::attachMenuBot>(
td_->contacts_manager_->get_user_id_object(bot.user_id_, "get_attach_menu_bot_object"), bot.name_,
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_,
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_),
get_attach_menu_bot_color_object(bot.icon_color_));
}
td_api::object_ptr<td_api::updateAttachMenuBots> AttachMenuManager::get_update_attach_menu_bots_object() const {
td_api::object_ptr<td_api::updateAttachmentMenuBots> AttachMenuManager::get_update_attachment_menu_bots_object() const {
CHECK(is_active());
CHECK(is_inited_);
auto bots =
transform(attach_menu_bots_, [this](const AttachMenuBot &bot) { return get_attach_menu_bot_object(bot); });
return td_api::make_object<td_api::updateAttachMenuBots>(std::move(bots));
transform(attach_menu_bots_, [this](const AttachMenuBot &bot) { return get_attachment_menu_bot_object(bot); });
return td_api::make_object<td_api::updateAttachmentMenuBots>(std::move(bots));
}
void AttachMenuManager::send_update_attach_menu_bots() const {
send_closure(G()->td(), &Td::send_update, get_update_attach_menu_bots_object());
send_closure(G()->td(), &Td::send_update, get_update_attachment_menu_bots_object());
}
string AttachMenuManager::get_attach_menu_bots_database_key() {
@ -912,7 +912,7 @@ void AttachMenuManager::get_current_state(vector<td_api::object_ptr<td_api::Upda
return;
}
updates.push_back(get_update_attach_menu_bots_object());
updates.push_back(get_update_attachment_menu_bots_object());
}
} // namespace td

View File

@ -41,7 +41,7 @@ class AttachMenuManager final : public Actor {
void reload_attach_menu_bots(Promise<Unit> &&promise);
void get_attach_menu_bot(UserId user_id, Promise<td_api::object_ptr<td_api::attachMenuBot>> &&promise);
void get_attach_menu_bot(UserId user_id, Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise);
void toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, Promise<Unit> &&promise);
@ -108,9 +108,9 @@ class AttachMenuManager final : public Actor {
Result<AttachMenuBot> get_attach_menu_bot(tl_object_ptr<telegram_api::attachMenuBot> &&bot) const;
td_api::object_ptr<td_api::attachMenuBot> get_attach_menu_bot_object(const AttachMenuBot &bot) const;
td_api::object_ptr<td_api::attachmentMenuBot> get_attachment_menu_bot_object(const AttachMenuBot &bot) const;
td_api::object_ptr<td_api::updateAttachMenuBots> get_update_attach_menu_bots_object() const;
td_api::object_ptr<td_api::updateAttachmentMenuBots> get_update_attachment_menu_bots_object() const;
void remove_bot_from_attach_menu(UserId user_id);
@ -125,7 +125,7 @@ class AttachMenuManager final : public Actor {
void on_get_attach_menu_bot(UserId user_id,
Result<telegram_api::object_ptr<telegram_api::attachMenuBotsBot>> &&result,
Promise<td_api::object_ptr<td_api::attachMenuBot>> &&promise);
Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise);
Td *td_;
ActorShared<> parent_;

View File

@ -8495,7 +8495,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
LOG_IF(ERROR, can_read_all_group_messages && !is_bot)
<< "Receive not bot " << user_id << " which can read all group messages from " << source;
LOG_IF(ERROR, can_be_added_to_attach_menu && !is_bot)
<< "Receive not bot " << user_id << " which can be added to attach menu from " << source;
<< "Receive not bot " << user_id << " which can be added to attachment menu from " << source;
LOG_IF(ERROR, is_inline_bot && !is_bot) << "Receive not bot " << user_id << " which is inline bot from " << source;
LOG_IF(ERROR, need_location_bot && !is_inline_bot)
<< "Receive not inline bot " << user_id << " which needs user location from " << source;

View File

@ -159,7 +159,7 @@ class LinkManager::InternalLinkAttachMenuBot final : public InternalLink {
string url_;
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeAttachMenuBot>(
return td_api::make_object<td_api::internalLinkTypeAttachmentMenuBot>(
dialog_link_ == nullptr ? nullptr : dialog_link_->get_internal_link_type_object(), bot_username_, url_);
}

View File

@ -6158,13 +6158,13 @@ void Td::on_request(uint64 id, const td_api::setPinnedChats &request) {
transform(request.chat_ids_, [](int64 chat_id) { return DialogId(chat_id); })));
}
void Td::on_request(uint64 id, const td_api::getAttachMenuBot &request) {
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
attach_menu_manager_->get_attach_menu_bot(UserId(request.bot_user_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleBotIsAddedToAttachMenu &request) {
void Td::on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
attach_menu_manager_->toggle_bot_is_added_to_attach_menu(UserId(request.bot_user_id_), request.is_added_,

View File

@ -846,9 +846,9 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::setPinnedChats &request);
void on_request(uint64 id, const td_api::getAttachMenuBot &request);
void on_request(uint64 id, const td_api::getAttachmentMenuBot &request);
void on_request(uint64 id, const td_api::toggleBotIsAddedToAttachMenu &request);
void on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request);
void on_request(uint64 id, td_api::setChatAvailableReactions &request);

View File

@ -3422,12 +3422,12 @@ class CliClient final : public Actor {
} else if (op == "gamb") {
UserId user_id;
get_args(args, user_id);
send_request(td_api::make_object<td_api::getAttachMenuBot>(user_id));
send_request(td_api::make_object<td_api::getAttachmentMenuBot>(user_id));
} else if (op == "tbiatam") {
UserId user_id;
bool is_added;
get_args(args, user_id, is_added);
send_request(td_api::make_object<td_api::toggleBotIsAddedToAttachMenu>(user_id, is_added));
send_request(td_api::make_object<td_api::toggleBotIsAddedToAttachmentMenu>(user_id, is_added));
} else if (op == "gwau") {
UserId user_id;
string url;

View File

@ -98,9 +98,9 @@ TEST(Link, parse_internal_link) {
auto active_sessions = [] {
return td::td_api::make_object<td::td_api::internalLinkTypeActiveSessions>();
};
auto attach_menu_bot = [](td::td_api::object_ptr<td::td_api::InternalLinkType> chat_link,
const td::string &bot_username, const td::string &start_parameter) {
return td::td_api::make_object<td::td_api::internalLinkTypeAttachMenuBot>(
auto attachment_menu_bot = [](td::td_api::object_ptr<td::td_api::InternalLinkType> chat_link,
const td::string &bot_username, const td::string &start_parameter) {
return td::td_api::make_object<td::td_api::internalLinkTypeAttachmentMenuBot>(
std::move(chat_link), bot_username, start_parameter.empty() ? td::string() : "start://" + start_parameter);
};
auto authentication_code = [](const td::string &code) {
@ -234,14 +234,15 @@ TEST(Link, parse_internal_link) {
parse_internal_link("tg:resolve?domain=telegram&post=&single", public_chat("telegram"));
parse_internal_link("tg:resolve?domain=123456&post=&single",
unknown_deep_link("tg://resolve?domain=123456&post=&single"));
parse_internal_link("tg:resolve?domain=telegram&startattach", attach_menu_bot(nullptr, "telegram", ""));
parse_internal_link("tg:resolve?domain=telegram&startattach=1", attach_menu_bot(nullptr, "telegram", "1"));
parse_internal_link("tg:resolve?domain=telegram&attach=&startattach", attach_menu_bot(nullptr, "telegram", ""));
parse_internal_link("tg:resolve?domain=telegram&attach=&startattach=1", attach_menu_bot(nullptr, "telegram", "1"));
parse_internal_link("tg:resolve?domain=telegram&startattach", attachment_menu_bot(nullptr, "telegram", ""));
parse_internal_link("tg:resolve?domain=telegram&startattach=1", attachment_menu_bot(nullptr, "telegram", "1"));
parse_internal_link("tg:resolve?domain=telegram&attach=&startattach", attachment_menu_bot(nullptr, "telegram", ""));
parse_internal_link("tg:resolve?domain=telegram&attach=&startattach=1",
attachment_menu_bot(nullptr, "telegram", "1"));
parse_internal_link("tg:resolve?domain=telegram&attach=test&startattach",
attach_menu_bot(public_chat("telegram"), "test", ""));
attachment_menu_bot(public_chat("telegram"), "test", ""));
parse_internal_link("tg:resolve?domain=telegram&attach=test&startattach=1",
attach_menu_bot(public_chat("telegram"), "test", "1"));
attachment_menu_bot(public_chat("telegram"), "test", "1"));
parse_internal_link("tg:resolve?phone=1", user_phone_number("1"));
parse_internal_link("tg:resolve?phone=123456", user_phone_number("123456"));
@ -250,11 +251,12 @@ TEST(Link, parse_internal_link) {
parse_internal_link("tg:resolve?phone=123456&attach=", user_phone_number("123456"));
parse_internal_link("tg:resolve?phone=123456&attach=&startattach", user_phone_number("123456"));
parse_internal_link("tg:resolve?phone=123456&attach=&startattach=123", user_phone_number("123456"));
parse_internal_link("tg:resolve?phone=123456&attach=test", attach_menu_bot(user_phone_number("123456"), "test", ""));
parse_internal_link("tg:resolve?phone=123456&attach=test",
attachment_menu_bot(user_phone_number("123456"), "test", ""));
parse_internal_link("tg:resolve?phone=123456&attach=test&startattach",
attach_menu_bot(user_phone_number("123456"), "test", ""));
attachment_menu_bot(user_phone_number("123456"), "test", ""));
parse_internal_link("tg:resolve?phone=123456&attach=test&startattach=123",
attach_menu_bot(user_phone_number("123456"), "test", "123"));
attachment_menu_bot(user_phone_number("123456"), "test", "123"));
parse_internal_link("tg:resolve?phone=01234567890123456789012345678912",
user_phone_number("01234567890123456789012345678912"));
parse_internal_link("tg:resolve?phone=012345678901234567890123456789123",
@ -279,14 +281,15 @@ TEST(Link, parse_internal_link) {
parse_internal_link("t.me/username/-12345", public_chat("username"));
parse_internal_link("t.me//12345?single", nullptr);
parse_internal_link("https://telegram.dog/telegram/?single", public_chat("telegram"));
parse_internal_link("t.me/username?startattach", attach_menu_bot(nullptr, "username", ""));
parse_internal_link("t.me/username?startattach=1", attach_menu_bot(nullptr, "username", "1"));
parse_internal_link("t.me/username?startattach", attachment_menu_bot(nullptr, "username", ""));
parse_internal_link("t.me/username?startattach=1", attachment_menu_bot(nullptr, "username", "1"));
parse_internal_link("t.me/username?attach=", public_chat("username"));
parse_internal_link("t.me/username?attach=&startattach", attach_menu_bot(nullptr, "username", ""));
parse_internal_link("t.me/username?attach=&startattach=1", attach_menu_bot(nullptr, "username", "1"));
parse_internal_link("t.me/username?attach=bot", attach_menu_bot(public_chat("username"), "bot", ""));
parse_internal_link("t.me/username?attach=bot&startattach", attach_menu_bot(public_chat("username"), "bot", ""));
parse_internal_link("t.me/username?attach=bot&startattach=1", attach_menu_bot(public_chat("username"), "bot", "1"));
parse_internal_link("t.me/username?attach=&startattach", attachment_menu_bot(nullptr, "username", ""));
parse_internal_link("t.me/username?attach=&startattach=1", attachment_menu_bot(nullptr, "username", "1"));
parse_internal_link("t.me/username?attach=bot", attachment_menu_bot(public_chat("username"), "bot", ""));
parse_internal_link("t.me/username?attach=bot&startattach", attachment_menu_bot(public_chat("username"), "bot", ""));
parse_internal_link("t.me/username?attach=bot&startattach=1",
attachment_menu_bot(public_chat("username"), "bot", "1"));
parse_internal_link("tg:privatepost?domain=username/12345&single",
unknown_deep_link("tg://privatepost?domain=username/12345&single"));
@ -454,10 +457,11 @@ TEST(Link, parse_internal_link) {
parse_internal_link("t.me/+123456?attach=", user_phone_number("123456"));
parse_internal_link("t.me/+123456?attach=&startattach", user_phone_number("123456"));
parse_internal_link("t.me/+123456?attach=&startattach=1", user_phone_number("123456"));
parse_internal_link("t.me/+123456?attach=bot", attach_menu_bot(user_phone_number("123456"), "bot", ""));
parse_internal_link("t.me/+123456?attach=bot&startattach", attach_menu_bot(user_phone_number("123456"), "bot", ""));
parse_internal_link("t.me/+123456?attach=bot", attachment_menu_bot(user_phone_number("123456"), "bot", ""));
parse_internal_link("t.me/+123456?attach=bot&startattach",
attachment_menu_bot(user_phone_number("123456"), "bot", ""));
parse_internal_link("t.me/+123456?attach=bot&startattach=1",
attach_menu_bot(user_phone_number("123456"), "bot", "1"));
attachment_menu_bot(user_phone_number("123456"), "bot", "1"));
parse_internal_link("tg:join?invite=abcdef", chat_invite("abcdef"));
parse_internal_link("tg:join?invite=abc%20def", chat_invite("abc%20def"));