Add userTypeBot.can_be_edited.

This commit is contained in:
levlam 2023-03-28 16:26:42 +03:00
parent a487c08eca
commit aec7d5a26f
3 changed files with 20 additions and 7 deletions

View File

@ -533,13 +533,14 @@ userTypeRegular = UserType;
userTypeDeleted = UserType;
//@description A bot (see https://core.telegram.org/bots)
//@can_be_edited True, if the bot is owned by the current user and can be edited using the methods toggleBotUsernameIsActive, reorderBotActiveUsernames, setBotProfilePhoto, setBotName, setBotInfoDescription, and setBotInfoShortDescription
//@can_join_groups True, if the bot can be invited to basic group and supergroup chats
//@can_read_all_group_messages True, if the bot can read all messages in basic group or supergroup chats and not just those addressed to the bot. In private and channel chats a bot can always read all messages
//@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_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;
userTypeBot can_be_edited:Bool 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;

View File

@ -4296,6 +4296,7 @@ void ContactsManager::User::store(StorerT &storer) const {
STORE_FLAG(attach_menu_enabled);
STORE_FLAG(has_emoji_status);
STORE_FLAG(has_usernames);
STORE_FLAG(can_be_edited_bot);
END_STORE_FLAGS();
store(first_name, storer);
if (has_last_name) {
@ -4376,6 +4377,7 @@ void ContactsManager::User::parse(ParserT &parser) {
PARSE_FLAG(attach_menu_enabled);
PARSE_FLAG(has_emoji_status);
PARSE_FLAG(has_usernames);
PARSE_FLAG(can_be_edited_bot);
END_PARSE_FLAGS();
parse(first_name, parser);
if (has_last_name) {
@ -9902,7 +9904,8 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
return;
}
int32 flags = user->flags_;
LOG(INFO) << "Receive " << user_id << " with flags " << flags << " from " << source;
int32 flags2 = user->flags2_;
LOG(INFO) << "Receive " << user_id << " with flags " << flags << ' ' << flags2 << " from " << source;
if (is_me && (flags & USER_FLAG_IS_ME) == 0) {
LOG(ERROR) << user_id << " doesn't have flag IS_ME, but must have it when received from " << source;
flags |= USER_FLAG_IS_ME;
@ -9977,6 +9980,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
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 can_be_edited_bot = (flags2 & USER_FLAG_CAN_BE_EDITED_BOT) != 0;
bool is_inline_bot = (flags & USER_FLAG_IS_INLINE_BOT) != 0;
string inline_query_placeholder = user->bot_inline_placeholder_;
bool need_location_bot = (flags & USER_FLAG_NEED_LOCATION_BOT) != 0;
@ -9990,6 +9994,8 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
<< "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 attachment menu from " << source;
LOG_IF(ERROR, can_be_edited_bot && !is_bot)
<< "Receive not bot " << user_id << " which is inline bot 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;
@ -10003,6 +10009,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
can_join_groups = false;
can_read_all_group_messages = false;
can_be_added_to_attach_menu = false;
can_be_edited_bot = false;
is_inline_bot = false;
inline_query_placeholder = string();
need_location_bot = false;
@ -10017,9 +10024,9 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
if (is_verified != u->is_verified || is_support != u->is_support || is_bot != u->is_bot ||
can_join_groups != u->can_join_groups || 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 ||
attach_menu_enabled != u->attach_menu_enabled) {
can_be_edited_bot != u->can_be_edited_bot || 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 || 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->usernames << " from " << source << " from "
<< u->is_bot << " to " << is_bot;
@ -10031,6 +10038,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
u->restriction_reasons = std::move(restriction_reasons);
u->is_scam = is_scam;
u->is_fake = is_fake;
u->can_be_edited_bot = can_be_edited_bot;
u->is_inline_bot = is_inline_bot;
u->inline_query_placeholder = std::move(inline_query_placeholder);
u->need_location_bot = need_location_bot;
@ -15926,6 +15934,7 @@ Result<ContactsManager::BotData> ContactsManager::get_bot_data(UserId user_id) c
BotData bot_data;
bot_data.username = u->usernames.get_first_username();
bot_data.can_be_edited = u->can_be_edited_bot;
bot_data.can_join_groups = u->can_join_groups;
bot_data.can_read_all_group_messages = u->can_read_all_group_messages;
bot_data.is_inline = u->is_inline_bot;
@ -18315,8 +18324,8 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
if (u->is_deleted) {
type = make_tl_object<td_api::userTypeDeleted>();
} else if (u->is_bot) {
type = make_tl_object<td_api::userTypeBot>(u->can_join_groups, u->can_read_all_group_messages, u->is_inline_bot,
u->inline_query_placeholder, u->need_location_bot,
type = make_tl_object<td_api::userTypeBot>(u->can_be_edited_bot, u->can_join_groups, u->can_read_all_group_messages,
u->is_inline_bot, u->inline_query_placeholder, u->need_location_bot,
u->can_be_added_to_attach_menu);
} else {
type = make_tl_object<td_api::userTypeRegular>();

View File

@ -539,6 +539,7 @@ class ContactsManager final : public Actor {
struct BotData {
string username;
bool can_be_edited;
bool can_join_groups;
bool can_read_all_group_messages;
bool is_inline;
@ -751,6 +752,7 @@ class ContactsManager final : public Actor {
bool is_bot = true;
bool can_join_groups = true;
bool can_read_all_group_messages = true;
bool can_be_edited_bot = false;
bool is_inline_bot = false;
bool need_location_bot = false;
bool is_scam = false;
@ -1168,6 +1170,7 @@ class ContactsManager final : public Actor {
static constexpr int32 USER_FLAG_ATTACH_MENU_ENABLED = 1 << 29;
static constexpr int32 USER_FLAG_HAS_EMOJI_STATUS = 1 << 30;
static constexpr int32 USER_FLAG_HAS_USERNAMES = 1 << 0;
static constexpr int32 USER_FLAG_CAN_BE_EDITED_BOT = 1 << 1;
static constexpr int32 USER_FULL_FLAG_IS_BLOCKED = 1 << 0;
static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1;