Move bot-related methods to BotInfoManager.

This commit is contained in:
levlam 2023-04-16 23:25:52 +03:00
parent 4f916a4d8e
commit 9263db3146
5 changed files with 295 additions and 282 deletions

View File

@ -6,11 +6,9 @@
//
#include "td/telegram/Account.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DeviceTokenManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
@ -525,204 +523,6 @@ class ResetWebAuthorizationsQuery final : public Td::ResultHandler {
}
};
class SetBotGroupDefaultAdminRightsQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit SetBotGroupDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(AdministratorRights administrator_rights) {
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotGroupDefaultAdminRights(administrator_rights.get_chat_admin_rights()), {{"me"}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotGroupDefaultAdminRights>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set group default administrator rights";
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_value(Unit());
}
void on_error(Status status) final {
if (status.message() == "RIGHTS_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_error(std::move(status));
}
};
class SetBotBroadcastDefaultAdminRightsQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit SetBotBroadcastDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(AdministratorRights administrator_rights) {
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotBroadcastDefaultAdminRights(administrator_rights.get_chat_admin_rights()), {{"me"}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotBroadcastDefaultAdminRights>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set channel default administrator rights";
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_value(Unit());
}
void on_error(Status status) final {
if (status.message() == "RIGHTS_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_error(std::move(status));
}
};
static Result<telegram_api::object_ptr<telegram_api::InputUser>> get_bot_input_user(const Td *td, UserId bot_user_id) {
if (td->auth_manager_->is_bot()) {
if (bot_user_id != UserId() && bot_user_id != td->contacts_manager_->get_my_id()) {
return Status::Error(400, "Invalid bot user identifier specified");
}
} else {
TRY_RESULT(bot_data, td->contacts_manager_->get_bot_data(bot_user_id));
if (!bot_data.can_be_edited) {
return Status::Error(400, "The bot can't be edited");
}
return td->contacts_manager_->get_input_user(bot_user_id);
}
return nullptr;
}
class SetBotInfoQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
UserId bot_user_id_;
bool set_name_ = false;
void invalidate_bot_info() {
if (!set_name_) {
td_->contacts_manager_->invalidate_user_full(bot_user_id_);
}
}
public:
explicit SetBotInfoQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(UserId bot_user_id, const string &language_code, bool set_name, const string &name, bool set_about,
const string &about, bool set_description, const string &description) {
int32 flags = 0;
if (set_name) {
flags |= telegram_api::bots_setBotInfo::NAME_MASK;
}
if (set_about) {
flags |= telegram_api::bots_setBotInfo::ABOUT_MASK;
}
if (set_description) {
flags |= telegram_api::bots_setBotInfo::DESCRIPTION_MASK;
}
auto r_input_user = get_bot_input_user(td_, bot_user_id);
if (r_input_user.is_error()) {
return on_error(r_input_user.move_as_error());
}
if (r_input_user.ok() != nullptr) {
flags |= telegram_api::bots_setBotInfo::BOT_MASK;
bot_user_id_ = bot_user_id;
} else {
bot_user_id_ = td_->contacts_manager_->get_my_id();
}
set_name_ = set_name;
invalidate_bot_info();
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotInfo(flags, r_input_user.move_as_ok(), language_code, name, about, description),
{{bot_user_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotInfo>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set bot info";
if (set_name_) {
td_->contacts_manager_->reload_user(bot_user_id_, std::move(promise_));
} else {
invalidate_bot_info();
if (td_->auth_manager_->is_bot()) {
// invalidation is enough for bots
promise_.set_value(Unit());
} else {
td_->contacts_manager_->reload_user_full(bot_user_id_, std::move(promise_));
}
}
}
void on_error(Status status) final {
invalidate_bot_info();
promise_.set_error(std::move(status));
}
};
class GetBotInfoQuery final : public Td::ResultHandler {
Promise<string> promise_;
size_t index_ = 0;
public:
explicit GetBotInfoQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
}
void send(UserId bot_user_id, const string &language_code, size_t index) {
index_ = index;
int32 flags = 0;
auto r_input_user = get_bot_input_user(td_, bot_user_id);
if (r_input_user.is_error()) {
return on_error(r_input_user.move_as_error());
}
if (r_input_user.ok() != nullptr) {
flags |= telegram_api::bots_getBotInfo::BOT_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::bots_getBotInfo(flags, r_input_user.move_as_ok(), language_code), {{bot_user_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_getBotInfo>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
switch (index_) {
case 0:
return promise_.set_value(std::move(result->about_));
case 1:
return promise_.set_value(std::move(result->description_));
case 2:
return promise_.set_value(std::move(result->name_));
default:
UNREACHABLE();
}
}
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
class ExportContactTokenQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::userLink>> promise_;
@ -850,53 +650,6 @@ void disconnect_all_websites(Td *td, Promise<Unit> &&promise) {
td->create_handler<ResetWebAuthorizationsQuery>(std::move(promise))->send();
}
void set_default_group_administrator_rights(Td *td, AdministratorRights administrator_rights, Promise<Unit> &&promise) {
td->contacts_manager_->invalidate_user_full(td->contacts_manager_->get_my_id());
td->create_handler<SetBotGroupDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
}
void set_default_channel_administrator_rights(Td *td, AdministratorRights administrator_rights,
Promise<Unit> &&promise) {
td->contacts_manager_->invalidate_user_full(td->contacts_manager_->get_my_id());
td->create_handler<SetBotBroadcastDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
}
void set_bot_name(Td *td, UserId bot_user_id, const string &language_code, const string &name,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, true, name, false, string(), false, string());
}
void get_bot_name(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 2);
}
void set_bot_info_description(Td *td, UserId bot_user_id, const string &language_code, const string &description,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, false, string(), false, string(), true, description);
}
void get_bot_info_description(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 1);
}
void set_bot_info_about(Td *td, UserId bot_user_id, const string &language_code, const string &about,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, false, string(), true, about, false, string());
}
void get_bot_info_about(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 0);
}
void export_contact_token(Td *td, Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
td->create_handler<ExportContactTokenQuery>(std::move(promise))->send();
}

View File

@ -6,9 +6,7 @@
//
#pragma once
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/td_api.h"
#include "td/telegram/UserId.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
@ -46,25 +44,6 @@ void disconnect_website(Td *td, int64 website_id, Promise<Unit> &&promise);
void disconnect_all_websites(Td *td, Promise<Unit> &&promise);
void set_default_group_administrator_rights(Td *td, AdministratorRights administrator_rights, Promise<Unit> &&promise);
void set_default_channel_administrator_rights(Td *td, AdministratorRights administrator_rights,
Promise<Unit> &&promise);
void set_bot_name(Td *td, UserId bot_user_id, const string &language_code, const string &name, Promise<Unit> &&promise);
void get_bot_name(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise);
void set_bot_info_description(Td *td, UserId bot_user_id, const string &language_code, const string &description,
Promise<Unit> &&promise);
void get_bot_info_description(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise);
void set_bot_info_about(Td *td, UserId bot_user_id, const string &language_code, const string &about,
Promise<Unit> &&promise);
void get_bot_info_about(Td *td, UserId bot_user_id, const string &language_code, Promise<string> &&promise);
void export_contact_token(Td *td, Promise<td_api::object_ptr<td_api::userLink>> &&promise);
void import_contact_token(Td *td, const string &token, Promise<td_api::object_ptr<td_api::user>> &&promise);

View File

@ -6,8 +6,218 @@
//
#include "td/telegram/BotInfoManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"
namespace td {
class SetBotGroupDefaultAdminRightsQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit SetBotGroupDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(AdministratorRights administrator_rights) {
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotGroupDefaultAdminRights(administrator_rights.get_chat_admin_rights()), {{"me"}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotGroupDefaultAdminRights>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set group default administrator rights";
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_value(Unit());
}
void on_error(Status status) final {
if (status.message() == "RIGHTS_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_error(std::move(status));
}
};
class SetBotBroadcastDefaultAdminRightsQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit SetBotBroadcastDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(AdministratorRights administrator_rights) {
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotBroadcastDefaultAdminRights(administrator_rights.get_chat_admin_rights()), {{"me"}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotBroadcastDefaultAdminRights>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set channel default administrator rights";
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_value(Unit());
}
void on_error(Status status) final {
if (status.message() == "RIGHTS_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
promise_.set_error(std::move(status));
}
};
static Result<telegram_api::object_ptr<telegram_api::InputUser>> get_bot_input_user(const Td *td, UserId bot_user_id) {
if (td->auth_manager_->is_bot()) {
if (bot_user_id != UserId() && bot_user_id != td->contacts_manager_->get_my_id()) {
return Status::Error(400, "Invalid bot user identifier specified");
}
} else {
TRY_RESULT(bot_data, td->contacts_manager_->get_bot_data(bot_user_id));
if (!bot_data.can_be_edited) {
return Status::Error(400, "The bot can't be edited");
}
return td->contacts_manager_->get_input_user(bot_user_id);
}
return nullptr;
}
class SetBotInfoQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
UserId bot_user_id_;
bool set_name_ = false;
void invalidate_bot_info() {
if (!set_name_) {
td_->contacts_manager_->invalidate_user_full(bot_user_id_);
}
}
public:
explicit SetBotInfoQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(UserId bot_user_id, const string &language_code, bool set_name, const string &name, bool set_about,
const string &about, bool set_description, const string &description) {
int32 flags = 0;
if (set_name) {
flags |= telegram_api::bots_setBotInfo::NAME_MASK;
}
if (set_about) {
flags |= telegram_api::bots_setBotInfo::ABOUT_MASK;
}
if (set_description) {
flags |= telegram_api::bots_setBotInfo::DESCRIPTION_MASK;
}
auto r_input_user = get_bot_input_user(td_, bot_user_id);
if (r_input_user.is_error()) {
return on_error(r_input_user.move_as_error());
}
if (r_input_user.ok() != nullptr) {
flags |= telegram_api::bots_setBotInfo::BOT_MASK;
bot_user_id_ = bot_user_id;
} else {
bot_user_id_ = td_->contacts_manager_->get_my_id();
}
set_name_ = set_name;
invalidate_bot_info();
send_query(G()->net_query_creator().create(
telegram_api::bots_setBotInfo(flags, r_input_user.move_as_ok(), language_code, name, about, description),
{{bot_user_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotInfo>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to set bot info";
if (set_name_) {
td_->contacts_manager_->reload_user(bot_user_id_, std::move(promise_));
} else {
invalidate_bot_info();
if (td_->auth_manager_->is_bot()) {
// invalidation is enough for bots
promise_.set_value(Unit());
} else {
td_->contacts_manager_->reload_user_full(bot_user_id_, std::move(promise_));
}
}
}
void on_error(Status status) final {
invalidate_bot_info();
promise_.set_error(std::move(status));
}
};
class GetBotInfoQuery final : public Td::ResultHandler {
Promise<string> promise_;
size_t index_ = 0;
public:
explicit GetBotInfoQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
}
void send(UserId bot_user_id, const string &language_code, size_t index) {
index_ = index;
int32 flags = 0;
auto r_input_user = get_bot_input_user(td_, bot_user_id);
if (r_input_user.is_error()) {
return on_error(r_input_user.move_as_error());
}
if (r_input_user.ok() != nullptr) {
flags |= telegram_api::bots_getBotInfo::BOT_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::bots_getBotInfo(flags, r_input_user.move_as_ok(), language_code), {{bot_user_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_getBotInfo>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
switch (index_) {
case 0:
return promise_.set_value(std::move(result->about_));
case 1:
return promise_.set_value(std::move(result->description_));
case 2:
return promise_.set_value(std::move(result->name_));
default:
UNREACHABLE();
}
}
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
BotInfoManager::BotInfoManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
@ -15,4 +225,53 @@ void BotInfoManager::tear_down() {
parent_.reset();
}
void BotInfoManager::set_default_group_administrator_rights(AdministratorRights administrator_rights,
Promise<Unit> &&promise) {
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
td_->create_handler<SetBotGroupDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
}
void BotInfoManager::set_default_channel_administrator_rights(AdministratorRights administrator_rights,
Promise<Unit> &&promise) {
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
td_->create_handler<SetBotBroadcastDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
}
void BotInfoManager::set_bot_name(UserId bot_user_id, const string &language_code, const string &name,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, true, name, false, string(), false, string());
}
void BotInfoManager::get_bot_name(UserId bot_user_id, const string &language_code, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 2);
}
void BotInfoManager::set_bot_info_description(UserId bot_user_id, const string &language_code,
const string &description, Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, false, string(), false, string(), true, description);
}
void BotInfoManager::get_bot_info_description(UserId bot_user_id, const string &language_code,
Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 1);
}
void BotInfoManager::set_bot_info_about(UserId bot_user_id, const string &language_code, const string &about,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<SetBotInfoQuery>(std::move(promise))
->send(bot_user_id, language_code, false, string(), true, about, false, string());
}
void BotInfoManager::get_bot_info_about(UserId bot_user_id, const string &language_code, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
td_->create_handler<GetBotInfoQuery>(std::move(promise))->send(bot_user_id, language_code, 0);
}
} // namespace td

View File

@ -6,9 +6,13 @@
//
#pragma once
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
namespace td {
@ -18,6 +22,24 @@ class BotInfoManager final : public Actor {
public:
BotInfoManager(Td *td, ActorShared<> parent);
void set_default_group_administrator_rights(AdministratorRights administrator_rights, Promise<Unit> &&promise);
void set_default_channel_administrator_rights(AdministratorRights administrator_rights, Promise<Unit> &&promise);
void set_bot_name(UserId bot_user_id, const string &language_code, const string &name, Promise<Unit> &&promise);
void get_bot_name(UserId bot_user_id, const string &language_code, Promise<string> &&promise);
void set_bot_info_description(UserId bot_user_id, const string &language_code, const string &description,
Promise<Unit> &&promise);
void get_bot_info_description(UserId bot_user_id, const string &language_code, Promise<string> &&promise);
void set_bot_info_about(UserId bot_user_id, const string &language_code, const string &about,
Promise<Unit> &&promise);
void get_bot_info_about(UserId bot_user_id, const string &language_code, Promise<string> &&promise);
private:
void tear_down() final;

View File

@ -7059,23 +7059,22 @@ void Td::on_request(uint64 id, const td_api::getMenuButton &request) {
void Td::on_request(uint64 id, const td_api::setDefaultGroupAdministratorRights &request) {
CHECK_IS_BOT();
CREATE_OK_REQUEST_PROMISE();
set_default_group_administrator_rights(
this, AdministratorRights(request.default_group_administrator_rights_, ChannelType::Megagroup),
std::move(promise));
bot_info_manager_->set_default_group_administrator_rights(
AdministratorRights(request.default_group_administrator_rights_, ChannelType::Megagroup), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setDefaultChannelAdministratorRights &request) {
CHECK_IS_BOT();
CREATE_OK_REQUEST_PROMISE();
set_default_channel_administrator_rights(
this, AdministratorRights(request.default_channel_administrator_rights_, ChannelType::Broadcast),
std::move(promise));
bot_info_manager_->set_default_channel_administrator_rights(
AdministratorRights(request.default_channel_administrator_rights_, ChannelType::Broadcast), std::move(promise));
}
void Td::on_request(uint64 id, td_api::setBotName &request) {
CLEAN_INPUT_STRING(request.name_);
CREATE_OK_REQUEST_PROMISE();
set_bot_name(this, UserId(request.bot_user_id_), request.language_code_, request.name_, std::move(promise));
bot_info_manager_->set_bot_name(UserId(request.bot_user_id_), request.language_code_, request.name_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getBotName &request) {
@ -7087,7 +7086,7 @@ void Td::on_request(uint64 id, const td_api::getBotName &request) {
promise.set_value(td_api::make_object<td_api::text>(result.move_as_ok()));
}
});
get_bot_name(this, UserId(request.bot_user_id_), request.language_code_, std::move(query_promise));
bot_info_manager_->get_bot_name(UserId(request.bot_user_id_), request.language_code_, std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::setBotProfilePhoto &request) {
@ -7116,8 +7115,8 @@ void Td::on_request(uint64 id, td_api::reorderActiveBotUsernames &request) {
void Td::on_request(uint64 id, td_api::setBotInfoDescription &request) {
CLEAN_INPUT_STRING(request.description_);
CREATE_OK_REQUEST_PROMISE();
set_bot_info_description(this, UserId(request.bot_user_id_), request.language_code_, request.description_,
std::move(promise));
bot_info_manager_->set_bot_info_description(UserId(request.bot_user_id_), request.language_code_,
request.description_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getBotInfoDescription &request) {
@ -7129,14 +7128,15 @@ void Td::on_request(uint64 id, const td_api::getBotInfoDescription &request) {
promise.set_value(td_api::make_object<td_api::text>(result.move_as_ok()));
}
});
get_bot_info_description(this, UserId(request.bot_user_id_), request.language_code_, std::move(query_promise));
bot_info_manager_->get_bot_info_description(UserId(request.bot_user_id_), request.language_code_,
std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::setBotInfoShortDescription &request) {
CLEAN_INPUT_STRING(request.short_description_);
CREATE_OK_REQUEST_PROMISE();
set_bot_info_about(this, UserId(request.bot_user_id_), request.language_code_, request.short_description_,
std::move(promise));
bot_info_manager_->set_bot_info_about(UserId(request.bot_user_id_), request.language_code_,
request.short_description_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getBotInfoShortDescription &request) {
@ -7148,7 +7148,7 @@ void Td::on_request(uint64 id, const td_api::getBotInfoShortDescription &request
promise.set_value(td_api::make_object<td_api::text>(result.move_as_ok()));
}
});
get_bot_info_about(this, UserId(request.bot_user_id_), request.language_code_, std::move(query_promise));
bot_info_manager_->get_bot_info_about(UserId(request.bot_user_id_), request.language_code_, std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::setLocation &request) {