From 2605cd374b95399fbc3a69e6e5657800e4bbf5a7 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 5 Aug 2021 05:41:24 +0300 Subject: [PATCH] Add has_media_timestamps. --- td/telegram/MessageEntity.cpp | 15 +++++++++++++++ td/telegram/MessageEntity.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 3c0b2da28..b9f213542 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -4096,6 +4096,21 @@ void add_formatted_text_dependencies(Dependencies &dependencies, const Formatted } } +bool has_media_timestamps(const FormattedText *text, int32 min_timestamp, int32 max_timestamp) { + if (text == nullptr) { + return false; + } + for (auto &entity : text->entities) { + if (entity.type == MessageEntity::Type::MediaTimestamp) { + int32 timestamp = to_integer(entity.argument); + if (min_timestamp <= timestamp && timestamp <= max_timestamp) { + return true; + } + } + } + return false; +} + bool has_bot_commands(const FormattedText *text) { if (text == nullptr) { return false; diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index 470f560f3..78023238f 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -196,6 +196,8 @@ Result process_input_caption(const ContactsManager *contacts_mana void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text); +bool has_media_timestamps(const FormattedText *text, int32 min_timestamp, int32 max_timestamp); + bool has_bot_commands(const FormattedText *text); bool need_always_skip_bot_commands(const ContactsManager *contacts_manager, DialogId dialog_id, bool is_bot);