From dfe0dc9881a4b55739026a38e832a80b625f756b Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Aug 2024 12:01:43 +0300 Subject: [PATCH] Add Client::on_get_sticker_set_name overload. --- telegram-bot-api/Client.cpp | 22 ++++++++++------------ telegram-bot-api/Client.h | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index cc3e12d..32fc2d4 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5216,9 +5216,7 @@ class Client::TdOnGetChatCustomEmojiStickerSetCallback final : public TdQueryCal if (result->get_id() == td_api::error::ID) { supergroup_info->custom_emoji_sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5254,9 +5252,7 @@ class Client::TdOnGetChatBusinessStartPageStickerSetCallback final : public TdQu user_info->business_info->start_page_->sticker_->set_id_ = 0; } } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } answer_query(JsonChat(chat_id_, client_, true, pinned_message_id_), std::move(query_)); @@ -5289,9 +5285,7 @@ class Client::TdOnGetChatStickerSetCallback final : public TdQueryCallback { if (result->get_id() == td_api::error::ID) { supergroup_info->sticker_set_id = 0; } else { - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); } auto sticker_set_id = supergroup_info->custom_emoji_sticker_set_id; @@ -5851,9 +5845,7 @@ class Client::TdOnGetStickerSetPromiseCallback final : public TdQueryCallback { return promise_.set_error(td::Status::Error(error->code_, error->message_)); } - CHECK(result->get_id() == td_api::text::ID); - auto sticker_set_name = move_object_as(result); - client_->on_get_sticker_set_name(sticker_set_id_, sticker_set_name->text_); + client_->on_get_sticker_set_name(sticker_set_id_, std::move(result)); promise_.set_value(td::Unit()); } @@ -6222,6 +6214,12 @@ void Client::on_get_sticker_set_name(int64 set_id, const td::string &name) { } } +void Client::on_get_sticker_set_name(int64 set_id, object_ptr sticker_set_name) { + CHECK(sticker_set_name->get_id() == td_api::text::ID); + auto text = move_object_as(sticker_set_name); + on_get_sticker_set_name(set_id, text->text_); +} + template void Client::check_user_read_access(const UserInfo *user_info, PromisedQueryPtr query, OnSuccess on_success) { CHECK(user_info != nullptr); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 5b430d9..820398b 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -270,6 +270,8 @@ class Client final : public WebhookActor::Callback { void on_get_sticker_set_name(int64 set_id, const td::string &name); + void on_get_sticker_set_name(int64 set_id, object_ptr sticker_set_name); + class TdQueryCallback { public: virtual void on_result(object_ptr result) = 0;