From 6ba3d865ac78395595ca38592f70cbf35239e60b Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 15 Jul 2024 23:49:30 +0500 Subject: [PATCH 01/28] Build instructions updated (#615) * Build instructions updated - Fixed package manager in CentOS - Added instructions for CentOS 9 - Added instructions for Fedora 37 --- build.html | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/build.html b/build.html index e1d7c7a..b5ca362 100644 --- a/build.html +++ b/build.html @@ -201,8 +201,10 @@ + + @@ -354,7 +356,7 @@ function onOptionsChanged() { document.getElementById('buildCommandsDiv').style.display = 'block'; var use_clang = os_freebsd || os_openbsd; - if (os_linux && linux_distro !== 'Alpine' && !linux_distro.includes('CentOS')) { + if (os_linux && linux_distro !== 'Alpine' && !linux_distro.includes('CentOS') && !linux_distro.includes('Fedora')) { document.getElementById('buildCompilerDiv').style.display = 'block'; use_clang = document.getElementById('buildCompilerRadioClang').checked; } else { @@ -531,19 +533,31 @@ function onOptionsChanged() { commands.push(sudo + 'apk add ' + packages); break; case 'CentOS 7': - case 'CentOS 8': commands.push(sudo + 'yum update -y'); var packages = 'gcc-c++ make git zlib-devel openssl-devel'; - if (linux_distro === 'CentOS 7') { - commands.push(sudo + 'yum install -y centos-release-scl-rh epel-release'); - commands.push(sudo + 'yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++'); - cmake = 'cmake3'; - packages += ' gperf'; - } else { + commands.push(sudo + 'yum install -y centos-release-scl-rh epel-release'); + commands.push(sudo + 'yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++'); + cmake = 'cmake3'; + packages += ' gperf ' + cmake; + commands.push(sudo + 'yum install -y ' + packages); + break; + case 'CentOS 8': + case 'CentOS Stream 9': + commands.push(sudo + 'dnf update -y'); + var packages = 'gcc-c++ make git zlib-devel openssl-devel'; + if (linux_distro === 'CentOS 8') { commands.push(sudo + 'dnf --enablerepo=powertools install gperf'); + } else { + commands.push(sudo + 'dnf --enablerepo=crb install gperf'); } packages += ' ' + cmake; - commands.push(sudo + 'yum install -y ' + packages); + commands.push(sudo + 'dnf install -y ' + packages); + break; + case 'Fedora 21+': + commands.push(sudo + 'dnf update -y'); + var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel'; + packages += ' ' + cmake; + commands.push(sudo + 'dnf install -y ' + packages); break; case 'Debian 8/9': case 'Debian 10+': From dd17f94d9aedf0418ee6ce27900ac8e299328b18 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 18 Jul 2024 17:21:56 +0300 Subject: [PATCH 02/28] Simplify packages list in build instructions generator. --- build.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/build.html b/build.html index b5ca362..5776d8a 100644 --- a/build.html +++ b/build.html @@ -534,29 +534,26 @@ function onOptionsChanged() { break; case 'CentOS 7': commands.push(sudo + 'yum update -y'); - var packages = 'gcc-c++ make git zlib-devel openssl-devel'; commands.push(sudo + 'yum install -y centos-release-scl-rh epel-release'); commands.push(sudo + 'yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++'); cmake = 'cmake3'; - packages += ' gperf ' + cmake; + var packages = 'gcc-c++ make git zlib-devel openssl-devel gperf ' + cmake; commands.push(sudo + 'yum install -y ' + packages); break; case 'CentOS 8': case 'CentOS Stream 9': commands.push(sudo + 'dnf update -y'); - var packages = 'gcc-c++ make git zlib-devel openssl-devel'; if (linux_distro === 'CentOS 8') { commands.push(sudo + 'dnf --enablerepo=powertools install gperf'); } else { commands.push(sudo + 'dnf --enablerepo=crb install gperf'); } - packages += ' ' + cmake; + var packages = 'gcc-c++ make git zlib-devel openssl-devel cmake'; commands.push(sudo + 'dnf install -y ' + packages); break; case 'Fedora 21+': commands.push(sudo + 'dnf update -y'); - var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel'; - packages += ' ' + cmake; + var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel cmake'; commands.push(sudo + 'dnf install -y ' + packages); break; case 'Debian 8/9': From 3a53074483f2852193b137f37cb70c16449b0aa7 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 30 Jul 2024 12:28:40 +0300 Subject: [PATCH 03/28] Update TDLib to 1.8.34. --- td | 2 +- telegram-bot-api/Client.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/td b/td index cb16492..1fa2a37 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit cb164927417f22811c74cd8678ed4a5ab7cb80ba +Subproject commit 1fa2a372a88c26369dcac2ce476166531df74a77 diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 212524c..36007ec 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3285,6 +3285,8 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { object("refunded_payment", JsonRefundedPayment(content)); break; } + case td_api::messageGiftedStars::ID: + break; default: UNREACHABLE(); } @@ -4085,7 +4087,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { case td_api::starTransactionPartnerBot::ID: { auto source_user = static_cast(source_); object("type", "user"); - object("user", JsonUser(source_user->bot_user_id_, client_)); + object("user", JsonUser(source_user->user_id_, client_)); if (!source_user->invoice_payload_.empty()) { if (!td::check_utf8(source_user->invoice_payload_)) { LOG(WARNING) << "Receive non-UTF-8 invoice payload"; @@ -4102,6 +4104,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { case td_api::starTransactionPartnerTelegram::ID: case td_api::starTransactionPartnerAppStore::ID: case td_api::starTransactionPartnerGooglePlay::ID: + case td_api::starTransactionPartnerUser::ID: case td_api::starTransactionPartnerChannel::ID: LOG(ERROR) << "Receive " << to_string(*source_); object("type", "other"); @@ -13778,6 +13781,8 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr Date: Tue, 30 Jul 2024 13:05:42 +0300 Subject: [PATCH 04/28] Support pinChatMessage for business messages. --- telegram-bot-api/Client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 36007ec..5badda4 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -11302,10 +11302,21 @@ td::Status Client::process_set_chat_description_query(PromisedQueryPtr &query) { } td::Status Client::process_pin_chat_message_query(PromisedQueryPtr &query) { + auto business_connection_id = query->arg("business_connection_id"); auto chat_id = query->arg("chat_id"); auto message_id = get_message_id(query.get()); auto disable_notification = to_bool(query->arg("disable_notification")); + if (!business_connection_id.empty()) { + check_business_connection_chat_id( + business_connection_id.str(), chat_id.str(), std::move(query), + [this, message_id](const BusinessConnection *business_connection, int64 chat_id, PromisedQueryPtr query) { + send_request( + make_object(business_connection->id_, chat_id, message_id, true), + td::make_unique(std::move(query))); + }); + return td::Status::OK(); + } check_message(chat_id, message_id, false, AccessRights::Write, "message to pin", std::move(query), [this, disable_notification](int64 chat_id, int64 message_id, PromisedQueryPtr query) { send_request(make_object(chat_id, message_id, disable_notification, false), From 16de9313b0d2960b702811263ba70998bcb553da Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 30 Jul 2024 13:10:46 +0300 Subject: [PATCH 05/28] Support unpinChatMessage for business messages. --- telegram-bot-api/Client.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 5badda4..d708db7 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -11326,9 +11326,21 @@ td::Status Client::process_pin_chat_message_query(PromisedQueryPtr &query) { } td::Status Client::process_unpin_chat_message_query(PromisedQueryPtr &query) { + auto business_connection_id = query->arg("business_connection_id"); auto chat_id = query->arg("chat_id"); auto message_id = get_message_id(query.get()); + if (!business_connection_id.empty()) { + check_business_connection_chat_id( + business_connection_id.str(), chat_id.str(), std::move(query), + [this, message_id](const BusinessConnection *business_connection, int64 chat_id, PromisedQueryPtr query) { + send_request( + make_object(business_connection->id_, chat_id, message_id, false), + td::make_unique(std::move(query))); + }); + return td::Status::OK(); + } + if (message_id == 0) { check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) { send_request(make_object(chat_id), From 127964a3f289d83c6730dc93f4a87d1b7c729d53 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 30 Jul 2024 13:43:00 +0300 Subject: [PATCH 06/28] Add User.has_main_web_app. --- telegram-bot-api/Client.cpp | 2 ++ telegram-bot-api/Client.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index d708db7..73303ba 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -420,6 +420,7 @@ class Client::JsonUser final : public td::Jsonable { object("can_read_all_group_messages", td::JsonBool(user_info->can_read_all_group_messages)); object("supports_inline_queries", td::JsonBool(user_info->is_inline_bot)); object("can_connect_to_business", td::JsonBool(user_info->can_connect_to_business)); + object("has_main_web_app", td::JsonBool(user_info->has_main_web_app)); } } @@ -12858,6 +12859,7 @@ void Client::add_user(UserInfo *user_info, object_ptr &&user) { user_info->can_read_all_group_messages = bot->can_read_all_group_messages_; user_info->is_inline_bot = bot->is_inline_; user_info->can_connect_to_business = bot->can_connect_to_business_; + user_info->has_main_web_app = bot->has_main_web_app_; break; } case td_api::userTypeDeleted::ID: diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 0ab6ee2..bc9edbb 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -841,9 +841,10 @@ class Client final : public WebhookActor::Callback { bool can_join_groups = false; bool can_read_all_group_messages = false; bool can_connect_to_business = false; - bool is_inline_bot = false; + bool has_main_web_app = false; bool has_private_forwards = false; bool has_restricted_voice_and_video_messages = false; + bool is_inline_bot = false; bool is_premium = false; bool added_to_attachment_menu = false; }; From 12bbe26692b8c6e347aaf3e32e0e9d11b86bb56d Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 30 Jul 2024 16:21:23 +0300 Subject: [PATCH 07/28] Update version to 7.8. --- CMakeLists.txt | 2 +- telegram-bot-api/telegram-bot-api.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 628b0bd..1451ed6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ if (POLICY CMP0065) cmake_policy(SET CMP0065 NEW) endif() -project(TelegramBotApi VERSION 7.7 LANGUAGES CXX) +project(TelegramBotApi VERSION 7.8 LANGUAGES CXX) if (POLICY CMP0069) option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.") diff --git a/telegram-bot-api/telegram-bot-api.cpp b/telegram-bot-api/telegram-bot-api.cpp index 82278b1..3633a66 100644 --- a/telegram-bot-api/telegram-bot-api.cpp +++ b/telegram-bot-api/telegram-bot-api.cpp @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) { auto start_time = td::Time::now(); auto shared_data = std::make_shared(); auto parameters = std::make_unique(); - parameters->version_ = "7.7"; + parameters->version_ = "7.8"; parameters->shared_data_ = shared_data; parameters->start_time_ = start_time; auto net_query_stats = td::create_net_query_stats(); From ffe39d4114df56161f2ecf6289729ba14d9a5406 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 14:51:15 +0300 Subject: [PATCH 08/28] Update TDLib to 1.8.35. --- td | 2 +- telegram-bot-api/Client.cpp | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/td b/td index 1fa2a37..8d08b34 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 1fa2a372a88c26369dcac2ce476166531df74a77 +Subproject commit 8d08b34e22a08e58db8341839c4e18ee06c516c5 diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 73303ba..fb81fa2 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -709,6 +709,8 @@ class Client::JsonReactionType final : public td::Jsonable { object("custom_emoji_id", td::to_string(static_cast(reaction_type_)->custom_emoji_id_)); break; + case td_api::reactionTypePaid::ID: + break; default: UNREACHABLE(); } @@ -4089,13 +4091,25 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { auto source_user = static_cast(source_); object("type", "user"); object("user", JsonUser(source_user->user_id_, client_)); - if (!source_user->invoice_payload_.empty()) { - if (!td::check_utf8(source_user->invoice_payload_)) { - LOG(WARNING) << "Receive non-UTF-8 invoice payload"; - object("invoice_payload", td::JsonRawString(source_user->invoice_payload_)); - } else { - object("invoice_payload", source_user->invoice_payload_); + CHECK(source_user->purpose_ != nullptr); + switch (source_user->purpose_->get_id()) { + case td_api::botTransactionPurposeInvoicePayment::ID: { + auto purpose = + static_cast(source_user->purpose_.get()); + if (!purpose->invoice_payload_.empty()) { + if (!td::check_utf8(purpose->invoice_payload_)) { + LOG(WARNING) << "Receive non-UTF-8 invoice payload"; + object("invoice_payload", td::JsonRawString(purpose->invoice_payload_)); + } else { + object("invoice_payload", purpose->invoice_payload_); + } + } + break; } + case td_api::botTransactionPurposePaidMedia::ID: + break; + default: + UNREACHABLE(); } break; } @@ -4106,6 +4120,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { case td_api::starTransactionPartnerAppStore::ID: case td_api::starTransactionPartnerGooglePlay::ID: case td_api::starTransactionPartnerUser::ID: + case td_api::starTransactionPartnerBusiness::ID: case td_api::starTransactionPartnerChannel::ID: LOG(ERROR) << "Receive " << to_string(*source_); object("type", "other"); @@ -10978,8 +10993,8 @@ td::Status Client::process_create_invoice_link_query(PromisedQueryPtr &query) { td::Status Client::process_get_star_transactions_query(PromisedQueryPtr &query) { auto offset = get_integer_arg(query.get(), "offset", 0, 0); auto limit = get_integer_arg(query.get(), "limit", 100, 1, 100); - send_request(make_object(make_object(my_id_), nullptr, - td::to_string(offset), limit), + send_request(make_object(make_object(my_id_), td::string(), + nullptr, td::to_string(offset), limit), td::make_unique(this, std::move(query))); return td::Status::OK(); } From 3c4656b5394ebded4c80aca1bfefa41fdda8da69 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 15:24:19 +0300 Subject: [PATCH 09/28] Support paid reactions. --- telegram-bot-api/Client.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index fb81fa2..1cc0084 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -710,6 +710,7 @@ class Client::JsonReactionType final : public td::Jsonable { td::to_string(static_cast(reaction_type_)->custom_emoji_id_)); break; case td_api::reactionTypePaid::ID: + object("type", "paid"); break; default: UNREACHABLE(); From e171396b8a051a148dbca6c81b0ca372cb9860a2 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 15:28:48 +0300 Subject: [PATCH 10/28] Support chatMemberStatusMember.member_until_date. --- telegram-bot-api/Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 1cc0084..51d9dc4 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3710,8 +3710,13 @@ class Client::JsonChatMember final : public td::Jsonable { } break; } - case td_api::chatMemberStatusMember::ID: + case td_api::chatMemberStatusMember::ID: { + auto member = static_cast(member_->status_.get()); + if (member->member_until_date_ > 0) { + object("until_date", member->member_until_date_); + } break; + } case td_api::chatMemberStatusRestricted::ID: if (chat_type_ == Client::ChatType::Supergroup) { auto restricted = static_cast(member_->status_.get()); From af5f55b20601f7391559434990a5eba0f9448fa9 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 15:46:37 +0300 Subject: [PATCH 11/28] Add subscription information to ChatInviteLink. --- telegram-bot-api/Client.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 51d9dc4..e02c120 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -887,6 +887,10 @@ class Client::JsonChatInviteLink final : public td::Jsonable { if (chat_invite_link_->pending_join_request_count_ != 0) { object("pending_join_request_count", chat_invite_link_->pending_join_request_count_); } + if (chat_invite_link_->subscription_pricing_ != nullptr) { + object("subscription_period", chat_invite_link_->subscription_pricing_->period_); + object("subscription_price", chat_invite_link_->subscription_pricing_->star_count_); + } object("creates_join_request", td::JsonBool(chat_invite_link_->creates_join_request_)); object("is_primary", td::JsonBool(chat_invite_link_->is_primary_)); object("is_revoked", td::JsonBool(chat_invite_link_->is_revoked_)); From 6478c25096ec1113e9617fa347e9acb38402d332 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 16:00:42 +0300 Subject: [PATCH 12/28] Support botTransactionPurposePaidMedia. --- telegram-bot-api/Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index e02c120..4ce09f9 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -4116,8 +4116,13 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { } break; } - case td_api::botTransactionPurposePaidMedia::ID: + case td_api::botTransactionPurposePaidMedia::ID: { + auto purpose = static_cast(source_user->purpose_.get()); + object("paid_media", td::json_array(purpose->media_, [client = client_](auto &media) { + return JsonPaidMedia(media.get(), client); + })); break; + } default: UNREACHABLE(); } From 76e5ed31c062ce60b6d3cd7761e4f1a4129882c9 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 14 Aug 2024 00:26:20 +0300 Subject: [PATCH 13/28] Add method createChatSubscriptionInviteLink. --- telegram-bot-api/Client.cpp | 17 +++++++++++++++++ telegram-bot-api/Client.h | 1 + 2 files changed, 18 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 4ce09f9..b6e3467 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -258,6 +258,7 @@ bool Client::init_methods() { methods_.emplace("answerprecheckoutquery", &Client::process_answer_pre_checkout_query_query); methods_.emplace("exportchatinvitelink", &Client::process_export_chat_invite_link_query); methods_.emplace("createchatinvitelink", &Client::process_create_chat_invite_link_query); + methods_.emplace("createchatsubscriptioninvitelink", &Client::process_create_chat_subscription_invite_link_query); methods_.emplace("editchatinvitelink", &Client::process_edit_chat_invite_link_query); methods_.emplace("revokechatinvitelink", &Client::process_revoke_chat_invite_link_query); methods_.emplace("getbusinessconnection", &Client::process_get_business_connection_query); @@ -11201,6 +11202,22 @@ td::Status Client::process_create_chat_invite_link_query(PromisedQueryPtr &query return td::Status::OK(); } +td::Status Client::process_create_chat_subscription_invite_link_query(PromisedQueryPtr &query) { + auto chat_id = query->arg("chat_id"); + auto name = query->arg("name"); + auto subscription_period = get_integer_arg(query.get(), "subscription_period", 0, 0, 1000000000); + auto subscription_price = get_integer_arg(query.get(), "subscription_price", 0, 0, 1000000); + + check_chat(chat_id, AccessRights::Write, std::move(query), + [this, name = name.str(), subscription_period, subscription_price](int64 chat_id, PromisedQueryPtr query) { + send_request(make_object( + chat_id, name, + make_object(subscription_period, subscription_price)), + td::make_unique(this, std::move(query))); + }); + return td::Status::OK(); +} + td::Status Client::process_edit_chat_invite_link_query(PromisedQueryPtr &query) { auto chat_id = query->arg("chat_id"); auto invite_link = query->arg("invite_link"); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index bc9edbb..0b0b3f6 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -683,6 +683,7 @@ class Client final : public WebhookActor::Callback { td::Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query); td::Status process_export_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_create_chat_invite_link_query(PromisedQueryPtr &query); + td::Status process_create_chat_subscription_invite_link_query(PromisedQueryPtr &query); td::Status process_edit_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_get_business_connection_query(PromisedQueryPtr &query); From 961a19e1a01f50555ee4d758a8d02cbacaf084c1 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 14 Aug 2024 00:29:32 +0300 Subject: [PATCH 14/28] Add method editChatSubscriptionInviteLink. --- telegram-bot-api/Client.cpp | 14 ++++++++++++++ telegram-bot-api/Client.h | 1 + 2 files changed, 15 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index b6e3467..86bd10d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -260,6 +260,7 @@ bool Client::init_methods() { methods_.emplace("createchatinvitelink", &Client::process_create_chat_invite_link_query); methods_.emplace("createchatsubscriptioninvitelink", &Client::process_create_chat_subscription_invite_link_query); methods_.emplace("editchatinvitelink", &Client::process_edit_chat_invite_link_query); + methods_.emplace("editchatsubscriptioninvitelink", &Client::process_edit_chat_subscription_invite_link_query); methods_.emplace("revokechatinvitelink", &Client::process_revoke_chat_invite_link_query); methods_.emplace("getbusinessconnection", &Client::process_get_business_connection_query); methods_.emplace("getchat", &Client::process_get_chat_query); @@ -11236,6 +11237,19 @@ td::Status Client::process_edit_chat_invite_link_query(PromisedQueryPtr &query) return td::Status::OK(); } +td::Status Client::process_edit_chat_subscription_invite_link_query(PromisedQueryPtr &query) { + auto chat_id = query->arg("chat_id"); + auto invite_link = query->arg("invite_link"); + auto name = query->arg("name"); + + check_chat(chat_id, AccessRights::Write, std::move(query), + [this, invite_link = invite_link.str(), name = name.str()](int64 chat_id, PromisedQueryPtr query) { + send_request(make_object(chat_id, invite_link, name), + td::make_unique(this, std::move(query))); + }); + return td::Status::OK(); +} + td::Status Client::process_revoke_chat_invite_link_query(PromisedQueryPtr &query) { auto chat_id = query->arg("chat_id"); auto invite_link = query->arg("invite_link"); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 0b0b3f6..3fef529 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -685,6 +685,7 @@ class Client final : public WebhookActor::Callback { td::Status process_create_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_create_chat_subscription_invite_link_query(PromisedQueryPtr &query); td::Status process_edit_chat_invite_link_query(PromisedQueryPtr &query); + td::Status process_edit_chat_subscription_invite_link_query(PromisedQueryPtr &query); td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_get_business_connection_query(PromisedQueryPtr &query); td::Status process_get_chat_query(PromisedQueryPtr &query); From 06e2e31aeaa9bdfc2b3e11bb3e4761241373b7cd Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 14 Aug 2024 05:16:39 +0300 Subject: [PATCH 15/28] Update version to 7.9. --- CMakeLists.txt | 2 +- telegram-bot-api/telegram-bot-api.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1451ed6..b5e56ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ if (POLICY CMP0065) cmake_policy(SET CMP0065 NEW) endif() -project(TelegramBotApi VERSION 7.8 LANGUAGES CXX) +project(TelegramBotApi VERSION 7.9 LANGUAGES CXX) if (POLICY CMP0069) option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.") diff --git a/telegram-bot-api/telegram-bot-api.cpp b/telegram-bot-api/telegram-bot-api.cpp index 3633a66..9035a3b 100644 --- a/telegram-bot-api/telegram-bot-api.cpp +++ b/telegram-bot-api/telegram-bot-api.cpp @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) { auto start_time = td::Time::now(); auto shared_data = std::make_shared(); auto parameters = std::make_unique(); - parameters->version_ = "7.8"; + parameters->version_ = "7.9"; parameters->shared_data_ = shared_data; parameters->start_time_ = start_time; auto net_query_stats = td::create_net_query_stats(); From 6e5d607b905578f557af855dc465306eaa3fd241 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 27 Aug 2024 15:55:54 +0300 Subject: [PATCH 16/28] Add and use Client::is_special_error_code. --- telegram-bot-api/Client.cpp | 42 ++++++++++++++++++++----------------- telegram-bot-api/Client.h | 2 ++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 86bd10d..87c63f3 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -39,6 +39,24 @@ namespace telegram_bot_api { using td_api::make_object; using td_api::move_object_as; +Client::Client(td::ActorShared<> parent, const td::string &bot_token, bool is_test_dc, int64 tqueue_id, + std::shared_ptr parameters, td::ActorId stat_actor) + : parent_(std::move(parent)) + , bot_token_(bot_token) + , bot_token_id_("") + , is_test_dc_(is_test_dc) + , tqueue_id_(tqueue_id) + , parameters_(std::move(parameters)) + , stat_actor_(std::move(stat_actor)) { + static auto is_inited = init_methods(); + CHECK(is_inited); +} + +Client::~Client() { + td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), messages_, users_, groups_, + supergroups_, chats_, sticker_set_names_); +} + int Client::get_retry_after_time(td::Slice error_message) { td::Slice prefix = "Too Many Requests: retry after "; if (td::begins_with(error_message, prefix)) { @@ -179,22 +197,8 @@ void Client::fail_query_with_error(PromisedQueryPtr &&query, object_ptrcode_, error->message_, default_message); } -Client::Client(td::ActorShared<> parent, const td::string &bot_token, bool is_test_dc, int64 tqueue_id, - std::shared_ptr parameters, td::ActorId stat_actor) - : parent_(std::move(parent)) - , bot_token_(bot_token) - , bot_token_id_("") - , is_test_dc_(is_test_dc) - , tqueue_id_(tqueue_id) - , parameters_(std::move(parameters)) - , stat_actor_(std::move(stat_actor)) { - static auto is_inited = init_methods(); - CHECK(is_inited); -} - -Client::~Client() { - td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), messages_, users_, groups_, - supergroups_, chats_, sticker_set_names_); +bool Client::is_special_error_code(int32 error_code) { + return error_code == 401 || error_code == 429 || error_code >= 500; } bool Client::init_methods() { @@ -5281,7 +5285,7 @@ class Client::TdOnGetChatPinnedMessageCallback final : public TdQueryCallback { int64 pinned_message_id = 0; if (result->get_id() == td_api::error::ID) { auto error = move_object_as(result); - if (error->code_ == 429) { + if (is_special_error_code(error->code_)) { return fail_query_with_error(std::move(query_), std::move(error)); } else if (error->code_ != 404 && error->message_ != "CHANNEL_PRIVATE") { LOG(ERROR) << "Failed to get chat pinned message: " << to_string(error); @@ -5349,7 +5353,7 @@ class Client::TdOnGetChatPinnedMessageToUnpinCallback final : public TdQueryCall int64 pinned_message_id = 0; if (result->get_id() == td_api::error::ID) { auto error = move_object_as(result); - if (error->code_ == 429) { + if (is_special_error_code(error->code_)) { return fail_query_with_error(std::move(query_), std::move(error)); } else { return fail_query_with_error(std::move(query_), 400, "Message to unpin not found"); @@ -9959,7 +9963,7 @@ void Client::on_message_send_failed(int64 chat_id, int64 old_message_id, int64 n auto &query = *pending_send_message_queries_[query_id]; if (query.is_multisend) { if (query.error == nullptr || query.error->message_ == "Group send failed") { - if (error->code_ == 401 || error->code_ == 429 || error->code_ >= 500 || error->message_ == "Group send failed") { + if (is_special_error_code(error->code_) || error->message_ == "Group send failed") { query.error = std::move(error); } else { auto pos = (query.total_message_count - query.awaited_message_count + 1); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 3fef529..bc12bcb 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -810,6 +810,8 @@ class Client final : public WebhookActor::Callback { static void fail_query_with_error(PromisedQueryPtr &&query, object_ptr error, td::Slice default_message = td::Slice()); + static bool is_special_error_code(int32 error_code); + class JsonUpdates; void do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQueryPtr query); From 240eb7b4a909458bbec116af5d712905a74d2884 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 27 Aug 2024 17:42:44 +0300 Subject: [PATCH 17/28] Update TDLib to 1.8.36. --- td | 2 +- telegram-bot-api/Client.cpp | 86 +++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/td b/td index 8d08b34..87d8810 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 8d08b34e22a08e58db8341839c4e18ee06c516c5 +Subproject commit 87d881071fe514936bb17029e96761141287d2be diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 87c63f3..dd31e7f 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2421,8 +2421,7 @@ class Client::JsonChatShared final : public td::Jsonable { class Client::JsonGiveaway final : public td::Jsonable { public: - JsonGiveaway(const td_api::messagePremiumGiveaway *giveaway, const Client *client) - : giveaway_(giveaway), client_(client) { + JsonGiveaway(const td_api::messageGiveaway *giveaway, const Client *client) : giveaway_(giveaway), client_(client) { } void store(td::JsonValueScope *scope) const { auto object = scope->enter_object(); @@ -2447,19 +2446,29 @@ class Client::JsonGiveaway final : public td::Jsonable { if (!giveaway_->parameters_->prize_description_.empty()) { object("prize_description", giveaway_->parameters_->prize_description_); } - if (giveaway_->month_count_ > 0) { - object("premium_subscription_month_count", giveaway_->month_count_); + switch (giveaway_->prize_->get_id()) { + case td_api::giveawayPrizePremium::ID: { + auto month_count = static_cast(giveaway_->prize_.get())->month_count_; + if (month_count > 0) { + object("premium_subscription_month_count", month_count); + } + break; + } + case td_api::giveawayPrizeStars::ID: + break; + default: + UNREACHABLE(); } } private: - const td_api::messagePremiumGiveaway *giveaway_; + const td_api::messageGiveaway *giveaway_; const Client *client_; }; class Client::JsonGiveawayWinners final : public td::Jsonable { public: - JsonGiveawayWinners(const td_api::messagePremiumGiveawayWinners *giveaway_winners, const Client *client) + JsonGiveawayWinners(const td_api::messageGiveawayWinners *giveaway_winners, const Client *client) : giveaway_winners_(giveaway_winners), client_(client) { } void store(td::JsonValueScope *scope) const { @@ -2476,8 +2485,19 @@ class Client::JsonGiveawayWinners final : public td::Jsonable { if (giveaway_winners_->was_refunded_) { object("was_refunded", td::JsonTrue()); } - if (giveaway_winners_->month_count_ > 0) { - object("premium_subscription_month_count", giveaway_winners_->month_count_); + switch (giveaway_winners_->prize_->get_id()) { + case td_api::giveawayPrizePremium::ID: { + auto month_count = + static_cast(giveaway_winners_->prize_.get())->month_count_; + if (month_count > 0) { + object("premium_subscription_month_count", month_count); + } + break; + } + case td_api::giveawayPrizeStars::ID: + break; + default: + UNREACHABLE(); } if (!giveaway_winners_->prize_description_.empty()) { object("prize_description", giveaway_winners_->prize_description_); @@ -2490,14 +2510,13 @@ class Client::JsonGiveawayWinners final : public td::Jsonable { } private: - const td_api::messagePremiumGiveawayWinners *giveaway_winners_; + const td_api::messageGiveawayWinners *giveaway_winners_; const Client *client_; }; class Client::JsonGiveawayCompleted final : public td::Jsonable { public: - JsonGiveawayCompleted(const td_api::messagePremiumGiveawayCompleted *giveaway_completed, int64 chat_id, - const Client *client) + JsonGiveawayCompleted(const td_api::messageGiveawayCompleted *giveaway_completed, int64 chat_id, const Client *client) : giveaway_completed_(giveaway_completed), chat_id_(chat_id), client_(client) { } void store(td::JsonValueScope *scope) const { @@ -2514,7 +2533,7 @@ class Client::JsonGiveawayCompleted final : public td::Jsonable { } private: - const td_api::messagePremiumGiveawayCompleted *giveaway_completed_; + const td_api::messageGiveawayCompleted *giveaway_completed_; int64 chat_id_; const Client *client_; }; @@ -2767,13 +2786,13 @@ class Client::JsonExternalReplyInfo final : public td::Jsonable { } case td_api::messageUnsupported::ID: break; - case td_api::messagePremiumGiveaway::ID: { - auto content = static_cast(reply_->content_.get()); + case td_api::messageGiveaway::ID: { + auto content = static_cast(reply_->content_.get()); object("giveaway", JsonGiveaway(content, client_)); break; } - case td_api::messagePremiumGiveawayWinners::ID: { - auto content = static_cast(reply_->content_.get()); + case td_api::messageGiveawayWinners::ID: { + auto content = static_cast(reply_->content_.get()); object("giveaway_winners", JsonGiveawayWinners(content, client_)); break; } @@ -3271,21 +3290,21 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { } case td_api::messagePremiumGiftCode::ID: break; - case td_api::messagePremiumGiveawayCreated::ID: + case td_api::messageGiveawayCreated::ID: object("giveaway_created", JsonEmptyObject()); break; - case td_api::messagePremiumGiveaway::ID: { - auto content = static_cast(message_->content.get()); + case td_api::messageGiveaway::ID: { + auto content = static_cast(message_->content.get()); object("giveaway", JsonGiveaway(content, client_)); break; } - case td_api::messagePremiumGiveawayWinners::ID: { - auto content = static_cast(message_->content.get()); + case td_api::messageGiveawayWinners::ID: { + auto content = static_cast(message_->content.get()); object("giveaway_winners", JsonGiveawayWinners(content, client_)); break; } - case td_api::messagePremiumGiveawayCompleted::ID: { - auto content = static_cast(message_->content.get()); + case td_api::messageGiveawayCompleted::ID: { + auto content = static_cast(message_->content.get()); object("giveaway_completed", JsonGiveawayCompleted(content, message_->chat_id, client_)); break; } @@ -3301,6 +3320,8 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { } case td_api::messageGiftedStars::ID: break; + case td_api::messageGiveawayPrizeStars::ID: + break; default: UNREACHABLE(); } @@ -4142,7 +4163,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { case td_api::starTransactionPartnerGooglePlay::ID: case td_api::starTransactionPartnerUser::ID: case td_api::starTransactionPartnerBusiness::ID: - case td_api::starTransactionPartnerChannel::ID: + case td_api::starTransactionPartnerChat::ID: LOG(ERROR) << "Receive " << to_string(*source_); object("type", "other"); break; @@ -10362,7 +10383,7 @@ td::Status Client::process_send_paid_media_query(PromisedQueryPtr &query) { TRY_RESULT(caption, get_caption(query.get())); auto show_caption_above_media = to_bool(query->arg("show_caption_above_media")); do_send_message(make_object(star_count, std::move(paid_media), std::move(caption), - show_caption_above_media), + show_caption_above_media, td::string()), std::move(query)); return td::Status::OK(); } @@ -13758,10 +13779,10 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr(message->content_.get()) ->old_background_message_id_; - case td_api::messagePremiumGiveawayCompleted::ID: - return static_cast(message->content_.get()) - ->giveaway_message_id_; + case td_api::messageGiveawayCompleted::ID: + return static_cast(message->content_.get())->giveaway_message_id_; case td_api::messagePaymentSuccessful::ID: UNREACHABLE(); return static_cast(0); From c571a9ee5b9c0152b140f38e03f93490a307dfb0 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 11:54:13 +0300 Subject: [PATCH 18/28] Use td_api::getStickerSetName instead of td_api::getStickerSet. --- telegram-bot-api/Client.cpp | 110 +++++++++++++++++++++--------------- telegram-bot-api/Client.h | 2 +- 2 files changed, 65 insertions(+), 47 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index dd31e7f..cc3e12d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5182,10 +5182,10 @@ class Client::TdOnGetStickerSetCallback final : public TdQueryCallback { nullptr); } - CHECK(result->get_id() == td_api::stickerSet::ID); + CHECK(result->get_id() == td_api::text::ID); client_->on_get_sticker_set(set_id_, new_callback_query_user_id_, new_message_chat_id_, new_message_business_connection_id_, new_business_callback_query_user_id_, - move_object_as(result)); + move_object_as(result)); } private: @@ -5199,9 +5199,13 @@ class Client::TdOnGetStickerSetCallback final : public TdQueryCallback { class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCallback { public: - TdOnGetChatCustomEmojiStickerSetCallback(Client *client, int64 chat_id, int64 pinned_message_id, + TdOnGetChatCustomEmojiStickerSetCallback(Client *client, int64 sticker_set_id, int64 chat_id, int64 pinned_message_id, PromisedQueryPtr query) - : client_(client), chat_id_(chat_id), pinned_message_id_(pinned_message_id), query_(std::move(query)) { + : client_(client) + , sticker_set_id_(sticker_set_id) + , chat_id_(chat_id) + , pinned_message_id_(pinned_message_id) + , query_(std::move(query)) { } void on_result(object_ptr result) final { @@ -5212,9 +5216,9 @@ class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCal if (result->get_id() == td_api::error::ID) { supergroup_info->custom_emoji_sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::stickerSet::ID); - auto sticker_set = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set->id_, sticker_set->name_); + CHECK(result->get_id() == td_api::text::ID); + auto sticker_set_name = move_object_as(result); + client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5222,6 +5226,7 @@ class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCal private: Client *client_; + int64 sticker_set_id_; int64 chat_id_; int64 pinned_message_id_; PromisedQueryPtr query_; @@ -5229,9 +5234,13 @@ class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCal class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQueryCallback { public: - TdOnGetChatBusinessStartPageStickerSetCallback(Client *client, int64 chat_id, int64 pinned_message_id, - PromisedQueryPtr query) - : client_(client), chat_id_(chat_id), pinned_message_id_(pinned_message_id), query_(std::move(query)) { + TdOnGetChatBusinessStartPageStickerSetCallback(Client *client, int64 sticker_set_id, int64 chat_id, + int64 pinned_message_id, PromisedQueryPtr query) + : client_(client) + , sticker_set_id_(sticker_set_id) + , chat_id_(chat_id) + , pinned_message_id_(pinned_message_id) + , query_(std::move(query)) { } void on_result(object_ptr result) final { @@ -5245,9 +5254,9 @@ class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQu user_info->business_info->start_page_->sticker_->set_id_ = 0; } } else { - CHECK(result->get_id() == td_api::stickerSet::ID); - auto sticker_set = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set->id_, sticker_set->name_); + CHECK(result->get_id() == td_api::text::ID); + auto sticker_set_name = move_object_as(result); + client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5255,6 +5264,7 @@ class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQu private: Client *client_; + int64 sticker_set_id_; int64 chat_id_; int64 pinned_message_id_; PromisedQueryPtr query_; @@ -5262,8 +5272,13 @@ class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQu class Client::TdOnGetChatStickerSetCallback final : public TdQueryCallback { public: - TdOnGetChatStickerSetCallback(Client *client, int64 chat_id, int64 pinned_message_id, PromisedQueryPtr query) - : client_(client), chat_id_(chat_id), pinned_message_id_(pinned_message_id), query_(std::move(query)) { + TdOnGetChatStickerSetCallback(Client *client, int64 sticker_set_id, int64 chat_id, int64 pinned_message_id, + PromisedQueryPtr query) + : client_(client) + , sticker_set_id_(sticker_set_id) + , chat_id_(chat_id) + , pinned_message_id_(pinned_message_id) + , query_(std::move(query)) { } void on_result(object_ptr result) final { @@ -5274,16 +5289,16 @@ class Client::TdOnGetChatStickerSetCallback final : public TdQueryCallback { if (result->get_id() == td_api::error::ID) { supergroup_info->sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::stickerSet::ID); - auto sticker_set = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set->id_, sticker_set->name_); + CHECK(result->get_id() == td_api::text::ID); + auto sticker_set_name = move_object_as(result); + client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); } auto sticker_set_id = supergroup_info->custom_emoji_sticker_set_id; if (sticker_set_id != 0 && client_->get_sticker_set_name(sticker_set_id).empty()) { - return client_->send_request(make_object(sticker_set_id), + return client_->send_request(make_object(sticker_set_id), td::make_unique( - client_, chat_id_, pinned_message_id_, std::move(query_))); + client_, sticker_set_id, chat_id_, pinned_message_id_, std::move(query_))); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5291,6 +5306,7 @@ class Client::TdOnGetChatStickerSetCallback final : public TdQueryCallback { private: Client *client_; + int64 sticker_set_id_; int64 chat_id_; int64 pinned_message_id_; PromisedQueryPtr query_; @@ -5327,16 +5343,16 @@ class Client::TdOnGetChatPinnedMessageCallback final : public TdQueryCallback { auto sticker_set_id = supergroup_info->sticker_set_id; if (sticker_set_id != 0 && client_->get_sticker_set_name(sticker_set_id).empty()) { - return client_->send_request( - make_object(sticker_set_id), - td::make_unique(client_, chat_id_, pinned_message_id, std::move(query_))); + return client_->send_request(make_object(sticker_set_id), + td::make_unique( + client_, sticker_set_id, chat_id_, pinned_message_id, std::move(query_))); } sticker_set_id = supergroup_info->custom_emoji_sticker_set_id; if (sticker_set_id != 0 && client_->get_sticker_set_name(sticker_set_id).empty()) { - return client_->send_request(make_object(sticker_set_id), + return client_->send_request(make_object(sticker_set_id), td::make_unique( - client_, chat_id_, pinned_message_id, std::move(query_))); + client_, sticker_set_id, chat_id_, pinned_message_id, std::move(query_))); } } else if (chat_info->type == ChatInfo::Type::Private) { auto user_info = client_->get_user_info(chat_info->user_id); @@ -5347,9 +5363,9 @@ class Client::TdOnGetChatPinnedMessageCallback final : public TdQueryCallback { if (sticker != nullptr) { auto sticker_set_id = sticker->set_id_; if (sticker_set_id != 0 && client_->get_sticker_set_name(sticker_set_id).empty()) { - return client_->send_request(make_object(sticker_set_id), + return client_->send_request(make_object(sticker_set_id), td::make_unique( - client_, chat_id_, pinned_message_id, std::move(query_))); + client_, sticker_set_id, chat_id_, pinned_message_id, std::move(query_))); } } } @@ -5825,8 +5841,8 @@ class Client::TdOnReturnStickerSetCallback final : public TdQueryCallback { class Client::TdOnGetStickerSetPromiseCallback final : public TdQueryCallback { public: - TdOnGetStickerSetPromiseCallback(Client *client, td::Promise &&promise) - : client_(client), promise_(std::move(promise)) { + TdOnGetStickerSetPromiseCallback(Client *client, int64 sticker_set_id, td::Promise &&promise) + : client_(client), sticker_set_id_(sticker_set_id), promise_(std::move(promise)) { } void on_result(object_ptr result) final { @@ -5835,14 +5851,15 @@ class Client::TdOnGetStickerSetPromiseCallback final : public TdQueryCallback { return promise_.set_error(td::Status::Error(error->code_, error->message_)); } - CHECK(result->get_id() == td_api::stickerSet::ID); - auto sticker_set = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set->id_, sticker_set->name_); + CHECK(result->get_id() == td_api::text::ID); + auto sticker_set_name = move_object_as(result); + client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); promise_.set_value(td::Unit()); } private: Client *client_; + int64 sticker_set_id_; td::Promise promise_; }; @@ -5874,8 +5891,9 @@ class Client::TdOnGetStickersCallback final : public TdQueryCallback { auto lock = mpas.get_promise(); for (auto sticker_set_id : sticker_set_ids) { - client_->send_request(make_object(sticker_set_id), - td::make_unique(client_, mpas.get_promise())); + client_->send_request( + make_object(sticker_set_id), + td::make_unique(client_, sticker_set_id, mpas.get_promise())); } lock.set_value(td::Unit()); } @@ -6145,7 +6163,7 @@ void Client::on_get_callback_query_message(object_ptr message, void Client::on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id, const td::string &new_message_business_connection_id, - int64 new_business_callback_query_user_id, object_ptr sticker_set) { + int64 new_business_callback_query_user_id, object_ptr sticker_set_name) { if (new_callback_query_user_id != 0) { auto &queue = new_callback_query_queues_[new_callback_query_user_id]; CHECK(queue.has_active_request_); @@ -6178,8 +6196,8 @@ void Client::on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, CHECK(set_id != 0); if (set_id != GREAT_MINDS_SET_ID) { td::string &set_name = sticker_set_names_[set_id]; - if (sticker_set != nullptr) { - set_name = std::move(sticker_set->name_); + if (sticker_set_name != nullptr) { + set_name = std::move(sticker_set_name->text_); } } @@ -13517,7 +13535,7 @@ void Client::process_new_callback_query_queue(int64 user_id, int state) { if (!have_sticker_set_name(message_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(message_sticker_set_id), + make_object(message_sticker_set_id), td::make_unique(this, message_sticker_set_id, user_id, 0, td::string(), 0)); } auto reply_to_message_id = get_same_chat_reply_to_message_id(message_info); @@ -13528,7 +13546,7 @@ void Client::process_new_callback_query_queue(int64 user_id, int state) { if (!have_sticker_set_name(reply_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(reply_sticker_set_id), + make_object(reply_sticker_set_id), td::make_unique(this, reply_sticker_set_id, user_id, 0, td::string(), 0)); } } @@ -13579,7 +13597,7 @@ void Client::process_new_business_callback_query_queue(int64 user_id) { if (!have_sticker_set_name(message_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(message_sticker_set_id), + make_object(message_sticker_set_id), td::make_unique(this, message_sticker_set_id, 0, 0, td::string(), user_id)); } if (message_ref->reply_to_message_ != nullptr) { @@ -13588,7 +13606,7 @@ void Client::process_new_business_callback_query_queue(int64 user_id) { if (!have_sticker_set_name(reply_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(reply_sticker_set_id), + make_object(reply_sticker_set_id), td::make_unique(this, reply_sticker_set_id, 0, 0, td::string(), user_id)); } } @@ -14163,7 +14181,7 @@ void Client::process_new_message_queue(int64 chat_id, int state) { if (!have_sticker_set_name(message_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(message_sticker_set_id), + make_object(message_sticker_set_id), td::make_unique(this, message_sticker_set_id, 0, chat_id, td::string(), 0)); } if (reply_to_message_id > 0) { @@ -14173,7 +14191,7 @@ void Client::process_new_message_queue(int64 chat_id, int state) { if (!have_sticker_set_name(reply_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(reply_sticker_set_id), + make_object(reply_sticker_set_id), td::make_unique(this, reply_sticker_set_id, 0, chat_id, td::string(), 0)); } } @@ -14263,7 +14281,7 @@ void Client::process_new_business_message_queue(const td::string &connection_id) if (!have_sticker_set_name(message_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(message_sticker_set_id), + make_object(message_sticker_set_id), td::make_unique(this, message_sticker_set_id, 0, 0, connection_id, 0)); } if (message_ref->reply_to_message_ != nullptr) { @@ -14272,7 +14290,7 @@ void Client::process_new_business_message_queue(const td::string &connection_id) if (!have_sticker_set_name(reply_sticker_set_id)) { queue.has_active_request_ = true; return send_request( - make_object(reply_sticker_set_id), + make_object(reply_sticker_set_id), td::make_unique(this, reply_sticker_set_id, 0, 0, connection_id, 0)); } } @@ -14426,7 +14444,7 @@ void Client::init_message(MessageInfo *message_info, object_ptr auto sticker_set_id = get_sticker_set_id(message_info->content); if (!have_sticker_set_name(sticker_set_id)) { - send_request(make_object(sticker_set_id), + send_request(make_object(sticker_set_id), td::make_unique(this, sticker_set_id, 0, 0, td::string(), 0)); } } else if (message->content_->get_id() == td_api::messagePoll::ID) { diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index bc12bcb..5b430d9 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -266,7 +266,7 @@ class Client final : public WebhookActor::Callback { void on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id, const td::string &new_message_business_connection_id, - int64 new_business_callback_query_user_id, object_ptr sticker_set); + int64 new_business_callback_query_user_id, object_ptr sticker_set_name); void on_get_sticker_set_name(int64 set_id, const td::string &name); From dfe0dc9881a4b55739026a38e832a80b625f756b Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:01:43 +0300 Subject: [PATCH 19/28] Add Client::on_get_sticker_set_name overload. --- telegram-bot-api/Client.cpp | 22 ++++++++++------------ telegram-bot-api/Client.h | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index cc3e12d..32fc2d4 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5216,9 +5216,7 @@ class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCal if (result->get_id() == td_api::error::ID) { supergroup_info->custom_emoji_sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5254,9 +5252,7 @@ class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQu user_info->business_info->start_page_->sticker_->set_id_ = 0; } } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5289,9 +5285,7 @@ class Client::TdOnGetChatStickerSetCallback final : public TdQueryCallback { if (result->get_id() == td_api::error::ID) { supergroup_info->sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } auto sticker_set_id = supergroup_info->custom_emoji_sticker_set_id; @@ -5851,9 +5845,7 @@ class Client::TdOnGetStickerSetPromiseCallback final : public TdQueryCallback { return promise_.set_error(td::Status::Error(error->code_, error->message_)); } - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); promise_.set_value(td::Unit()); } @@ -6222,6 +6214,12 @@ void Client::on_get_sticker_set_name(int64 set_id, const td::string &name) { } } +void Client::on_get_sticker_set_name(int64 set_id, object_ptr sticker_set_name) { + CHECK(sticker_set_name->get_id() == td_api::text::ID); + auto text = move_object_as(sticker_set_name); + on_get_sticker_set_name(set_id, text->text_); +} + template void Client::check_user_read_access(const UserInfo *user_info, PromisedQueryPtr query, OnSuccess on_success) { CHECK(user_info != nullptr); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 5b430d9..820398b 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -270,6 +270,8 @@ class Client final : public WebhookActor::Callback { void on_get_sticker_set_name(int64 set_id, const td::string &name); + void on_get_sticker_set_name(int64 set_id, object_ptr sticker_set_name); + class TdQueryCallback { public: virtual void on_result(object_ptr result) = 0; From f8c757d07d30898ecc2f04e99cb0a14fdfbbb6aa Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:10:37 +0300 Subject: [PATCH 20/28] Add TransactionPartnerUser.paid_media_payload. --- telegram-bot-api/Client.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 32fc2d4..169672f 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -4148,6 +4148,9 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { object("paid_media", td::json_array(purpose->media_, [client = client_](auto &media) { return JsonPaidMedia(media.get(), client); })); + if (!purpose->payload_.empty()) { + object("paid_media_payload", purpose->payload_); + } break; } default: From 3fdee61a88d92974d7d456ffdb5cdd9463557457 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:13:10 +0300 Subject: [PATCH 21/28] Add sendPaidMedia.payload. --- telegram-bot-api/Client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 169672f..3db925d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -10400,9 +10400,10 @@ td::Status Client::process_send_paid_media_query(PromisedQueryPtr &query) { int32 star_count = get_integer_arg(query.get(), "star_count", 0, 0, 1000000000); TRY_RESULT(paid_media, get_paid_media(query.get(), "media")); TRY_RESULT(caption, get_caption(query.get())); + auto payload = query->arg("payload").str(); auto show_caption_above_media = to_bool(query->arg("show_caption_above_media")); do_send_message(make_object(star_count, std::move(paid_media), std::move(caption), - show_caption_above_media, td::string()), + show_caption_above_media, payload), std::move(query)); return td::Status::OK(); } From 7422214945a17a3face29b3aa58cde7b05de7048 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:27:23 +0300 Subject: [PATCH 22/28] Add GiveawayCreated.prize_star_count. --- telegram-bot-api/Client.cpp | 22 ++++++++++++++++++++-- telegram-bot-api/Client.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 3db925d..468af8d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2419,6 +2419,22 @@ class Client::JsonChatShared final : public td::Jsonable { const Client *client_; }; +class Client::JsonGiveawayCreated final : public td::Jsonable { + public: + explicit JsonGiveawayCreated(const td_api::messageGiveawayCreated *giveaway_created) + : giveaway_created_(giveaway_created) { + } + void store(td::JsonValueScope *scope) const { + auto object = scope->enter_object(); + if (giveaway_created_->star_count_ > 0) { + object("prize_star_count", giveaway_created_->star_count_); + } + } + + private: + const td_api::messageGiveawayCreated *giveaway_created_; +}; + class Client::JsonGiveaway final : public td::Jsonable { public: JsonGiveaway(const td_api::messageGiveaway *giveaway, const Client *client) : giveaway_(giveaway), client_(client) { @@ -3290,9 +3306,11 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { } case td_api::messagePremiumGiftCode::ID: break; - case td_api::messageGiveawayCreated::ID: - object("giveaway_created", JsonEmptyObject()); + case td_api::messageGiveawayCreated::ID: { + auto content = static_cast(message_->content.get()); + object("giveaway_created", JsonGiveawayCreated(content)); break; + } case td_api::messageGiveaway::ID: { auto content = static_cast(message_->content.get()); object("giveaway", JsonGiveaway(content, client_)); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 820398b..dba71ac 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -194,6 +194,7 @@ class Client final : public WebhookActor::Callback { class JsonSharedUser; class JsonUsersShared; class JsonChatShared; + class JsonGiveawayCreated; class JsonGiveaway; class JsonGiveawayWinners; class JsonGiveawayCompleted; From 1548e96656b5214bcf6d98c5f0b6ed758d68977e Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:29:44 +0300 Subject: [PATCH 23/28] Add Giveaway.prize_star_count. --- telegram-bot-api/Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 468af8d..c7c8db7 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2470,8 +2470,13 @@ class Client::JsonGiveaway final : public td::Jsonable { } break; } - case td_api::giveawayPrizeStars::ID: + case td_api::giveawayPrizeStars::ID: { + auto star_count = static_cast(giveaway_->prize_.get())->star_count_; + if (star_count > 0) { + object("prize_star_count", star_count); + } break; + } default: UNREACHABLE(); } From c08e6b3b84092111d4411761575c30c49714c1cb Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:32:03 +0300 Subject: [PATCH 24/28] Add GiveawayWinners.prize_star_count. --- telegram-bot-api/Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index c7c8db7..676011d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2515,8 +2515,13 @@ class Client::JsonGiveawayWinners final : public td::Jsonable { } break; } - case td_api::giveawayPrizeStars::ID: + case td_api::giveawayPrizeStars::ID: { + auto star_count = static_cast(giveaway_winners_->prize_.get())->star_count_; + if (star_count > 0) { + object("prize_star_count", star_count); + } break; + } default: UNREACHABLE(); } From cb41fe9930bb09cece032d26dc5659dbc7e47545 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 13:13:51 +0300 Subject: [PATCH 25/28] Add "purchased_paid_media" update. --- telegram-bot-api/Client.cpp | 28 ++++++++++++++++++++++++++++ telegram-bot-api/Client.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 676011d..9542b2d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3610,6 +3610,23 @@ class Client::JsonPreCheckoutQuery final : public td::Jsonable { const Client *client_; }; +class Client::JsonPaidMediaPurchased final : public td::Jsonable { + public: + JsonPaidMediaPurchased(const td_api::updatePaidMediaPurchased *update, const Client *client) + : update_(update), client_(client) { + } + + void store(td::JsonValueScope *scope) const { + auto object = scope->enter_object(); + object("from", JsonUser(update_->user_id_, client_)); + object("payload", update_->payload_); + } + + private: + const td_api::updatePaidMediaPurchased *update_; + const Client *client_; +}; + class Client::JsonCustomJson final : public td::Jsonable { public: explicit JsonCustomJson(const td::string &json) : json_(json) { @@ -7252,6 +7269,9 @@ void Client::on_update(object_ptr result) { case td_api::updateNewPreCheckoutQuery::ID: add_new_pre_checkout_query(move_object_as(result)); break; + case td_api::updatePaidMediaPurchased::ID: + add_update_purchased_paid_media(move_object_as(result)); + break; case td_api::updateNewCustomEvent::ID: add_new_custom_event(move_object_as(result)); break; @@ -13349,6 +13369,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) { return td::Slice("edited_business_message"); case UpdateType::BusinessMessagesDeleted: return td::Slice("deleted_business_messages"); + case UpdateType::PurchasedPaidMedia: + return td::Slice("purchased_paid_media"); default: UNREACHABLE(); return td::Slice(); @@ -13672,6 +13694,12 @@ void Client::add_new_pre_checkout_query(object_ptrsender_user_id_ + (static_cast(4) << 33)); } +void Client::add_update_purchased_paid_media(object_ptr &&query) { + CHECK(query != nullptr); + add_update(UpdateType::PurchasedPaidMedia, JsonPaidMediaPurchased(query.get(), this), 86400, + query->user_id_ + (static_cast(12) << 33)); +} + void Client::add_new_custom_event(object_ptr &&event) { CHECK(event != nullptr); add_update(UpdateType::CustomEvent, JsonCustomJson(event->event_), 600, 0); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index dba71ac..24176c4 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -148,6 +148,7 @@ class Client final : public WebhookActor::Callback { class JsonInlineCallbackQuery; class JsonShippingQuery; class JsonPreCheckoutQuery; + class JsonPaidMediaPurchased; class JsonBotCommand; class JsonBotMenuButton; class JsonBotName; @@ -1108,6 +1109,8 @@ class Client final : public WebhookActor::Callback { void add_new_pre_checkout_query(object_ptr &&query); + void add_update_purchased_paid_media(object_ptr &&query); + void add_new_custom_event(object_ptr &&event); void add_new_custom_query(object_ptr &&query); @@ -1152,6 +1155,7 @@ class Client final : public WebhookActor::Callback { BusinessMessage, EditedBusinessMessage, BusinessMessagesDeleted, + PurchasedPaidMedia, Size }; From c96ab1328873fb1f9e0ddaed8d3c525a67b4246a Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 30 Aug 2024 11:44:17 +0300 Subject: [PATCH 26/28] Add ChatBoostSourceGiveaway.prize_star_count. --- telegram-bot-api/Client.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 9542b2d..7748516 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3934,6 +3934,9 @@ class Client::JsonChatBoostSource final : public td::Jsonable { const auto *source = static_cast(boost_source_); object("source", "giveaway"); object("giveaway_message_id", as_client_message_id_unchecked(source->giveaway_message_id_)); + if (source->star_count_ > 0) { + object("prize_star_count", source->star_count_); + } if (source->user_id_ != 0) { object("user", JsonUser(source->user_id_, client_)); } else if (source->is_unclaimed_) { From 4acd7d28e619d3f738adfe7c6b9d8ae097247b04 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 30 Aug 2024 11:45:49 +0300 Subject: [PATCH 27/28] Add GiveawayCompleted.is_star_giveaway. --- telegram-bot-api/Client.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 7748516..6095f43 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2551,6 +2551,9 @@ class Client::JsonGiveawayCompleted final : public td::Jsonable { if (giveaway_completed_->unclaimed_prize_count_ > 0) { object("unclaimed_prize_count", giveaway_completed_->unclaimed_prize_count_); } + if (giveaway_completed_->is_star_giveaway_) { + object("is_star_giveaway", td::JsonTrue()); + } const MessageInfo *giveaway_message = client_->get_message(chat_id_, giveaway_completed_->giveaway_message_id_, true); if (giveaway_message != nullptr) { From a186a9ae823d91678ace87ef5b920688c555f5b5 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 6 Sep 2024 16:22:58 +0300 Subject: [PATCH 28/28] Update version to 7.10. --- CMakeLists.txt | 2 +- telegram-bot-api/telegram-bot-api.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e56ca..74f1233 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ if (POLICY CMP0065) cmake_policy(SET CMP0065 NEW) endif() -project(TelegramBotApi VERSION 7.9 LANGUAGES CXX) +project(TelegramBotApi VERSION 7.10 LANGUAGES CXX) if (POLICY CMP0069) option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.") diff --git a/telegram-bot-api/telegram-bot-api.cpp b/telegram-bot-api/telegram-bot-api.cpp index 9035a3b..a234ade 100644 --- a/telegram-bot-api/telegram-bot-api.cpp +++ b/telegram-bot-api/telegram-bot-api.cpp @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) { auto start_time = td::Time::now(); auto shared_data = std::make_shared(); auto parameters = std::make_unique(); - parameters->version_ = "7.9"; + parameters->version_ = "7.10"; parameters->shared_data_ = shared_data; parameters->start_time_ = start_time; auto net_query_stats = td::create_net_query_stats();