Add default administrator rights to botInfo.
This commit is contained in:
parent
ef8d959e98
commit
afa00d8b00
@ -419,56 +419,6 @@ inputChatPhotoStatic photo:InputFile = InputChatPhoto;
|
|||||||
inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputChatPhoto;
|
inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputChatPhoto;
|
||||||
|
|
||||||
|
|
||||||
//@description Represents a user
|
|
||||||
//@id User identifier
|
|
||||||
//@first_name First name of the user
|
|
||||||
//@last_name Last name of the user
|
|
||||||
//@username Username of the user
|
|
||||||
//@phone_number Phone number of the user
|
|
||||||
//@status Current online status of the user
|
|
||||||
//@profile_photo Profile photo of the user; may be null
|
|
||||||
//@is_contact The user is a contact of the current user
|
|
||||||
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
|
||||||
//@is_verified True, if the user is verified
|
|
||||||
//@is_support True, if the user is Telegram support account
|
|
||||||
//@restriction_reason If non-empty, it contains a human-readable description of the reason why access to this user must be restricted
|
|
||||||
//@is_scam True, if many users reported this user as a scam
|
|
||||||
//@is_fake True, if many users reported this user as a fake account
|
|
||||||
//@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_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string = 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
|
|
||||||
//@param_description The text shown in the chat with the bot if the chat is empty
|
|
||||||
//@commands List of the bot commands
|
|
||||||
botInfo share_text:string description:string commands:vector<botCommand> = BotInfo;
|
|
||||||
|
|
||||||
//@description Contains full information about a user
|
|
||||||
//@photo User profile photo; may be null
|
|
||||||
//@is_blocked True, if the user is blocked by the current user
|
|
||||||
//@can_be_called True, if the user can be called
|
|
||||||
//@supports_video_calls True, if a video call can be created with the user
|
|
||||||
//@has_private_calls True, if the user can't be called due to their privacy settings
|
|
||||||
//@has_private_forwards True, if the user can't be linked in forwarded messages due to their privacy settings
|
|
||||||
//@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used
|
|
||||||
//@bio A short user bio
|
|
||||||
//@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user
|
|
||||||
//@bot_info For bots, information about the bot; may be null
|
|
||||||
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool need_phone_number_privacy_exception:Bool bio:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
|
|
||||||
|
|
||||||
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
|
|
||||||
users total_count:int32 user_ids:vector<int53> = Users;
|
|
||||||
|
|
||||||
|
|
||||||
//@description Contains information about a chat administrator @user_id User identifier of the administrator @custom_title Custom title of the administrator @is_owner True, if the user is the owner of the chat
|
|
||||||
chatAdministrator user_id:int53 custom_title:string is_owner:Bool = ChatAdministrator;
|
|
||||||
|
|
||||||
//@description Represents a list of chat administrators @administrators A list of chat administrators
|
|
||||||
chatAdministrators administrators:vector<chatAdministrator> = ChatAdministrators;
|
|
||||||
|
|
||||||
|
|
||||||
//@description Describes actions that a user is allowed to take in a chat
|
//@description Describes actions that a user is allowed to take in a chat
|
||||||
//@can_send_messages True, if the user can send text messages, contacts, locations, and venues
|
//@can_send_messages True, if the user can send text messages, contacts, locations, and venues
|
||||||
//@can_send_media_messages True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions
|
//@can_send_media_messages True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions
|
||||||
@ -495,6 +445,58 @@ chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_pol
|
|||||||
chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool can_manage_video_chats:Bool is_anonymous:Bool = ChatAdministratorRights;
|
chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool can_manage_video_chats:Bool is_anonymous:Bool = ChatAdministratorRights;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Represents a user
|
||||||
|
//@id User identifier
|
||||||
|
//@first_name First name of the user
|
||||||
|
//@last_name Last name of the user
|
||||||
|
//@username Username of the user
|
||||||
|
//@phone_number Phone number of the user
|
||||||
|
//@status Current online status of the user
|
||||||
|
//@profile_photo Profile photo of the user; may be null
|
||||||
|
//@is_contact The user is a contact of the current user
|
||||||
|
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
||||||
|
//@is_verified True, if the user is verified
|
||||||
|
//@is_support True, if the user is Telegram support account
|
||||||
|
//@restriction_reason If non-empty, it contains a human-readable description of the reason why access to this user must be restricted
|
||||||
|
//@is_scam True, if many users reported this user as a scam
|
||||||
|
//@is_fake True, if many users reported this user as a fake account
|
||||||
|
//@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_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string = 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
|
||||||
|
//@param_description The text shown in the chat with the bot if the chat is empty
|
||||||
|
//@commands List of the bot commands
|
||||||
|
//@default_group_administrator_rights Default administrator rights for adding the bot to basic groups and supergroups; may be null
|
||||||
|
//@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null
|
||||||
|
botInfo share_text:string description:string commands:vector<botCommand> default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights = BotInfo;
|
||||||
|
|
||||||
|
//@description Contains full information about a user
|
||||||
|
//@photo User profile photo; may be null
|
||||||
|
//@is_blocked True, if the user is blocked by the current user
|
||||||
|
//@can_be_called True, if the user can be called
|
||||||
|
//@supports_video_calls True, if a video call can be created with the user
|
||||||
|
//@has_private_calls True, if the user can't be called due to their privacy settings
|
||||||
|
//@has_private_forwards True, if the user can't be linked in forwarded messages due to their privacy settings
|
||||||
|
//@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used
|
||||||
|
//@bio A short user bio
|
||||||
|
//@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user
|
||||||
|
//@bot_info For bots, information about the bot; may be null
|
||||||
|
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool need_phone_number_privacy_exception:Bool bio:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
|
||||||
|
|
||||||
|
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
|
||||||
|
users total_count:int32 user_ids:vector<int53> = Users;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Contains information about a chat administrator @user_id User identifier of the administrator @custom_title Custom title of the administrator @is_owner True, if the user is the owner of the chat
|
||||||
|
chatAdministrator user_id:int53 custom_title:string is_owner:Bool = ChatAdministrator;
|
||||||
|
|
||||||
|
//@description Represents a list of chat administrators @administrators A list of chat administrators
|
||||||
|
chatAdministrators administrators:vector<chatAdministrator> = ChatAdministrators;
|
||||||
|
|
||||||
|
|
||||||
//@class ChatMemberStatus @description Provides information about the status of a member in a chat
|
//@class ChatMemberStatus @description Provides information about the status of a member in a chat
|
||||||
|
|
||||||
//@description The user is the owner of the chat and has all the administrator privileges
|
//@description The user is the owner of the chat and has all the administrator privileges
|
||||||
|
@ -3691,6 +3691,8 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
|||||||
bool has_description = !description.empty();
|
bool has_description = !description.empty();
|
||||||
bool has_commands = !commands.empty();
|
bool has_commands = !commands.empty();
|
||||||
bool has_private_forward_name = !private_forward_name.empty();
|
bool has_private_forward_name = !private_forward_name.empty();
|
||||||
|
bool has_group_administrator_rights = group_administrator_rights != AdministratorRights();
|
||||||
|
bool has_broadcast_administrator_rights = broadcast_administrator_rights != AdministratorRights();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_about);
|
STORE_FLAG(has_about);
|
||||||
STORE_FLAG(is_blocked);
|
STORE_FLAG(is_blocked);
|
||||||
@ -3703,6 +3705,8 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(has_description);
|
STORE_FLAG(has_description);
|
||||||
STORE_FLAG(has_commands);
|
STORE_FLAG(has_commands);
|
||||||
STORE_FLAG(has_private_forward_name);
|
STORE_FLAG(has_private_forward_name);
|
||||||
|
STORE_FLAG(has_group_administrator_rights);
|
||||||
|
STORE_FLAG(has_broadcast_administrator_rights);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
if (has_about) {
|
if (has_about) {
|
||||||
store(about, storer);
|
store(about, storer);
|
||||||
@ -3721,6 +3725,12 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
|||||||
if (has_private_forward_name) {
|
if (has_private_forward_name) {
|
||||||
store(private_forward_name, storer);
|
store(private_forward_name, storer);
|
||||||
}
|
}
|
||||||
|
if (has_group_administrator_rights) {
|
||||||
|
store(group_administrator_rights, storer);
|
||||||
|
}
|
||||||
|
if (has_broadcast_administrator_rights) {
|
||||||
|
store(broadcast_administrator_rights, storer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
@ -3731,6 +3741,8 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
|||||||
bool has_description;
|
bool has_description;
|
||||||
bool has_commands;
|
bool has_commands;
|
||||||
bool has_private_forward_name;
|
bool has_private_forward_name;
|
||||||
|
bool has_group_administrator_rights;
|
||||||
|
bool has_broadcast_administrator_rights;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_about);
|
PARSE_FLAG(has_about);
|
||||||
PARSE_FLAG(is_blocked);
|
PARSE_FLAG(is_blocked);
|
||||||
@ -3743,6 +3755,8 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(has_description);
|
PARSE_FLAG(has_description);
|
||||||
PARSE_FLAG(has_commands);
|
PARSE_FLAG(has_commands);
|
||||||
PARSE_FLAG(has_private_forward_name);
|
PARSE_FLAG(has_private_forward_name);
|
||||||
|
PARSE_FLAG(has_group_administrator_rights);
|
||||||
|
PARSE_FLAG(has_broadcast_administrator_rights);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
if (has_about) {
|
if (has_about) {
|
||||||
parse(about, parser);
|
parse(about, parser);
|
||||||
@ -3761,6 +3775,12 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
|||||||
if (has_private_forward_name) {
|
if (has_private_forward_name) {
|
||||||
parse(private_forward_name, parser);
|
parse(private_forward_name, parser);
|
||||||
}
|
}
|
||||||
|
if (has_group_administrator_rights) {
|
||||||
|
parse(group_administrator_rights, parser);
|
||||||
|
}
|
||||||
|
if (has_broadcast_administrator_rights) {
|
||||||
|
parse(broadcast_administrator_rights, parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
@ -10503,13 +10523,19 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
|||||||
bool can_be_called = user->phone_calls_available_ && !user->phone_calls_private_;
|
bool can_be_called = user->phone_calls_available_ && !user->phone_calls_private_;
|
||||||
bool supports_video_calls = user->video_calls_available_ && !user->phone_calls_private_;
|
bool supports_video_calls = user->video_calls_available_ && !user->phone_calls_private_;
|
||||||
bool has_private_calls = user->phone_calls_private_;
|
bool has_private_calls = user->phone_calls_private_;
|
||||||
|
auto group_administrator_rights = get_administrator_rights(std::move(user->bot_group_admin_rights_));
|
||||||
|
auto broadcast_administrator_rights = get_administrator_rights(std::move(user->bot_broadcast_admin_rights_));
|
||||||
if (user_full->can_be_called != can_be_called || user_full->supports_video_calls != supports_video_calls ||
|
if (user_full->can_be_called != can_be_called || user_full->supports_video_calls != supports_video_calls ||
|
||||||
user_full->has_private_calls != has_private_calls ||
|
user_full->has_private_calls != has_private_calls ||
|
||||||
user_full->private_forward_name != user->private_forward_name_) {
|
user_full->private_forward_name != user->private_forward_name_ ||
|
||||||
|
user_full->group_administrator_rights != group_administrator_rights ||
|
||||||
|
user_full->broadcast_administrator_rights != broadcast_administrator_rights) {
|
||||||
user_full->can_be_called = can_be_called;
|
user_full->can_be_called = can_be_called;
|
||||||
user_full->supports_video_calls = supports_video_calls;
|
user_full->supports_video_calls = supports_video_calls;
|
||||||
user_full->has_private_calls = has_private_calls;
|
user_full->has_private_calls = has_private_calls;
|
||||||
user_full->private_forward_name = std::move(user->private_forward_name_);
|
user_full->private_forward_name = std::move(user->private_forward_name_);
|
||||||
|
user_full->group_administrator_rights = group_administrator_rights;
|
||||||
|
user_full->broadcast_administrator_rights = broadcast_administrator_rights;
|
||||||
|
|
||||||
user_full->is_changed = true;
|
user_full->is_changed = true;
|
||||||
}
|
}
|
||||||
@ -11754,6 +11780,8 @@ void ContactsManager::drop_user_full(UserId user_id) {
|
|||||||
user_full->commands.clear();
|
user_full->commands.clear();
|
||||||
user_full->common_chat_count = 0;
|
user_full->common_chat_count = 0;
|
||||||
user_full->private_forward_name.clear();
|
user_full->private_forward_name.clear();
|
||||||
|
user_full->group_administrator_rights = {};
|
||||||
|
user_full->broadcast_administrator_rights = {};
|
||||||
user_full->is_changed = true;
|
user_full->is_changed = true;
|
||||||
|
|
||||||
update_user_full(user_full, user_id, "drop_user_full");
|
update_user_full(user_full, user_id, "drop_user_full");
|
||||||
@ -16226,7 +16254,14 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
|||||||
if (is_bot) {
|
if (is_bot) {
|
||||||
auto commands =
|
auto commands =
|
||||||
transform(user_full->commands, [](const auto &command) { return command.get_bot_command_object(); });
|
transform(user_full->commands, [](const auto &command) { return command.get_bot_command_object(); });
|
||||||
bot_info = td_api::make_object<td_api::botInfo>(user_full->about, user_full->description, std::move(commands));
|
bot_info = td_api::make_object<td_api::botInfo>(
|
||||||
|
user_full->about, user_full->description, std::move(commands),
|
||||||
|
user_full->group_administrator_rights == AdministratorRights()
|
||||||
|
? nullptr
|
||||||
|
: user_full->group_administrator_rights.get_chat_administrator_rights_object(),
|
||||||
|
user_full->broadcast_administrator_rights == AdministratorRights()
|
||||||
|
? nullptr
|
||||||
|
: user_full->broadcast_administrator_rights.get_chat_administrator_rights_object());
|
||||||
}
|
}
|
||||||
return make_tl_object<td_api::userFullInfo>(
|
return make_tl_object<td_api::userFullInfo>(
|
||||||
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
|
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
|
||||||
|
@ -695,6 +695,8 @@ class ContactsManager final : public Actor {
|
|||||||
string private_forward_name;
|
string private_forward_name;
|
||||||
|
|
||||||
vector<BotCommand> commands;
|
vector<BotCommand> commands;
|
||||||
|
AdministratorRights group_administrator_rights;
|
||||||
|
AdministratorRights broadcast_administrator_rights;
|
||||||
|
|
||||||
int32 common_chat_count = 0;
|
int32 common_chat_count = 0;
|
||||||
|
|
||||||
@ -1040,6 +1042,8 @@ class ContactsManager final : public Actor {
|
|||||||
static constexpr int32 USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES = 1 << 12;
|
static constexpr int32 USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES = 1 << 12;
|
||||||
static constexpr int32 USER_FULL_FLAG_HAS_MESSAGE_TTL = 1 << 14;
|
static constexpr int32 USER_FULL_FLAG_HAS_MESSAGE_TTL = 1 << 14;
|
||||||
static constexpr int32 USER_FULL_FLAG_HAS_PRIVATE_FORWARD_NAME = 1 << 16;
|
static constexpr int32 USER_FULL_FLAG_HAS_PRIVATE_FORWARD_NAME = 1 << 16;
|
||||||
|
static constexpr int32 USER_FULL_FLAG_HAS_GROUP_ADMINISTRATOR_RIGHTS = 1 << 17;
|
||||||
|
static constexpr int32 USER_FULL_FLAG_HAS_BROADCAST_ADMINISTRATOR_RIGHTS = 1 << 18;
|
||||||
|
|
||||||
static constexpr int32 CHAT_FLAG_USER_IS_CREATOR = 1 << 0;
|
static constexpr int32 CHAT_FLAG_USER_IS_CREATOR = 1 << 0;
|
||||||
static constexpr int32 CHAT_FLAG_USER_HAS_LEFT = 1 << 2;
|
static constexpr int32 CHAT_FLAG_USER_HAS_LEFT = 1 << 2;
|
||||||
|
@ -544,7 +544,7 @@ DialogParticipantStatus get_dialog_participant_status(const tl_object_ptr<td_api
|
|||||||
|
|
||||||
AdministratorRights get_administrator_rights(tl_object_ptr<telegram_api::chatAdminRights> &&admin_rights) {
|
AdministratorRights get_administrator_rights(tl_object_ptr<telegram_api::chatAdminRights> &&admin_rights) {
|
||||||
if (admin_rights == nullptr) {
|
if (admin_rights == nullptr) {
|
||||||
return AdministratorRights(false, false, false, false, false, false, false, false, false, false, false);
|
return AdministratorRights();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!admin_rights->other_) {
|
if (!admin_rights->other_) {
|
||||||
@ -558,7 +558,7 @@ AdministratorRights get_administrator_rights(tl_object_ptr<telegram_api::chatAdm
|
|||||||
|
|
||||||
AdministratorRights get_administrator_rights(const td_api::object_ptr<td_api::chatAdministratorRights> &rights) {
|
AdministratorRights get_administrator_rights(const td_api::object_ptr<td_api::chatAdministratorRights> &rights) {
|
||||||
if (rights == nullptr) {
|
if (rights == nullptr) {
|
||||||
return AdministratorRights(false, false, false, false, false, false, false, false, false, false, false);
|
return AdministratorRights();
|
||||||
}
|
}
|
||||||
return AdministratorRights(rights->is_anonymous_, rights->can_manage_chat_, rights->can_change_info_,
|
return AdministratorRights(rights->is_anonymous_, rights->can_manage_chat_, rights->can_change_info_,
|
||||||
rights->can_post_messages_, rights->can_edit_messages_, rights->can_delete_messages_,
|
rights->can_post_messages_, rights->can_edit_messages_, rights->can_delete_messages_,
|
||||||
|
@ -47,6 +47,9 @@ class AdministratorRights {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
AdministratorRights() : flags_(0) {
|
||||||
|
}
|
||||||
|
|
||||||
AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages,
|
AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages,
|
||||||
bool can_edit_messages, bool can_delete_messages, bool can_invite_users,
|
bool can_edit_messages, bool can_delete_messages, bool can_invite_users,
|
||||||
bool can_restrict_members, bool can_pin_messages, bool can_promote_members,
|
bool can_restrict_members, bool can_pin_messages, bool can_promote_members,
|
||||||
|
Loading…
Reference in New Issue
Block a user