From 76e5ed31c062ce60b6d3cd7761e4f1a4129882c9 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 14 Aug 2024 00:26:20 +0300 Subject: [PATCH] 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);