diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 423eaf9..7cdd107 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3576,6 +3576,26 @@ class Client::JsonMessageReactionCountUpdated final : public td::Jsonable { const Client *client_; }; +class Client::JsonBusinessConnection final : public td::Jsonable { + public: + JsonBusinessConnection(const td_api::businessConnection *connection, const Client *client) + : connection_(connection), client_(client) { + } + void store(td::JsonValueScope *scope) const { + auto object = scope->enter_object(); + object("id", connection_->id_); + object("user", JsonUser(connection_->user_id_, client_)); + object("user_chat_id", connection_->user_chat_id_); + object("date", connection_->date_); + object("can_reply", td::JsonBool(connection_->can_reply_)); + object("is_enabled", td::JsonBool(connection_->is_enabled_)); + } + + private: + const td_api::businessConnection *connection_; + const Client *client_; +}; + class Client::JsonUpdateTypes final : public td::Jsonable { public: explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) { @@ -6330,6 +6350,9 @@ void Client::on_update(object_ptr result) { case td_api::updateMessageReactions::ID: add_update_message_reaction_count(move_object_as(result)); break; + case td_api::updateBusinessConnection::ID: + add_update_business_connection(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) { @@ -11967,6 +11990,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) { return td::Slice("message_reaction"); case UpdateType::MessageReactionCount: return td::Slice("message_reaction_count"); + case UpdateType::BusinessConnection: + return td::Slice("business_connection"); default: UNREACHABLE(); return td::Slice(); @@ -12317,6 +12342,20 @@ void Client::add_update_message_reaction_count(object_ptr &&update) { + CHECK(update != nullptr); + auto connection = std::move(update->connection_); + auto left_time = connection->date_ + 86400 - get_unix_time(); + if (left_time > 0) { + auto webhook_queue_id = connection->user_id_ + (static_cast(10) << 33); + add_update(UpdateType::BusinessConnection, JsonBusinessConnection(connection.get(), this), left_time, + webhook_queue_id); + } else { + LOG(DEBUG) << "Skip updateBusinessConnection with date " << connection->date_ << ", because current date is " + << get_unix_time(); + } +} + td::int64 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const { CHECK(message_add_members != nullptr); for (auto &member_user_id : message_add_members->member_user_ids_) { diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 4c49c77..0f2a1c6 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -163,6 +163,7 @@ class Client final : public WebhookActor::Callback { class JsonGameHighScore; class JsonMessageReactionUpdated; class JsonMessageReactionCountUpdated; + class JsonBusinessConnection; class JsonAddress; class JsonOrderInfo; class JsonStory; @@ -1017,6 +1018,8 @@ class Client final : public WebhookActor::Callback { void add_update_message_reaction_count(object_ptr &&update); + void add_update_business_connection(object_ptr &&update); + // append only before Size enum class UpdateType : int32 { Message, @@ -1039,6 +1042,7 @@ class Client final : public WebhookActor::Callback { ChatBoostRemoved, MessageReaction, MessageReactionCount, + BusinessConnection, Size };