Return bio as formatted text.
This commit is contained in:
parent
1484af8c97
commit
b0b98f8f83
@ -497,10 +497,10 @@ botInfo share_text:string description:string photo:photo animation:animation men
|
|||||||
//@has_private_calls True, if the user can't be called due to their privacy settings
|
//@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
|
//@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
|
//@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
|
//@bio A short user bio; may be null for bots
|
||||||
//@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
|
//@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
|
//@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;
|
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:formattedText 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
|
//@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;
|
users total_count:int32 user_ids:vector<int53> = Users;
|
||||||
|
@ -16663,6 +16663,7 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
|||||||
CHECK(user_full != nullptr);
|
CHECK(user_full != nullptr);
|
||||||
td_api::object_ptr<td_api::botInfo> bot_info;
|
td_api::object_ptr<td_api::botInfo> bot_info;
|
||||||
bool is_bot = is_user_bot(user_id);
|
bool is_bot = is_user_bot(user_id);
|
||||||
|
td_api::object_ptr<td_api::formattedText> bio_object;
|
||||||
if (is_bot) {
|
if (is_bot) {
|
||||||
auto menu_button = get_bot_menu_button_object(td_, user_full->menu_button.get());
|
auto menu_button = get_bot_menu_button_object(td_, user_full->menu_button.get());
|
||||||
auto commands =
|
auto commands =
|
||||||
@ -16678,12 +16679,17 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
|||||||
user_full->broadcast_administrator_rights == AdministratorRights()
|
user_full->broadcast_administrator_rights == AdministratorRights()
|
||||||
? nullptr
|
? nullptr
|
||||||
: user_full->broadcast_administrator_rights.get_chat_administrator_rights_object());
|
: user_full->broadcast_administrator_rights.get_chat_administrator_rights_object());
|
||||||
|
} else {
|
||||||
|
FormattedText bio;
|
||||||
|
bio.text = user_full->about;
|
||||||
|
bio.entities = find_entities(bio.text, true, true, !is_user_premium(user_id));
|
||||||
|
bio_object = get_formatted_text_object(bio, true, 0);
|
||||||
}
|
}
|
||||||
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,
|
||||||
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
||||||
!user_full->private_forward_name.empty(), user_full->need_phone_number_privacy_exception,
|
!user_full->private_forward_name.empty(), user_full->need_phone_number_privacy_exception, std::move(bio_object),
|
||||||
is_bot ? string() : user_full->about, user_full->common_chat_count, std::move(bot_info));
|
user_full->common_chat_count, std::move(bot_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_unknown_basic_group_object(ChatId chat_id) {
|
td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_unknown_basic_group_object(ChatId chat_id) {
|
||||||
|
@ -1636,7 +1636,7 @@ static void fix_entity_offsets(Slice text, vector<MessageEntity> &entities) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool skip_media_timestamps) {
|
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool skip_media_timestamps, bool skip_urls) {
|
||||||
vector<MessageEntity> entities;
|
vector<MessageEntity> entities;
|
||||||
|
|
||||||
auto add_entities = [&entities, &text](MessageEntity::Type type, vector<Slice> (*find_entities_f)(Slice)) mutable {
|
auto add_entities = [&entities, &text](MessageEntity::Type type, vector<Slice> (*find_entities_f)(Slice)) mutable {
|
||||||
@ -1655,16 +1655,16 @@ vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool ski
|
|||||||
add_entities(MessageEntity::Type::Cashtag, find_cashtags);
|
add_entities(MessageEntity::Type::Cashtag, find_cashtags);
|
||||||
// TODO find_phone_numbers
|
// TODO find_phone_numbers
|
||||||
add_entities(MessageEntity::Type::BankCardNumber, find_bank_card_numbers);
|
add_entities(MessageEntity::Type::BankCardNumber, find_bank_card_numbers);
|
||||||
add_entities(MessageEntity::Type::Url, find_tg_urls);
|
if (!skip_urls) {
|
||||||
|
add_entities(MessageEntity::Type::Url, find_tg_urls);
|
||||||
auto urls = find_urls(text);
|
auto urls = find_urls(text);
|
||||||
for (auto &url : urls) {
|
for (auto &url : urls) {
|
||||||
auto type = url.second ? MessageEntity::Type::EmailAddress : MessageEntity::Type::Url;
|
auto type = url.second ? MessageEntity::Type::EmailAddress : MessageEntity::Type::Url;
|
||||||
auto offset = narrow_cast<int32>(url.first.begin() - text.begin());
|
auto offset = narrow_cast<int32>(url.first.begin() - text.begin());
|
||||||
auto length = narrow_cast<int32>(url.first.size());
|
auto length = narrow_cast<int32>(url.first.size());
|
||||||
entities.emplace_back(type, offset, length);
|
entities.emplace_back(type, offset, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip_media_timestamps) {
|
if (!skip_media_timestamps) {
|
||||||
auto media_timestamps = find_media_timestamps(text);
|
auto media_timestamps = find_media_timestamps(text);
|
||||||
for (auto &entity : media_timestamps) {
|
for (auto &entity : media_timestamps) {
|
||||||
|
@ -143,7 +143,8 @@ vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<
|
|||||||
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text, bool skip_bot_commands,
|
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text, bool skip_bot_commands,
|
||||||
int32 max_media_timestamp);
|
int32 max_media_timestamp);
|
||||||
|
|
||||||
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool skip_media_timestamps);
|
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool skip_media_timestamps,
|
||||||
|
bool skip_urls = false);
|
||||||
|
|
||||||
vector<Slice> find_mentions(Slice str);
|
vector<Slice> find_mentions(Slice str);
|
||||||
vector<Slice> find_bot_commands(Slice str);
|
vector<Slice> find_bot_commands(Slice str);
|
||||||
|
Loading…
Reference in New Issue
Block a user