Remove only_urls parameter from find_entities.
This commit is contained in:
parent
c9de490c7f
commit
ce2202b1cc
@ -1376,10 +1376,9 @@ static void remove_entities_intersecting_blockquote(vector<MessageEntity> &entit
|
|||||||
entities.erase(entities.begin() + left_entities, entities.end());
|
entities.erase(entities.begin() + left_entities, entities.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool only_urls) {
|
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands) {
|
||||||
vector<MessageEntity> entities;
|
vector<MessageEntity> entities;
|
||||||
|
|
||||||
if (!only_urls) {
|
|
||||||
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 {
|
||||||
auto new_entities = find_entities_f(text);
|
auto new_entities = find_entities_f(text);
|
||||||
for (auto &entity : new_entities) {
|
for (auto &entity : new_entities) {
|
||||||
@ -1396,14 +1395,10 @@ vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool onl
|
|||||||
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);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
if (only_urls && type != MessageEntity::Type::Url) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
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);
|
||||||
@ -2160,7 +2155,7 @@ static vector<MessageEntity> find_splittable_entities_v3(Slice text, const vecto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto found_entities = find_entities(text, false, false);
|
auto found_entities = find_entities(text, false);
|
||||||
td::remove_if(found_entities, [](const auto &entity) {
|
td::remove_if(found_entities, [](const auto &entity) {
|
||||||
return entity.type == MessageEntity::Type::EmailAddress || entity.type == MessageEntity::Type::Url;
|
return entity.type == MessageEntity::Type::EmailAddress || entity.type == MessageEntity::Type::Url;
|
||||||
});
|
});
|
||||||
|
@ -135,7 +135,7 @@ 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);
|
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text);
|
||||||
|
|
||||||
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool only_urls = false);
|
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands);
|
||||||
|
|
||||||
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