Add getMyShortDescription.

This commit is contained in:
levlam 2023-03-04 22:12:34 +03:00
parent 4df8df2f17
commit 8ee91caacf
2 changed files with 43 additions and 0 deletions

View File

@ -207,6 +207,7 @@ bool Client::init_methods() {
methods_.emplace("setmydefaultadministratorrights", &Client::process_set_my_default_administrator_rights_query); methods_.emplace("setmydefaultadministratorrights", &Client::process_set_my_default_administrator_rights_query);
methods_.emplace("getmydescription", &Client::process_get_my_description_query); methods_.emplace("getmydescription", &Client::process_get_my_description_query);
methods_.emplace("setmydescription", &Client::process_set_my_description_query); methods_.emplace("setmydescription", &Client::process_set_my_description_query);
methods_.emplace("getmyshortdescription", &Client::process_get_my_short_description_query);
methods_.emplace("getchatmenubutton", &Client::process_get_chat_menu_button_query); methods_.emplace("getchatmenubutton", &Client::process_get_chat_menu_button_query);
methods_.emplace("setchatmenubutton", &Client::process_set_chat_menu_button_query); methods_.emplace("setchatmenubutton", &Client::process_set_chat_menu_button_query);
methods_.emplace("getuserprofilephotos", &Client::process_get_user_profile_photos_query); methods_.emplace("getuserprofilephotos", &Client::process_get_user_profile_photos_query);
@ -2595,6 +2596,19 @@ class Client::JsonBotInfoDescription final : public td::Jsonable {
const td_api::text *text_; const td_api::text *text_;
}; };
class Client::JsonBotInfoShortDescription final : public td::Jsonable {
public:
explicit JsonBotInfoShortDescription(const td_api::text *text) : text_(text) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("short_description", text_->text_);
}
private:
const td_api::text *text_;
};
class Client::JsonChatAdministratorRights final : public td::Jsonable { class Client::JsonChatAdministratorRights final : public td::Jsonable {
public: public:
JsonChatAdministratorRights(const td_api::chatAdministratorRights *rights, Client::ChatType chat_type) JsonChatAdministratorRights(const td_api::chatAdministratorRights *rights, Client::ChatType chat_type)
@ -3754,6 +3768,25 @@ class Client::TdOnGetMyDescriptionCallback final : public TdQueryCallback {
PromisedQueryPtr query_; PromisedQueryPtr query_;
}; };
class Client::TdOnGetMyShortDescriptionCallback final : public TdQueryCallback {
public:
explicit TdOnGetMyShortDescriptionCallback(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(JsonBotInfoShortDescription(text.get()), std::move(query_));
}
private:
PromisedQueryPtr query_;
};
class Client::TdOnGetForumTopicInfoCallback final : public TdQueryCallback { class Client::TdOnGetForumTopicInfoCallback final : public TdQueryCallback {
public: public:
explicit TdOnGetForumTopicInfoCallback(PromisedQueryPtr query) : query_(std::move(query)) { explicit TdOnGetForumTopicInfoCallback(PromisedQueryPtr query) : query_(std::move(query)) {
@ -7843,6 +7876,13 @@ td::Status Client::process_set_my_description_query(PromisedQueryPtr &query) {
return td::Status::OK(); return td::Status::OK();
} }
td::Status Client::process_get_my_short_description_query(PromisedQueryPtr &query) {
auto language_code = query->arg("language_code");
send_request(make_object<td_api::getBotInfoShortDescription>(language_code.str()),
td::make_unique<TdOnGetMyShortDescriptionCallback>(std::move(query)));
return td::Status::OK();
}
td::Status Client::process_get_chat_menu_button_query(PromisedQueryPtr &query) { td::Status Client::process_get_chat_menu_button_query(PromisedQueryPtr &query) {
if (query->has_arg("chat_id")) { if (query->has_arg("chat_id")) {
TRY_RESULT(user_id, get_user_id(query.get(), "chat_id")); TRY_RESULT(user_id, get_user_id(query.get(), "chat_id"));

View File

@ -138,6 +138,7 @@ class Client final : public WebhookActor::Callback {
class JsonBotCommand; class JsonBotCommand;
class JsonBotMenuButton; class JsonBotMenuButton;
class JsonBotInfoDescription; class JsonBotInfoDescription;
class JsonBotInfoShortDescription;
class JsonChatAdministratorRights; class JsonChatAdministratorRights;
class JsonChatPhotos; class JsonChatPhotos;
class JsonChatMember; class JsonChatMember;
@ -189,6 +190,7 @@ class Client final : public WebhookActor::Callback {
class TdOnGetMyCommandsCallback; class TdOnGetMyCommandsCallback;
class TdOnGetMyDefaultAdministratorRightsCallback; class TdOnGetMyDefaultAdministratorRightsCallback;
class TdOnGetMyDescriptionCallback; class TdOnGetMyDescriptionCallback;
class TdOnGetMyShortDescriptionCallback;
class TdOnGetChatFullInfoCallback; class TdOnGetChatFullInfoCallback;
class TdOnGetChatStickerSetCallback; class TdOnGetChatStickerSetCallback;
class TdOnGetChatPinnedMessageCallback; class TdOnGetChatPinnedMessageCallback;
@ -509,6 +511,7 @@ class Client final : public WebhookActor::Callback {
td::Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query); td::Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query);
td::Status process_get_my_description_query(PromisedQueryPtr &query); td::Status process_get_my_description_query(PromisedQueryPtr &query);
td::Status process_set_my_description_query(PromisedQueryPtr &query); td::Status process_set_my_description_query(PromisedQueryPtr &query);
td::Status process_get_my_short_description_query(PromisedQueryPtr &query);
td::Status process_get_chat_menu_button_query(PromisedQueryPtr &query); td::Status process_get_chat_menu_button_query(PromisedQueryPtr &query);
td::Status process_set_chat_menu_button_query(PromisedQueryPtr &query); td::Status process_set_chat_menu_button_query(PromisedQueryPtr &query);
td::Status process_get_user_profile_photos_query(PromisedQueryPtr &query); td::Status process_get_user_profile_photos_query(PromisedQueryPtr &query);