Replace botInfo with commands in userFullInfo.
This commit is contained in:
parent
f165429143
commit
5f9fd502b7
@ -425,8 +425,8 @@ user id:int32 first_name:string last_name:string username:string phone_number:st
|
||||
//@share_text For bots, 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 For bots, the text shown in the chat with the bot if the chat is empty
|
||||
//@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 If the user is a bot, 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 need_phone_number_privacy_exception:Bool bio:string share_text:string description:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
|
||||
//@commands For bots, list of the bot commands
|
||||
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string description:string group_in_common_count:int32 commands:vector<botCommand> = UserFullInfo;
|
||||
|
||||
//@description Represents a list of users @total_count Approximate total count of users found @user_ids A list of user identifiers
|
||||
users total_count:int32 user_ids:vector<int32> = Users;
|
||||
|
@ -23,6 +23,10 @@ td_api::object_ptr<td_api::botCommand> BotCommand::get_bot_command_object() cons
|
||||
return td_api::make_object<td_api::botCommand>(command_, description_);
|
||||
}
|
||||
|
||||
bool operator==(const BotCommand &lhs, const BotCommand &rhs) {
|
||||
return lhs.command_ == rhs.command_ && lhs.description_ == rhs.description_;
|
||||
}
|
||||
|
||||
BotCommands::BotCommands(UserId bot_user_id, vector<telegram_api::object_ptr<telegram_api::botCommand>> &&bot_commands)
|
||||
: bot_user_id_(bot_user_id) {
|
||||
commands_ = transform(std::move(bot_commands), [](telegram_api::object_ptr<telegram_api::botCommand> &&bot_command) {
|
||||
@ -36,4 +40,8 @@ td_api::object_ptr<td_api::botCommands> BotCommands::get_bot_commands_object(Td
|
||||
td->contacts_manager_->get_user_id_object(bot_user_id_, "get_bot_commands_object"), std::move(commands));
|
||||
}
|
||||
|
||||
bool operator==(const BotCommands &lhs, const BotCommands &rhs) {
|
||||
return lhs.bot_user_id_ == rhs.bot_user_id_ && lhs.commands_ == rhs.commands_;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -21,8 +21,12 @@ class BotCommand {
|
||||
string command_;
|
||||
string description_;
|
||||
|
||||
friend bool operator==(const BotCommand &lhs, const BotCommand &rhs);
|
||||
|
||||
public:
|
||||
BotCommand() = default;
|
||||
BotCommand(string command, string description) : command_(std::move(command)), description_(std::move(description)) {
|
||||
}
|
||||
BotCommand(telegram_api::object_ptr<telegram_api::botCommand> &&bot_command);
|
||||
|
||||
td_api::object_ptr<td_api::botCommand> get_bot_command_object() const;
|
||||
@ -40,10 +44,18 @@ class BotCommand {
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const BotCommand &lhs, const BotCommand &rhs);
|
||||
|
||||
inline bool operator!=(const BotCommand &lhs, const BotCommand &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
class BotCommands {
|
||||
UserId bot_user_id_;
|
||||
vector<BotCommand> commands_;
|
||||
|
||||
friend bool operator==(const BotCommands &lhs, const BotCommands &rhs);
|
||||
|
||||
public:
|
||||
BotCommands() = default;
|
||||
BotCommands(UserId bot_user_id, vector<telegram_api::object_ptr<telegram_api::botCommand>> &&bot_commands);
|
||||
@ -63,4 +75,10 @@ class BotCommands {
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const BotCommands &lhs, const BotCommands &rhs);
|
||||
|
||||
inline bool operator!=(const BotCommands &lhs, const BotCommands &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -3905,6 +3905,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
||||
bool has_about = !about.empty();
|
||||
bool has_photo = !photo.is_empty();
|
||||
bool has_description = !description.empty();
|
||||
bool has_commands = !commands.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_about);
|
||||
STORE_FLAG(is_blocked);
|
||||
@ -3915,6 +3916,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
||||
STORE_FLAG(has_photo);
|
||||
STORE_FLAG(supports_video_calls);
|
||||
STORE_FLAG(has_description);
|
||||
STORE_FLAG(has_commands);
|
||||
END_STORE_FLAGS();
|
||||
if (has_about) {
|
||||
store(about, storer);
|
||||
@ -3927,6 +3929,9 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
||||
if (has_description) {
|
||||
store(description, storer);
|
||||
}
|
||||
if (has_commands) {
|
||||
store(commands, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -3935,6 +3940,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
||||
bool has_about;
|
||||
bool has_photo;
|
||||
bool has_description;
|
||||
bool has_commands;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_about);
|
||||
PARSE_FLAG(is_blocked);
|
||||
@ -3945,6 +3951,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
||||
PARSE_FLAG(has_photo);
|
||||
PARSE_FLAG(supports_video_calls);
|
||||
PARSE_FLAG(has_description);
|
||||
PARSE_FLAG(has_commands);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_about) {
|
||||
parse(about, parser);
|
||||
@ -3957,6 +3964,9 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
||||
if (has_description) {
|
||||
parse(description, parser);
|
||||
}
|
||||
if (has_commands) {
|
||||
parse(commands, parser);
|
||||
}
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
@ -9388,6 +9398,9 @@ void ContactsManager::on_load_user_full_from_database(UserId user_id, string val
|
||||
auto *bot_info = get_bot_info_force(user_id, false);
|
||||
if (bot_info != nullptr) {
|
||||
user_full->description = bot_info->description;
|
||||
user_full->commands = transform(
|
||||
bot_info->commands, [](const auto &bot_command) { return BotCommand(bot_command.first, bot_command.second); });
|
||||
user_full->expires_at = 0.0;
|
||||
}
|
||||
|
||||
User *u = get_user(user_id);
|
||||
@ -10290,8 +10303,12 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
||||
td_->group_call_manager_->on_update_dialog_about(DialogId(user_id), user_full->about, true);
|
||||
}
|
||||
string description;
|
||||
if (user->bot_info_ != nullptr) {
|
||||
if (user->bot_info_ != nullptr && !td_->auth_manager_->is_bot()) {
|
||||
description = std::move(user->bot_info_->description_);
|
||||
|
||||
auto commands = transform(std::move(user->bot_info_->commands_),
|
||||
[](auto &&bot_command) { return BotCommand(std::move(bot_command)); });
|
||||
on_update_user_full_commands(user_full, user_id, std::move(commands));
|
||||
}
|
||||
if (user_full->description != description) {
|
||||
user_full->description = std::move(description);
|
||||
@ -11231,6 +11248,14 @@ void ContactsManager::on_update_user_full_common_chat_count(UserFull *user_full,
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_full_commands(UserFull *user_full, UserId user_id, vector<BotCommand> &&commands) {
|
||||
CHECK(user_full != nullptr);
|
||||
if (user_full->commands != commands) {
|
||||
user_full->commands = std::move(commands);
|
||||
user_full->is_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_need_phone_number_privacy_exception(UserId user_id,
|
||||
bool need_phone_number_privacy_exception) {
|
||||
LOG(INFO) << "Receive " << need_phone_number_privacy_exception << " need phone number privacy exception with "
|
||||
@ -11484,6 +11509,7 @@ void ContactsManager::drop_user_full(UserId user_id) {
|
||||
user_full->need_phone_number_privacy_exception = false;
|
||||
user_full->about = string();
|
||||
user_full->description = string();
|
||||
user_full->commands.clear();
|
||||
user_full->common_chat_count = 0;
|
||||
user_full->is_changed = true;
|
||||
|
||||
@ -16006,12 +16032,13 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
||||
const UserFull *user_full) const {
|
||||
CHECK(user_full != nullptr);
|
||||
bool is_bot = is_user_bot(user_id);
|
||||
auto commands = transform(user_full->commands, [](const auto &command) { return command.get_bot_command_object(); });
|
||||
return make_tl_object<td_api::userFullInfo>(
|
||||
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
|
||||
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
||||
user_full->need_phone_number_privacy_exception, is_bot ? string() : user_full->about,
|
||||
is_bot ? user_full->about : string(), is_bot ? user_full->description : string(), user_full->common_chat_count,
|
||||
is_bot ? get_bot_info_object(user_id) : nullptr);
|
||||
std::move(commands));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_unknown_basic_group_object(ChatId chat_id) {
|
||||
|
@ -678,6 +678,8 @@ class ContactsManager : public Actor {
|
||||
string about;
|
||||
string description;
|
||||
|
||||
vector<BotCommand> commands;
|
||||
|
||||
int32 common_chat_count = 0;
|
||||
|
||||
bool is_blocked = false;
|
||||
@ -1200,6 +1202,7 @@ class ContactsManager : public Actor {
|
||||
|
||||
void on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked);
|
||||
void on_update_user_full_common_chat_count(UserFull *user_full, UserId user_id, int32 common_chat_count);
|
||||
void on_update_user_full_commands(UserFull *user_full, UserId user_id, vector<BotCommand> &&commands);
|
||||
void on_update_user_full_need_phone_number_privacy_exception(UserFull *user_full, UserId user_id,
|
||||
bool need_phone_number_privacy_exception);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user