Add td_api::removeBusinessConnectedBotFromChat.
This commit is contained in:
parent
69fd5333d7
commit
4c1fa3b45d
@ -9728,6 +9728,9 @@ deleteBusinessConnectedBot bot_user_id:int53 = Ok;
|
||||
//@description Pauses or resumes the connected business bot in a specific chat @chat_id Chat identifier @is_paused Pass true to pause the connected bot in the chat; pass false to resume the bot
|
||||
toggleBusinessConnectedBotChatIsPaused chat_id:int53 is_paused:Bool = Ok;
|
||||
|
||||
//@description Removes the connected business bot from a specific chat by adding the chat to businessRecipients.excluded_chat_ids @chat_id Chat identifier
|
||||
removeBusinessConnectedBotFromChat chat_id:int53 = Ok;
|
||||
|
||||
|
||||
//@description Returns an HTTPS link, which can be used to get information about the current user
|
||||
getUserLink = UserLink;
|
||||
|
@ -113,12 +113,14 @@ class UpdateConnectedBotQuery final : public Td::ResultHandler {
|
||||
|
||||
class ToggleConnectedBotPausedQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit ToggleConnectedBotPausedQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, bool is_paused) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||
if (input_peer == nullptr) {
|
||||
return on_error(Status::Error(400, "Have no write access to the chat"));
|
||||
@ -140,6 +142,45 @@ class ToggleConnectedBotPausedQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ToggleConnectedBotPausedQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class DisablePeerConnectedBotQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit DisablePeerConnectedBotQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||
if (input_peer == nullptr) {
|
||||
return on_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_disablePeerConnectedBot(std::move(input_peer)),
|
||||
{{"me"}, {dialog_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::account_disablePeerConnectedBot>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
if (!result_ptr.ok()) {
|
||||
LOG(INFO) << "Failed to remove business bot";
|
||||
} else {
|
||||
td_->messages_manager_->on_update_dialog_business_bot_removed(dialog_id_);
|
||||
}
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "DisablePeerConnectedBotQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
@ -347,9 +388,9 @@ void BusinessManager::delete_business_connected_bot(UserId bot_user_id, Promise<
|
||||
td_->create_handler<UpdateConnectedBotQuery>(std::move(promise))->send(std::move(input_user));
|
||||
}
|
||||
|
||||
void BusinessManager::toggle_business_connected_bot_chat_is_paused(DialogId dialog_id, bool is_paused,
|
||||
Promise<Unit> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_business_connected_bot_chat_is_paused")) {
|
||||
void BusinessManager::toggle_business_connected_bot_dialog_is_paused(DialogId dialog_id, bool is_paused,
|
||||
Promise<Unit> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_business_connected_bot_dialog_is_paused")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User) {
|
||||
@ -359,6 +400,17 @@ void BusinessManager::toggle_business_connected_bot_chat_is_paused(DialogId dial
|
||||
td_->create_handler<ToggleConnectedBotPausedQuery>(std::move(promise))->send(dialog_id, is_paused);
|
||||
}
|
||||
|
||||
void BusinessManager::remove_business_connected_bot_from_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "remove_business_connected_bot_from_dialog")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User) {
|
||||
return promise.set_error(Status::Error(400, "The chat has no connected bot"));
|
||||
}
|
||||
td_->messages_manager_->on_update_dialog_business_bot_removed(dialog_id);
|
||||
td_->create_handler<DisablePeerConnectedBotQuery>(std::move(promise))->send(dialog_id);
|
||||
}
|
||||
|
||||
void BusinessManager::set_business_location(DialogLocation &&location, Promise<Unit> &&promise) {
|
||||
td_->create_handler<UpdateBusinessLocationQuery>(std::move(promise))->send(std::move(location));
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ class BusinessManager final : public Actor {
|
||||
|
||||
void delete_business_connected_bot(UserId bot_user_id, Promise<Unit> &&promise);
|
||||
|
||||
void toggle_business_connected_bot_chat_is_paused(DialogId dialog_id, bool is_paused, Promise<Unit> &&promise);
|
||||
void toggle_business_connected_bot_dialog_is_paused(DialogId dialog_id, bool is_paused, Promise<Unit> &&promise);
|
||||
|
||||
void remove_business_connected_bot_from_dialog(DialogId dialog_id, Promise<Unit> &&promise);
|
||||
|
||||
void set_business_location(DialogLocation &&location, Promise<Unit> &&promise);
|
||||
|
||||
|
@ -30322,6 +30322,15 @@ void MessagesManager::on_update_dialog_business_bot_is_paused(DialogId dialog_id
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_dialog_business_bot_removed(DialogId dialog_id) {
|
||||
auto d = get_dialog_force(dialog_id, "on_update_dialog_business_bot_removed");
|
||||
CHECK(d != nullptr);
|
||||
if (d->business_bot_manage_bar != nullptr) {
|
||||
d->business_bot_manage_bar = nullptr;
|
||||
send_update_chat_business_bot_manage_bar(d);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_dialog_last_pinned_message_id(DialogId dialog_id, MessageId pinned_message_id) {
|
||||
if (!dialog_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive pinned message in invalid " << dialog_id;
|
||||
|
@ -266,6 +266,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void on_update_dialog_business_bot_is_paused(DialogId dialog_id, bool is_paused);
|
||||
|
||||
void on_update_dialog_business_bot_removed(DialogId dialog_id);
|
||||
|
||||
void on_update_dialog_last_pinned_message_id(DialogId dialog_id, MessageId last_pinned_message_id);
|
||||
|
||||
void on_update_dialog_background(DialogId dialog_id, telegram_api::object_ptr<telegram_api::WallPaper> &&wallpaper);
|
||||
|
@ -7973,8 +7973,14 @@ void Td::on_request(uint64 id, const td_api::deleteBusinessConnectedBot &request
|
||||
void Td::on_request(uint64 id, const td_api::toggleBusinessConnectedBotChatIsPaused &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
business_manager_->toggle_business_connected_bot_chat_is_paused(DialogId(request.chat_id_), request.is_paused_,
|
||||
std::move(promise));
|
||||
business_manager_->toggle_business_connected_bot_dialog_is_paused(DialogId(request.chat_id_), request.is_paused_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::removeBusinessConnectedBotFromChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
business_manager_->remove_business_connected_bot_from_dialog(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
||||
|
@ -1441,6 +1441,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleBusinessConnectedBotChatIsPaused &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::removeBusinessConnectedBotFromChat &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setSupergroupUsername &request);
|
||||
|
||||
void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request);
|
||||
|
@ -6161,6 +6161,10 @@ class CliClient final : public Actor {
|
||||
bool is_paused;
|
||||
get_args(args, chat_id, is_paused);
|
||||
send_request(td_api::make_object<td_api::toggleBusinessConnectedBotChatIsPaused>(chat_id, is_paused));
|
||||
} else if (op == "rbcbfc") {
|
||||
ChatId chat_id;
|
||||
get_args(args, chat_id);
|
||||
send_request(td_api::make_object<td_api::removeBusinessConnectedBotFromChat>(chat_id));
|
||||
} else if (op == "dbcb") {
|
||||
UserId bot_user_id;
|
||||
get_args(args, bot_user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user