From 047a3e9922926a7ab83e72053ecac51041f5beb7 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 21 Dec 2023 22:30:01 +0300 Subject: [PATCH] Support channel emoji status. --- telegram-bot-api/Client.cpp | 29 ++++++++++++++++++++--------- telegram-bot-api/Client.h | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index c55af20..f614082 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -760,12 +760,6 @@ class Client::JsonChat final : public td::Jsonable { object("active_usernames", td::json_array(user_info->active_usernames, [](td::Slice username) { return td::JsonString(username); })); } - if (user_info->emoji_status_custom_emoji_id != 0) { - object("emoji_status_custom_emoji_id", td::to_string(user_info->emoji_status_custom_emoji_id)); - if (user_info->emoji_status_expiration_date != 0) { - object("emoji_status_expiration_date", user_info->emoji_status_expiration_date); - } - } if (!user_info->bio.empty()) { object("bio", user_info->bio); } @@ -922,6 +916,12 @@ class Client::JsonChat final : public td::Jsonable { if (chat_info->message_auto_delete_time != 0) { object("message_auto_delete_time", chat_info->message_auto_delete_time); } + if (chat_info->emoji_status_custom_emoji_id != 0) { + object("emoji_status_custom_emoji_id", td::to_string(chat_info->emoji_status_custom_emoji_id)); + if (chat_info->emoji_status_expiration_date != 0) { + object("emoji_status_expiration_date", chat_info->emoji_status_expiration_date); + } + } if (chat_info->available_reactions != nullptr) { object("available_reactions", td::json_array(chat_info->available_reactions->reactions_, @@ -5978,6 +5978,10 @@ void Client::on_update(object_ptr result) { chat_info->photo_info = std::move(chat->photo_); chat_info->permissions = std::move(chat->permissions_); chat_info->message_auto_delete_time = chat->message_auto_delete_time_; + chat_info->emoji_status_custom_emoji_id = + chat->emoji_status_ != nullptr ? chat->emoji_status_->custom_emoji_id_ : 0; + chat_info->emoji_status_expiration_date = + chat->emoji_status_ != nullptr ? chat->emoji_status_->expiration_date_ : 0; if (chat->available_reactions_->get_id() == td_api::chatAvailableReactionsSome::ID) { chat_info->available_reactions = move_object_as(chat->available_reactions_); } @@ -6016,6 +6020,16 @@ void Client::on_update(object_ptr result) { chat_info->message_auto_delete_time = update->message_auto_delete_time_; break; } + case td_api::updateChatEmojiStatus::ID: { + auto update = move_object_as(result); + auto chat_info = add_chat(update->chat_id_); + CHECK(chat_info->type != ChatInfo::Type::Unknown); + chat_info->emoji_status_custom_emoji_id = + update->emoji_status_ != nullptr ? update->emoji_status_->custom_emoji_id_ : 0; + chat_info->emoji_status_expiration_date = + update->emoji_status_ != nullptr ? update->emoji_status_->expiration_date_ : 0; + break; + } case td_api::updateChatAvailableReactions::ID: { auto update = move_object_as(result); auto chat_info = add_chat(update->chat_id_); @@ -11492,9 +11506,6 @@ void Client::add_user(UserInfo *user_info, object_ptr &&user) { user_info->editable_username = std::move(user->usernames_->editable_username_); } user_info->language_code = std::move(user->language_code_); - user_info->emoji_status_custom_emoji_id = user->emoji_status_ != nullptr ? user->emoji_status_->custom_emoji_id_ : 0; - user_info->emoji_status_expiration_date = user->emoji_status_ != nullptr ? user->emoji_status_->expiration_date_ : 0; - user_info->have_access = user->have_access_; user_info->is_premium = user->is_premium_; user_info->added_to_attachment_menu = user->added_to_attachment_menu_; diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 57ea6a9..4169810 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -769,8 +769,6 @@ class Client final : public WebhookActor::Callback { td::vector active_usernames; td::string editable_username; td::string language_code; - int64 emoji_status_custom_emoji_id; - int32 emoji_status_expiration_date; object_ptr photo; td::string bio; @@ -833,6 +831,8 @@ class Client final : public WebhookActor::Callback { Type type = Type::Unknown; td::string title; int32 message_auto_delete_time = 0; + int64 emoji_status_custom_emoji_id = 0; + int32 emoji_status_expiration_date = 0; int32 accent_color_id = -1; int32 profile_accent_color_id = -1; int64 background_custom_emoji_id = 0;