From 538fc78fa68977a5a9e9a83a3e9829130e31e4ad Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Mar 2024 13:58:44 +0300 Subject: [PATCH] Add "deleted_business_messages" updates. --- telegram-bot-api/Client.cpp | 30 ++++++++++++++++++++++++++++++ telegram-bot-api/Client.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 0dc2629..da6ffcf 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3603,6 +3603,24 @@ class Client::JsonBusinessConnection final : public td::Jsonable { const Client *client_; }; +class Client::JsonBusinessMessagesDeleted final : public td::Jsonable { + public: + JsonBusinessMessagesDeleted(const td_api::updateBusinessMessagesDeleted *update, const Client *client) + : update_(update), client_(client) { + } + void store(td::JsonValueScope *scope) const { + auto object = scope->enter_object(); + object("business_connection_id", update_->connection_id_); + object("chat", JsonChat(update_->chat_id_, client_)); + object("message_ids", + td::json_array(update_->message_ids_, [](int64 message_id) { return as_client_message_id(message_id); })); + } + + private: + const td_api::updateBusinessMessagesDeleted *update_; + const Client *client_; +}; + class Client::JsonUpdateTypes final : public td::Jsonable { public: explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) { @@ -6480,6 +6498,9 @@ void Client::on_update(object_ptr result) { case td_api::updateBusinessMessageEdited::ID: add_business_message_edited(move_object_as(result)); break; + case td_api::updateBusinessMessagesDeleted::ID: + add_update_business_messages_deleted(move_object_as(result)); + break; case td_api::updateConnectionState::ID: { auto update = move_object_as(result); if (update->state_->get_id() == td_api::connectionStateReady::ID) { @@ -12186,6 +12207,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) { return td::Slice("business_message"); case UpdateType::EditedBusinessMessage: return td::Slice("edited_business_message"); + case UpdateType::BusinessMessagesDeleted: + return td::Slice("deleted_business_messages"); default: UNREACHABLE(); return td::Slice(); @@ -12551,6 +12574,13 @@ void Client::add_update_business_connection(object_ptr &&update) { + CHECK(update != nullptr); + auto webhook_queue_id = update->chat_id_ + (static_cast(11) << 33); + add_update(UpdateType::BusinessMessagesDeleted, JsonBusinessMessagesDeleted(update.get(), this), 86400, + webhook_queue_id); +} + void Client::add_new_business_message(object_ptr &&update) { CHECK(update != nullptr); CHECK(!update->connection_id_.empty()); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 252e79e..80a6a1b 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -164,6 +164,7 @@ class Client final : public WebhookActor::Callback { class JsonMessageReactionUpdated; class JsonMessageReactionCountUpdated; class JsonBusinessConnection; + class JsonBusinessMessagesDeleted; class JsonAddress; class JsonOrderInfo; class JsonStory; @@ -1059,6 +1060,8 @@ class Client final : public WebhookActor::Callback { void add_update_business_connection(object_ptr &&update); + void add_update_business_messages_deleted(object_ptr &&update); + // append only before Size enum class UpdateType : int32 { Message, @@ -1084,6 +1087,7 @@ class Client final : public WebhookActor::Callback { BusinessConnection, BusinessMessage, EditedBusinessMessage, + BusinessMessagesDeleted, Size };