From 30ec8c97819aee199b5d49e7ae47b0ef7443249b Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 16 Jun 2025 13:35:36 +0300 Subject: [PATCH] Support "direct_message_price_changed" messages. --- telegram-bot-api/Client.cpp | 24 +++++++++++++++++++++--- telegram-bot-api/Client.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 0af34b7..e772809 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2886,6 +2886,23 @@ class Client::JsonPaidMessagePriceChanged final : public td::Jsonable { const td_api::messagePaidMessagePriceChanged *price_changed_; }; +class Client::JsonDirectMessagePriceChanged final : public td::Jsonable { + public: + explicit JsonDirectMessagePriceChanged(const td_api::messageDirectMessagePriceChanged *price_changed) + : price_changed_(price_changed) { + } + void store(td::JsonValueScope *scope) const { + auto object = scope->enter_object(); + object("are_direct_messages_enabled", td::JsonBool(price_changed_->is_enabled_)); + if (price_changed_->paid_message_star_count_ > 0) { + object("direct_message_star_count", price_changed_->paid_message_star_count_); + } + } + + private: + const td_api::messageDirectMessagePriceChanged *price_changed_; +}; + class Client::JsonWebAppInfo final : public td::Jsonable { public: explicit JsonWebAppInfo(const td::string &url) : url_(url) { @@ -3700,8 +3717,11 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { } case td_api::messageGroupCall::ID: break; - case td_api::messageDirectMessagePriceChanged::ID: + case td_api::messageDirectMessagePriceChanged::ID: { + auto content = static_cast(message_->content.get()); + object("direct_message_price_changed", JsonDirectMessagePriceChanged(content)); break; + } default: UNREACHABLE(); } @@ -15509,8 +15529,6 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr