Add td_api::getBotInfoDescription.
This commit is contained in:
parent
72bebaf3f5
commit
d7ba7f693b
@ -7604,6 +7604,10 @@ setDefaultChannelAdministratorRights default_channel_administrator_rights:chatAd
|
|||||||
//@param_description New bot's description on the specified language
|
//@param_description New bot's description on the specified language
|
||||||
setBotInfoDescription language_code:string description:string = Ok;
|
setBotInfoDescription language_code:string description:string = Ok;
|
||||||
|
|
||||||
|
//@description Returns the text shown in the chat with the bot if the chat is empty in the given language; bots only
|
||||||
|
//@language_code A two-letter ISO 639-1 language code or an empty string
|
||||||
|
getBotInfoDescription language_code:string = Text;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns all active sessions of the current user
|
//@description Returns all active sessions of the current user
|
||||||
getActiveSessions = Sessions;
|
getActiveSessions = Sessions;
|
||||||
|
@ -628,6 +628,37 @@ class SetBotInfoQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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(const string &language_code, size_t index) {
|
||||||
|
index_ = index;
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::bots_getBotInfo(language_code), {{"me"}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (result.size() != 2) {
|
||||||
|
return on_error(Status::Error(500, "Failed to get bot info"));
|
||||||
|
}
|
||||||
|
promise_.set_value(std::move(result[index_]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ExportContactTokenQuery final : public Td::ResultHandler {
|
class ExportContactTokenQuery final : public Td::ResultHandler {
|
||||||
Promise<td_api::object_ptr<td_api::userLink>> promise_;
|
Promise<td_api::object_ptr<td_api::userLink>> promise_;
|
||||||
|
|
||||||
@ -772,6 +803,11 @@ void set_bot_info_description(Td *td, const string &language_code, const string
|
|||||||
td->create_handler<SetBotInfoQuery>(std::move(promise))->send(language_code, false, string(), true, description);
|
td->create_handler<SetBotInfoQuery>(std::move(promise))->send(language_code, false, string(), true, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void get_bot_info_description(Td *td, 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(language_code, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void export_contact_token(Td *td, Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
void export_contact_token(Td *td, Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
||||||
td->create_handler<ExportContactTokenQuery>(std::move(promise))->send();
|
td->create_handler<ExportContactTokenQuery>(std::move(promise))->send();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ void set_default_channel_administrator_rights(Td *td, AdministratorRights admini
|
|||||||
|
|
||||||
void set_bot_info_description(Td *td, const string &language_code, const string &description, Promise<Unit> &&promise);
|
void set_bot_info_description(Td *td, const string &language_code, const string &description, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void get_bot_info_description(Td *td, const string &language_code, Promise<string> &&promise);
|
||||||
|
|
||||||
void export_contact_token(Td *td, Promise<td_api::object_ptr<td_api::userLink>> &&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);
|
void import_contact_token(Td *td, const string &token, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||||
|
@ -7019,6 +7019,19 @@ void Td::on_request(uint64 id, td_api::setBotInfoDescription &request) {
|
|||||||
set_bot_info_description(this, request.language_code_, request.description_, std::move(promise));
|
set_bot_info_description(this, request.language_code_, request.description_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::getBotInfoDescription &request) {
|
||||||
|
CHECK_IS_BOT();
|
||||||
|
CREATE_REQUEST_PROMISE();
|
||||||
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
promise.set_value(td_api::make_object<td_api::text>(result.move_as_ok()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
get_bot_info_description(this, request.language_code_, std::move(query_promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::setLocation &request) {
|
void Td::on_request(uint64 id, const td_api::setLocation &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
@ -1120,6 +1120,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::setBotInfoDescription &request);
|
void on_request(uint64 id, td_api::setBotInfoDescription &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::getBotInfoDescription &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::setLocation &request);
|
void on_request(uint64 id, const td_api::setLocation &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::setProfilePhoto &request);
|
void on_request(uint64 id, td_api::setProfilePhoto &request);
|
||||||
|
Loading…
Reference in New Issue
Block a user