Add td_api::toggleBusinessConnectedBotChatIsPaused.
This commit is contained in:
parent
83a3190f2f
commit
e7ff4688fc
@ -1885,7 +1885,7 @@ chatActionBarJoinRequest title:string is_channel:Bool request_date:int32 = ChatA
|
||||
//@description The chat is a private chat administered by a business bot
|
||||
//@bot_user_id User identifier of the bot
|
||||
//@manage_url URL to be opened to manage the bot
|
||||
//@is_bot_paused True, if the bot is paused
|
||||
//@is_bot_paused True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the value of the field
|
||||
//@can_bot_reply True, if the bot can reply
|
||||
chatActionBarManageBusinessBot bot_user_id:int53 manage_url:string is_bot_paused:Bool can_bot_reply:Bool = ChatActionBar;
|
||||
|
||||
@ -9720,6 +9720,9 @@ 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 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 Returns an HTTPS link, which can be used to get information about the current user
|
||||
getUserLink = UserLink;
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#include "td/telegram/BusinessManager.h"
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/BusinessAwayMessage.h"
|
||||
#include "td/telegram/BusinessConnectedBot.h"
|
||||
#include "td/telegram/BusinessGreetingMessage.h"
|
||||
@ -13,7 +14,9 @@
|
||||
#include "td/telegram/BusinessRecipients.h"
|
||||
#include "td/telegram/BusinessWorkHours.h"
|
||||
#include "td/telegram/DialogLocation.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
@ -107,6 +110,39 @@ class UpdateConnectedBotQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class ToggleConnectedBotPausedQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit ToggleConnectedBotPausedQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, bool is_paused) {
|
||||
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_toggleConnectedBotPaused(std::move(input_peer), is_paused), {{"me"}, {dialog_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::account_toggleConnectedBotPaused>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
if (!result_ptr.ok()) {
|
||||
LOG(INFO) << "Failed to toggle business bot is paused";
|
||||
}
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class UpdateBusinessLocationQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogLocation location_;
|
||||
@ -310,6 +346,18 @@ 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")) {
|
||||
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_is_paused(dialog_id, is_paused);
|
||||
td_->create_handler<ToggleConnectedBotPausedQuery>(std::move(promise))->send(dialog_id, is_paused);
|
||||
}
|
||||
|
||||
void BusinessManager::set_business_location(DialogLocation &&location, Promise<Unit> &&promise) {
|
||||
td_->create_handler<UpdateBusinessLocationQuery>(std::move(promise))->send(std::move(location));
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
@ -33,6 +34,8 @@ 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 set_business_location(DialogLocation &&location, Promise<Unit> &&promise);
|
||||
|
||||
void set_business_work_hours(BusinessWorkHours &&work_hours, Promise<Unit> &&promise);
|
||||
|
@ -310,6 +310,14 @@ bool DialogActionBar::on_outgoing_message() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogActionBar::set_business_bot_is_paused(bool is_paused) {
|
||||
if (!business_bot_user_id_.is_valid() || is_business_bot_paused_ == is_paused) {
|
||||
return false;
|
||||
}
|
||||
is_business_bot_paused_ = is_paused;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DialogActionBar::add_dependencies(Dependencies &dependencies) const {
|
||||
dependencies.add(business_bot_user_id_);
|
||||
}
|
||||
|
@ -69,6 +69,8 @@ class DialogActionBar {
|
||||
|
||||
bool on_outgoing_message();
|
||||
|
||||
bool set_business_bot_is_paused(bool is_paused);
|
||||
|
||||
void add_dependencies(Dependencies &dependencies) const;
|
||||
|
||||
template <class StorerT>
|
||||
|
@ -30251,6 +30251,14 @@ void MessagesManager::set_dialog_is_blocked(Dialog *d, bool is_blocked, bool is_
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_dialog_business_bot_is_paused(DialogId dialog_id, bool is_paused) {
|
||||
auto d = get_dialog_force(dialog_id, "on_update_dialog_is_blocked");
|
||||
CHECK(d != nullptr);
|
||||
if (d->action_bar != nullptr && d->action_bar->set_business_bot_is_paused(is_paused)) {
|
||||
send_update_chat_action_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;
|
||||
|
@ -263,6 +263,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void on_update_dialog_is_blocked(DialogId dialog_id, bool is_blocked, bool is_blocked_for_stories);
|
||||
|
||||
void on_update_dialog_business_bot_is_paused(DialogId dialog_id, bool is_paused);
|
||||
|
||||
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);
|
||||
|
@ -7970,6 +7970,13 @@ void Td::on_request(uint64 id, const td_api::deleteBusinessConnectedBot &request
|
||||
business_manager_->delete_business_connected_bot(UserId(request.bot_user_id_), std::move(promise));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
|
@ -1439,6 +1439,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::deleteBusinessConnectedBot &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleBusinessConnectedBotChatIsPaused &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setSupergroupUsername &request);
|
||||
|
||||
void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request);
|
||||
|
@ -6152,10 +6152,15 @@ class CliClient final : public Actor {
|
||||
} else if (op == "sbcb") {
|
||||
UserId bot_user_id;
|
||||
string chat_ids;
|
||||
bool can_reply = false;
|
||||
bool can_reply;
|
||||
get_args(args, bot_user_id, chat_ids, can_reply);
|
||||
send_request(td_api::make_object<td_api::setBusinessConnectedBot>(
|
||||
td_api::make_object<td_api::businessConnectedBot>(bot_user_id, as_business_recipients(chat_ids), can_reply)));
|
||||
} else if (op == "tbcbcip") {
|
||||
ChatId chat_id;
|
||||
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 == "dbcb") {
|
||||
UserId bot_user_id;
|
||||
get_args(args, bot_user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user