Add toggleBotIsAddedToAttachmentMenu.allow_write_access.

This commit is contained in:
levlam 2022-12-15 14:21:22 +03:00
parent cc52263026
commit 743ba7cc28
5 changed files with 20 additions and 9 deletions

View File

@ -6597,8 +6597,11 @@ setPinnedChats chat_list:ChatList chat_ids:vector<int53> = Ok;
//@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 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 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
//@allow_write_access Pass true if the current user allowed the bot to send them messages. Ignored if is_added is false
toggleBotIsAddedToAttachmentMenu bot_user_id:int53 is_added:Bool allow_write_access:Bool = Ok;
//@description Returns up to 8 themed emoji statuses, which color must be changed to the color of the Telegram Premium badge

View File

@ -257,8 +257,11 @@ class ToggleBotInAttachMenuQuery final : public Td::ResultHandler {
explicit ToggleBotInAttachMenuQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(tl_object_ptr<telegram_api::InputUser> &&input_user, bool is_added) {
void send(tl_object_ptr<telegram_api::InputUser> &&input_user, bool is_added, bool allow_write_access) {
int32 flags = 0;
if (is_added && allow_write_access) {
flags |= telegram_api::messages_toggleBotInAttachMenu::WRITE_ALLOWED_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::messages_toggleBotInAttachMenu(flags, false /*ignored*/, std::move(input_user), is_added)));
}
@ -996,7 +999,8 @@ FileSourceId AttachMenuManager::get_attach_menu_bot_file_source_id(UserId user_i
return source_id;
}
void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, Promise<Unit> &&promise) {
void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, bool allow_write_access,
Promise<Unit> &&promise) {
CHECK(is_active());
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
@ -1030,7 +1034,8 @@ 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_->create_handler<ToggleBotInAttachMenuQuery>(std::move(query_promise))
->send(std::move(input_user), is_added, allow_write_access);
}
td_api::object_ptr<td_api::attachmentMenuBot> AttachMenuManager::get_attachment_menu_bot_object(

View File

@ -50,7 +50,8 @@ class AttachMenuManager final : public Actor {
FileSourceId get_attach_menu_bot_file_source_id(UserId user_id);
void toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, Promise<Unit> &&promise);
void toggle_bot_is_added_to_attach_menu(UserId user_id, bool is_added, bool allow_write_access,
Promise<Unit> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;

View File

@ -6212,7 +6212,7 @@ void Td::on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &r
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_,
std::move(promise));
request.allow_write_access_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::setChatAvailableReactions &request) {

View File

@ -3641,8 +3641,10 @@ class CliClient final : public Actor {
} 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::toggleBotIsAddedToAttachmentMenu>(user_id, is_added));
bool allow_write_access;
get_args(args, user_id, is_added, allow_write_access);
send_request(
td_api::make_object<td_api::toggleBotIsAddedToAttachmentMenu>(user_id, is_added, allow_write_access));
} else if (op == "gwau") {
UserId user_id;
string url;