From 18d7e1c29f05a4be816e702051b4e1f5c1416567 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 28 Oct 2024 18:50:38 +0300 Subject: [PATCH] Add scheduled messages support. --- telegram-bot-api/Client.cpp | 5 +++-- telegram-bot-api/Client.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 1a71808..ec8318b 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2895,7 +2895,7 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { object("sender_business_bot", JsonUser(message_->sender_business_bot_user_id, client_)); } } - object("message_id", as_client_message_id(message_->id)); + object("message_id", message_->is_scheduled ? 0 : as_client_message_id(message_->id)); if (message_->sender_user_id != 0) { object("from", JsonUser(message_->sender_user_id, client_)); } @@ -3404,7 +3404,7 @@ class Client::JsonMessageId final : public td::Jsonable { } void store(td::JsonValueScope *scope) const { auto object = scope->enter_object(); - object("message_id", as_client_message_id(message_id_)); + object("message_id", as_client_message_id_unchecked(message_id_)); } private: @@ -14532,6 +14532,7 @@ void Client::init_message(MessageInfo *message_info, object_ptr } message_info->can_be_saved = message->can_be_saved_; + message_info->is_scheduled = message->scheduling_state_ != nullptr; message_info->is_from_offline = message->is_from_offline_; message_info->is_topic_message = message->is_topic_message_; message_info->author_signature = std::move(message->author_signature_); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index d1ccc4b..b7e42fe 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -967,6 +967,7 @@ class Client final : public WebhookActor::Callback { bool is_automatic_forward = false; bool is_topic_message = false; bool is_from_offline = false; + bool is_scheduled = false; mutable bool is_content_changed = false; };