From e28828fb9760bfebf2d33bf9cadfb095b255c425 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 11 May 2022 19:30:35 +0300 Subject: [PATCH] Add user.added_to_attachment_menu flag. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/ContactsManager.cpp | 10 +++++++--- td/telegram/ContactsManager.h | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 45f92fa1e..260beb75e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -471,7 +471,8 @@ chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messa //@have_access If false, the user is inaccessible, and the only information known about the user is inside this class. Identifier of the user can't be passed to any method except GetUser //@type Type of the user //@language_code IETF language tag of the user's language; only available to bots -user id:int53 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string = User; +//@added_to_attachment_menu True, if the user added the current bot to attachment menu; only available to bots +user id:int53 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User; //@description Contains information about a bot //@share_text The text that is shown on the bot's profile page and is sent together with the link when users share the bot diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index d541046c1..15d21da35 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -3630,6 +3630,7 @@ void ContactsManager::User::store(StorerT &storer) const { STORE_FLAG(is_fake); STORE_FLAG(can_be_added_to_attach_menu); STORE_FLAG(is_premium); // 25 + STORE_FLAG(attach_menu_enabled); END_STORE_FLAGS(); store(first_name, storer); if (has_last_name) { @@ -3702,6 +3703,7 @@ void ContactsManager::User::parse(ParserT &parser) { PARSE_FLAG(is_fake); PARSE_FLAG(can_be_added_to_attach_menu); PARSE_FLAG(is_premium); + PARSE_FLAG(attach_menu_enabled); END_PARSE_FLAGS(); parse(first_name, parser); if (has_last_name) { @@ -8638,6 +8640,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, bool can_join_groups = (flags & USER_FLAG_IS_PRIVATE_BOT) == 0; bool can_read_all_group_messages = (flags & USER_FLAG_IS_BOT_WITH_PRIVACY_DISABLED) != 0; bool can_be_added_to_attach_menu = (flags & USER_FLAG_IS_ATTACH_MENU_BOT) != 0; + bool attach_menu_enabled = (flags & USER_FLAG_ATTACH_MENU_ENABLED) != 0; auto restriction_reasons = get_restriction_reasons(std::move(user->restriction_reason_)); bool is_scam = (flags & USER_FLAG_IS_SCAM) != 0; bool is_inline_bot = (flags & USER_FLAG_IS_INLINE_BOT) != 0; @@ -8682,7 +8685,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, can_read_all_group_messages != u->can_read_all_group_messages || restriction_reasons != u->restriction_reasons || is_scam != u->is_scam || is_fake != u->is_fake || is_inline_bot != u->is_inline_bot || inline_query_placeholder != u->inline_query_placeholder || need_location_bot != u->need_location_bot || - can_be_added_to_attach_menu != u->can_be_added_to_attach_menu) { + can_be_added_to_attach_menu != u->can_be_added_to_attach_menu || attach_menu_enabled != u->attach_menu_enabled) { LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted && u->is_received) << "User.is_bot has changed for " << user_id << "/" << u->username << " from " << source << " from " << u->is_bot << " to " << is_bot; @@ -8699,6 +8702,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, u->inline_query_placeholder = std::move(inline_query_placeholder); u->need_location_bot = need_location_bot; u->can_be_added_to_attach_menu = can_be_added_to_attach_menu; + u->attach_menu_enabled = attach_menu_enabled; LOG(DEBUG) << "Info has changed for " << user_id; u->is_changed = true; @@ -16589,7 +16593,7 @@ td_api::object_ptr ContactsManager::get_user_status_object(U td_api::object_ptr ContactsManager::get_update_unknown_user_object(UserId user_id) { return td_api::make_object(td_api::make_object( user_id.get(), "", "", "", "", td_api::make_object(), nullptr, false, false, false, - false, false, "", false, false, false, td_api::make_object(), "")); + false, false, "", false, false, false, td_api::make_object(), "", false)); } int64 ContactsManager::get_user_id_object(UserId user_id, const char *source) const { @@ -16624,7 +16628,7 @@ tl_object_ptr ContactsManager::get_user_object(UserId user_id, con user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u), get_profile_photo_object(td_->file_manager_.get(), u->photo), u->is_contact, u->is_mutual_contact, u->is_verified, u->is_premium, u->is_support, get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake, - u->is_received, std::move(type), u->language_code); + u->is_received, std::move(type), u->language_code, u->attach_menu_enabled); } vector ContactsManager::get_user_ids_object(const vector &user_ids, const char *source) const { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 49ce6c31a..3d9dbc64a 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -670,6 +670,7 @@ class ContactsManager final : public Actor { bool is_mutual_contact = false; bool need_apply_min_photo = false; bool can_be_added_to_attach_menu = false; + bool attach_menu_enabled = false; bool is_photo_inited = false; @@ -1056,6 +1057,7 @@ class ContactsManager final : public Actor { static constexpr int32 USER_FLAG_IS_FAKE = 1 << 26; static constexpr int32 USER_FLAG_IS_ATTACH_MENU_BOT = 1 << 27; static constexpr int32 USER_FLAG_IS_PREMIUM = 1 << 28; + static constexpr int32 USER_FLAG_ATTACH_MENU_ENABLED = 1 << 29; static constexpr int32 USER_FULL_FLAG_IS_BLOCKED = 1 << 0; static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1;