Skip new entities for some bots.

This commit is contained in:
levlam 2023-05-01 13:44:41 +03:00
parent 14eda7a97c
commit f8853fb938
2 changed files with 5 additions and 2 deletions

View File

@ -3478,7 +3478,8 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
const int32 MAX_CUSTOM_ENTITIES_COUNT = 100; // server-side limit
if (need_message_changed_warning && need_message_text_changed_warning(old_, new_) &&
old_->text.entities.size() <= MAX_CUSTOM_ENTITIES_COUNT &&
need_message_entities_changed_warning(old_->text.entities, new_->text.entities)) {
need_message_entities_changed_warning(old_->text.entities, new_->text.entities) &&
td->option_manager_->get_option_integer("session_count") <= 1) {
LOG(WARNING) << "Entities have changed in " << get_content_object(old_content) << ". New content is "
<< get_content_object(new_content);
}

View File

@ -4341,7 +4341,9 @@ Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
auto need_skip_bot_commands = need_always_skip_bot_commands(td->contacts_manager_.get(), dialog_id, is_bot);
bool parse_markdown = td->option_manager_->get_option_boolean("always_parse_markdown");
TRY_STATUS(fix_formatted_text(text->text_, entities, allow_empty, parse_markdown, need_skip_bot_commands,
bool skip_new_entities = is_bot && td->option_manager_->get_option_integer("session_count") > 1;
TRY_STATUS(fix_formatted_text(text->text_, entities, allow_empty, skip_new_entities || parse_markdown,
skip_new_entities || need_skip_bot_commands,
is_bot || skip_media_timestamps || parse_markdown, skip_trim));
FormattedText result{std::move(text->text_), std::move(entities)};