Improve td_api::emojiCategory.

This commit is contained in:
levlam 2024-04-25 02:54:25 +03:00
parent 4b078cb36c
commit 394c556f7b
5 changed files with 49 additions and 6 deletions

View File

@ -3695,11 +3695,21 @@ stickerSets total_count:int32 sets:vector<stickerSetInfo> = StickerSets;
trendingStickerSets total_count:int32 sets:vector<stickerSetInfo> is_premium:Bool = TrendingStickerSets; trendingStickerSets total_count:int32 sets:vector<stickerSetInfo> is_premium:Bool = TrendingStickerSets;
//@description Contains a list of similar emoji to search for in getStickers and searchStickers //@class EmojiCategorySource @description Describes source of stickers for an emoji category
//@description The category contains a list of similar emoji to search for in getStickers and searchStickers @emojis List of emojis for search for
emojiCategorySourceSearch emojis:vector<string> = EmojiCategorySource;
//@description The category contains Premium stickers that must be found by getPremiumStickers
emojiCategorySourcePremium = EmojiCategorySource;
//@description Describes an emoji category
//@name Name of the category //@name Name of the category
//@icon Custom emoji sticker, which represents icon of the category //@icon Custom emoji sticker, which represents icon of the category
//@emojis List of emojis in the category //@source Source of stickers for the emoji category
emojiCategory name:string icon:sticker emojis:vector<string> = EmojiCategory; //@is_greeting True, if the category must be shown first when choosing a sticker for the start page
emojiCategory name:string icon:sticker source:EmojiCategorySource is_greeting:Bool = EmojiCategory;
//@description Represents a list of emoji categories @categories List of categories //@description Represents a list of emoji categories @categories List of categories
emojiCategories categories:vector<emojiCategory> = EmojiCategories; emojiCategories categories:vector<emojiCategory> = EmojiCategories;

View File

@ -28,12 +28,14 @@ EmojiGroup::EmojiGroup(telegram_api::object_ptr<telegram_api::EmojiGroup> &&emoj
title_ = std::move(emoji_group->title_); title_ = std::move(emoji_group->title_);
icon_custom_emoji_id_ = CustomEmojiId(emoji_group->icon_emoji_id_); icon_custom_emoji_id_ = CustomEmojiId(emoji_group->icon_emoji_id_);
emojis_ = std::move(emoji_group->emoticons_); emojis_ = std::move(emoji_group->emoticons_);
is_greeting_ = true;
break; break;
} }
case telegram_api::emojiGroupPremium::ID: { case telegram_api::emojiGroupPremium::ID: {
auto emoji_group = telegram_api::move_object_as<telegram_api::emojiGroupPremium>(emoji_group_ptr); auto emoji_group = telegram_api::move_object_as<telegram_api::emojiGroupPremium>(emoji_group_ptr);
title_ = std::move(emoji_group->title_); title_ = std::move(emoji_group->title_);
icon_custom_emoji_id_ = CustomEmojiId(emoji_group->icon_emoji_id_); icon_custom_emoji_id_ = CustomEmojiId(emoji_group->icon_emoji_id_);
is_premium_ = true;
break; break;
} }
default: default:
@ -43,8 +45,15 @@ EmojiGroup::EmojiGroup(telegram_api::object_ptr<telegram_api::EmojiGroup> &&emoj
td_api::object_ptr<td_api::emojiCategory> EmojiGroup::get_emoji_category_object( td_api::object_ptr<td_api::emojiCategory> EmojiGroup::get_emoji_category_object(
StickersManager *stickers_manager) const { StickersManager *stickers_manager) const {
auto source = [&]() -> td_api::object_ptr<td_api::EmojiCategorySource> {
if (is_premium_) {
return td_api::make_object<td_api::emojiCategorySourcePremium>();
}
return td_api::make_object<td_api::emojiCategorySourceSearch>(vector<string>(emojis_));
}();
return td_api::make_object<td_api::emojiCategory>( return td_api::make_object<td_api::emojiCategory>(
title_, stickers_manager->get_custom_emoji_sticker_object(icon_custom_emoji_id_), vector<string>(emojis_)); title_, stickers_manager->get_custom_emoji_sticker_object(icon_custom_emoji_id_), std::move(source),
is_greeting_);
} }
EmojiGroupList::EmojiGroupList(string used_language_codes, int32 hash, EmojiGroupList::EmojiGroupList(string used_language_codes, int32 hash,

View File

@ -20,6 +20,8 @@ class EmojiGroup {
string title_; string title_;
CustomEmojiId icon_custom_emoji_id_; CustomEmojiId icon_custom_emoji_id_;
vector<string> emojis_; vector<string> emojis_;
bool is_greeting_ = false;
bool is_premium_ = false;
public: public:
EmojiGroup() = default; EmojiGroup() = default;

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "td/telegram/EmojiGroup.h" #include "td/telegram/EmojiGroup.h"
#include "td/telegram/Version.h"
#include "td/utils/tl_helpers.h" #include "td/utils/tl_helpers.h"
@ -14,16 +15,36 @@ namespace td {
template <class StorerT> template <class StorerT>
void EmojiGroup::store(StorerT &storer) const { void EmojiGroup::store(StorerT &storer) const {
bool has_emojis = !emojis_.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_greeting_);
STORE_FLAG(is_premium_);
STORE_FLAG(has_emojis);
END_STORE_FLAGS();
td::store(title_, storer); td::store(title_, storer);
td::store(icon_custom_emoji_id_, storer); td::store(icon_custom_emoji_id_, storer);
td::store(emojis_, storer); if (has_emojis) {
td::store(emojis_, storer);
}
} }
template <class ParserT> template <class ParserT>
void EmojiGroup::parse(ParserT &parser) { void EmojiGroup::parse(ParserT &parser) {
bool has_emojis;
if (parser.version() >= static_cast<int32>(Version::SupportMoreEmojiGroups)) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_greeting_);
PARSE_FLAG(is_premium_);
PARSE_FLAG(has_emojis);
END_PARSE_FLAGS();
} else {
has_emojis = true;
}
td::parse(title_, parser); td::parse(title_, parser);
td::parse(icon_custom_emoji_id_, parser); td::parse(icon_custom_emoji_id_, parser);
td::parse(emojis_, parser); if (has_emojis) {
td::parse(emojis_, parser);
}
} }
template <class StorerT> template <class StorerT>

View File

@ -66,6 +66,7 @@ enum class Version : int32 {
AddPageBlockChatLinkFlags, // 50 AddPageBlockChatLinkFlags, // 50
SupportRepliesInOtherChats, SupportRepliesInOtherChats,
SupportMultipleSharedUsers, SupportMultipleSharedUsers,
SupportMoreEmojiGroups,
Next Next
}; };