mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-29 05:35:48 +01:00
Add getMyName.
This commit is contained in:
parent
6561063f52
commit
a894cace6b
@ -205,6 +205,7 @@ bool Client::init_methods() {
|
||||
methods_.emplace("deletemycommands", &Client::process_delete_my_commands_query);
|
||||
methods_.emplace("getmydefaultadministratorrights", &Client::process_get_my_default_administrator_rights_query);
|
||||
methods_.emplace("setmydefaultadministratorrights", &Client::process_set_my_default_administrator_rights_query);
|
||||
methods_.emplace("getmyname", &Client::process_get_my_name_query);
|
||||
methods_.emplace("getmydescription", &Client::process_get_my_description_query);
|
||||
methods_.emplace("setmydescription", &Client::process_set_my_description_query);
|
||||
methods_.emplace("getmyshortdescription", &Client::process_get_my_short_description_query);
|
||||
@ -2591,6 +2592,19 @@ class Client::JsonBotMenuButton final : public td::Jsonable {
|
||||
const td_api::botMenuButton *menu_button_;
|
||||
};
|
||||
|
||||
class Client::JsonBotName final : public td::Jsonable {
|
||||
public:
|
||||
explicit JsonBotName(const td_api::text *text) : text_(text) {
|
||||
}
|
||||
void store(td::JsonValueScope *scope) const {
|
||||
auto object = scope->enter_object();
|
||||
object("name", text_->text_);
|
||||
}
|
||||
|
||||
private:
|
||||
const td_api::text *text_;
|
||||
};
|
||||
|
||||
class Client::JsonBotInfoDescription final : public td::Jsonable {
|
||||
public:
|
||||
explicit JsonBotInfoDescription(const td_api::text *text) : text_(text) {
|
||||
@ -3757,6 +3771,25 @@ class Client::TdOnGetMyDefaultAdministratorRightsCallback final : public TdQuery
|
||||
PromisedQueryPtr query_;
|
||||
};
|
||||
|
||||
class Client::TdOnGetMyNameCallback final : public TdQueryCallback {
|
||||
public:
|
||||
explicit TdOnGetMyNameCallback(PromisedQueryPtr query) : query_(std::move(query)) {
|
||||
}
|
||||
|
||||
void on_result(object_ptr<td_api::Object> result) final {
|
||||
if (result->get_id() == td_api::error::ID) {
|
||||
return fail_query_with_error(std::move(query_), move_object_as<td_api::error>(result));
|
||||
}
|
||||
|
||||
CHECK(result->get_id() == td_api::text::ID);
|
||||
auto text = move_object_as<td_api::text>(result);
|
||||
answer_query(JsonBotName(text.get()), std::move(query_));
|
||||
}
|
||||
|
||||
private:
|
||||
PromisedQueryPtr query_;
|
||||
};
|
||||
|
||||
class Client::TdOnGetMyDescriptionCallback final : public TdQueryCallback {
|
||||
public:
|
||||
explicit TdOnGetMyDescriptionCallback(PromisedQueryPtr query) : query_(std::move(query)) {
|
||||
@ -7871,6 +7904,13 @@ td::Status Client::process_set_my_default_administrator_rights_query(PromisedQue
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status Client::process_get_my_name_query(PromisedQueryPtr &query) {
|
||||
auto language_code = query->arg("language_code");
|
||||
send_request(make_object<td_api::getBotName>(my_id_, language_code.str()),
|
||||
td::make_unique<TdOnGetMyNameCallback>(std::move(query)));
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status Client::process_get_my_description_query(PromisedQueryPtr &query) {
|
||||
auto language_code = query->arg("language_code");
|
||||
send_request(make_object<td_api::getBotInfoDescription>(my_id_, language_code.str()),
|
||||
|
@ -137,6 +137,7 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonPreCheckoutQuery;
|
||||
class JsonBotCommand;
|
||||
class JsonBotMenuButton;
|
||||
class JsonBotName;
|
||||
class JsonBotInfoDescription;
|
||||
class JsonBotInfoShortDescription;
|
||||
class JsonChatAdministratorRights;
|
||||
@ -189,6 +190,7 @@ class Client final : public WebhookActor::Callback {
|
||||
class TdOnGetMenuButtonCallback;
|
||||
class TdOnGetMyCommandsCallback;
|
||||
class TdOnGetMyDefaultAdministratorRightsCallback;
|
||||
class TdOnGetMyNameCallback;
|
||||
class TdOnGetMyDescriptionCallback;
|
||||
class TdOnGetMyShortDescriptionCallback;
|
||||
class TdOnGetChatFullInfoCallback;
|
||||
@ -509,6 +511,7 @@ class Client final : public WebhookActor::Callback {
|
||||
td::Status process_delete_my_commands_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_my_default_administrator_rights_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_my_name_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_my_description_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_my_description_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_my_short_description_query(PromisedQueryPtr &query);
|
||||
|
Loading…
Reference in New Issue
Block a user