diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 41e07ed4c..364056b1b 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -3949,21 +3949,30 @@ telegram_api::object_ptr get_input_text_with_ent text.text, get_input_message_entities(user_manager, text.entities, source)); } +FormattedText get_formatted_text(const UserManager *user_manager, string &&text, + vector> &&server_entities, + bool allow_empty, bool skip_new_entities, bool skip_bot_commands, + bool skip_media_timestamps, bool skip_trim, const char *source) { + auto entities = get_message_entities(user_manager, std::move(server_entities), source); + auto status = fix_formatted_text(text, entities, allow_empty, skip_new_entities, skip_bot_commands, + skip_media_timestamps, skip_trim); + if (status.is_error()) { + if (!clean_input_string(text)) { + text.clear(); + } + entities = find_entities(text, skip_bot_commands, skip_media_timestamps); + } + return {std::move(text), std::move(entities)}; +} + FormattedText get_formatted_text(const UserManager *user_manager, telegram_api::object_ptr text_with_entities, bool allow_empty, bool skip_new_entities, bool skip_bot_commands, bool skip_media_timestamps, bool skip_trim, const char *source) { CHECK(text_with_entities != nullptr); - auto entities = get_message_entities(user_manager, std::move(text_with_entities->entities_), source); - auto status = fix_formatted_text(text_with_entities->text_, entities, allow_empty, skip_new_entities, - skip_bot_commands, skip_media_timestamps, skip_trim); - if (status.is_error()) { - if (!clean_input_string(text_with_entities->text_)) { - text_with_entities->text_.clear(); - } - entities = find_entities(text_with_entities->text_, skip_bot_commands, skip_media_timestamps); - } - return {std::move(text_with_entities->text_), std::move(entities)}; + return get_formatted_text(user_manager, std::move(text_with_entities->text_), + std::move(text_with_entities->entities_), allow_empty, skip_new_entities, skip_bot_commands, + skip_media_timestamps, skip_trim, source); } // like clean_input_string but also fixes entities diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index be03885f6..ffc138028 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -223,6 +223,11 @@ telegram_api::object_ptr get_input_text_with_ent const FormattedText &text, const char *source); +FormattedText get_formatted_text(const UserManager *user_manager, string &&text, + vector> &&server_entities, + bool allow_empty, bool skip_new_entities, bool skip_bot_commands, + bool skip_media_timestamps, bool skip_trim, const char *source); + FormattedText get_formatted_text(const UserManager *user_manager, telegram_api::object_ptr text_with_entities, bool allow_empty, bool skip_new_entities, bool skip_bot_commands,