From f43ba612528a50e0700f2fd002fe634acc4fec19 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 4 Mar 2024 18:17:57 +0300 Subject: [PATCH] Add td_api::deleteBusinessConnectedBot. --- td/generate/scheme/td_api.tl | 3 +++ td/telegram/BusinessManager.cpp | 13 +++++++++++++ td/telegram/BusinessManager.h | 3 +++ td/telegram/Td.cpp | 6 ++++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 4 ++++ 6 files changed, 31 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 711198653..858c4ab6c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9411,6 +9411,9 @@ getBusinessConnectedBot = BusinessConnectedBot; //@description Adds or changes business bot that is connected to the current user account @bot Connection settings for the bot setBusinessConnectedBot bot:businessConnectedBot = Ok; +//@description Deletes the business bot that is connected to the current user account @bot_user_id Unique user identifier for the bot +deleteBusinessConnectedBot bot_user_id:int53 = Ok; + //@description Returns an HTTPS link, which can be used to get information about the current user getUserLink = UserLink; diff --git a/td/telegram/BusinessManager.cpp b/td/telegram/BusinessManager.cpp index 6241385d1..b8c45b1d8 100644 --- a/td/telegram/BusinessManager.cpp +++ b/td/telegram/BusinessManager.cpp @@ -80,6 +80,14 @@ class UpdateConnectedBotQuery final : public Td::ResultHandler { {{"me"}})); } + void send(telegram_api::object_ptr &&input_user) { + int32 flags = telegram_api::account_updateConnectedBot::DELETED_MASK; + send_query(G()->net_query_creator().create( + telegram_api::account_updateConnectedBot(flags, false /*ignored*/, false /*ignored*/, std::move(input_user), + BusinessRecipients().get_input_business_recipients(td_)), + {{"me"}})); + } + void on_result(BufferSlice packet) final { auto result_ptr = fetch_result(packet); if (result_ptr.is_error()) { @@ -260,6 +268,11 @@ void BusinessManager::set_business_connected_bot(td_api::object_ptrcreate_handler(std::move(promise))->send(connected_bot, std::move(input_user)); } +void BusinessManager::delete_business_connected_bot(UserId bot_user_id, Promise &&promise) { + TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id)); + td_->create_handler(std::move(promise))->send(std::move(input_user)); +} + void BusinessManager::set_business_location(DialogLocation &&location, Promise &&promise) { td_->create_handler(std::move(promise))->send(std::move(location)); } diff --git a/td/telegram/BusinessManager.h b/td/telegram/BusinessManager.h index ad1c1c65f..b47731b75 100644 --- a/td/telegram/BusinessManager.h +++ b/td/telegram/BusinessManager.h @@ -7,6 +7,7 @@ #pragma once #include "td/telegram/td_api.h" +#include "td/telegram/UserId.h" #include "td/actor/actor.h" @@ -29,6 +30,8 @@ class BusinessManager final : public Actor { void set_business_connected_bot(td_api::object_ptr &&bot, Promise &&promise); + void delete_business_connected_bot(UserId bot_user_id, Promise &&promise); + void set_business_location(DialogLocation &&location, Promise &&promise); void set_business_work_hours(BusinessWorkHours &&work_hours, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 31af943bc..0a0472d54 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7874,6 +7874,12 @@ void Td::on_request(uint64 id, td_api::setBusinessConnectedBot &request) { business_manager_->set_business_connected_bot(std::move(request.bot_), std::move(promise)); } +void Td::on_request(uint64 id, const td_api::deleteBusinessConnectedBot &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + business_manager_->delete_business_connected_bot(UserId(request.bot_user_id_), std::move(promise)); +} + void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.username_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index b0735bfd2..ecacc4820 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1409,6 +1409,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::setBusinessConnectedBot &request); + void on_request(uint64 id, const td_api::deleteBusinessConnectedBot &request); + void on_request(uint64 id, td_api::setSupergroupUsername &request); void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 0e9208985..2f6cea87f 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -6028,6 +6028,10 @@ class CliClient final : public Actor { get_args(args, bot_user_id, chat_ids, can_reply); send_request(td_api::make_object( td_api::make_object(bot_user_id, as_business_recipients(chat_ids), can_reply))); + } else if (op == "dbcb") { + UserId bot_user_id; + get_args(args, bot_user_id); + send_request(td_api::make_object(bot_user_id)); } else if (op == "sco") { SearchQuery query; get_args(args, query);