Support new special sticker set types.

This commit is contained in:
levlam 2022-09-02 13:59:49 +03:00
parent e212d9c62a
commit 899ceecab1
4 changed files with 50 additions and 5 deletions

View File

@ -29,6 +29,14 @@ SpecialStickerSetType SpecialStickerSetType::premium_gifts() {
return SpecialStickerSetType("premium_gifts_sticker_set");
}
SpecialStickerSetType SpecialStickerSetType::generic_animations() {
return SpecialStickerSetType("generic_animations_sticker_set");
}
SpecialStickerSetType SpecialStickerSetType::default_statuses() {
return SpecialStickerSetType("default_statuses_sticker_set");
}
SpecialStickerSetType::SpecialStickerSetType(
const telegram_api::object_ptr<telegram_api::InputStickerSet> &input_sticker_set) {
CHECK(input_sticker_set != nullptr);
@ -45,6 +53,12 @@ SpecialStickerSetType::SpecialStickerSetType(
case telegram_api::inputStickerSetPremiumGifts::ID:
*this = premium_gifts();
break;
case telegram_api::inputStickerSetEmojiGenericAnimations::ID:
*this = generic_animations();
break;
case telegram_api::inputStickerSetEmojiDefaultStatuses::ID:
*this = default_statuses();
break;
default:
UNREACHABLE();
break;
@ -69,6 +83,12 @@ telegram_api::object_ptr<telegram_api::InputStickerSet> SpecialStickerSetType::g
if (*this == premium_gifts()) {
return telegram_api::make_object<telegram_api::inputStickerSetPremiumGifts>();
}
if (*this == generic_animations()) {
return telegram_api::make_object<telegram_api::inputStickerSetEmojiGenericAnimations>();
}
if (*this == default_statuses()) {
return telegram_api::make_object<telegram_api::inputStickerSetEmojiDefaultStatuses>();
}
auto emoji = get_dice_emoji();
if (!emoji.empty()) {
return telegram_api::make_object<telegram_api::inputStickerSetDice>(emoji);

View File

@ -31,6 +31,10 @@ class SpecialStickerSetType {
static SpecialStickerSetType premium_gifts();
static SpecialStickerSetType generic_animations();
static SpecialStickerSetType default_statuses();
string get_dice_emoji() const;
bool is_empty() const {

View File

@ -1417,7 +1417,6 @@ void StickersManager::init() {
is_inited_ = true;
{
// add animated emoji sticker set
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_emoji());
if (G()->is_test_dc()) {
init_special_sticker_set(sticker_set, 1258816259751954, 4879754868529595811, "emojies");
@ -1427,13 +1426,21 @@ void StickersManager::init() {
load_special_sticker_set_info_from_binlog(sticker_set);
}
if (!G()->is_test_dc()) {
// add animated emoji click sticker set
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_emoji_click());
load_special_sticker_set_info_from_binlog(sticker_set);
}
// add premium gifts sticker set
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::premium_gifts());
load_special_sticker_set_info_from_binlog(sticker_set);
{
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::premium_gifts());
load_special_sticker_set_info_from_binlog(sticker_set);
}
{
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::generic_animations());
load_special_sticker_set_info_from_binlog(sticker_set);
}
{
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::default_statuses());
load_special_sticker_set_info_from_binlog(sticker_set);
}
dice_emojis_str_ =
td_->option_manager_->get_option_string("dice_emojis", "🎲\x01🎯\x01🏀\x01\x01⚽️\x01🎰\x01🎳");
@ -1656,6 +1663,12 @@ void StickersManager::on_load_special_sticker_set(const SpecialStickerSetType &t
try_update_premium_gift_messages();
return;
}
if (type == SpecialStickerSetType::generic_animations()) {
return;
}
if (type == SpecialStickerSetType::default_statuses()) {
return;
}
CHECK(special_sticker_set.id_.is_valid());
auto sticker_set = get_sticker_set(special_sticker_set.id_);
@ -2739,6 +2752,8 @@ StickerSetId StickersManager::get_sticker_set_id(const tl_object_ptr<telegram_ap
case telegram_api::inputStickerSetAnimatedEmoji::ID:
case telegram_api::inputStickerSetAnimatedEmojiAnimations::ID:
case telegram_api::inputStickerSetPremiumGifts::ID:
case telegram_api::inputStickerSetEmojiGenericAnimations::ID:
case telegram_api::inputStickerSetEmojiDefaultStatuses::ID:
LOG(ERROR) << "Receive special sticker set " << to_string(set_ptr);
return add_special_sticker_set(SpecialStickerSetType(set_ptr)).id_;
case telegram_api::inputStickerSetDice::ID:
@ -2769,6 +2784,8 @@ StickerSetId StickersManager::add_sticker_set(tl_object_ptr<telegram_api::InputS
case telegram_api::inputStickerSetAnimatedEmoji::ID:
case telegram_api::inputStickerSetAnimatedEmojiAnimations::ID:
case telegram_api::inputStickerSetPremiumGifts::ID:
case telegram_api::inputStickerSetEmojiGenericAnimations::ID:
case telegram_api::inputStickerSetEmojiDefaultStatuses::ID:
LOG(ERROR) << "Receive special sticker set " << to_string(set_ptr);
return add_special_sticker_set(SpecialStickerSetType(set_ptr)).id_;
case telegram_api::inputStickerSetDice::ID:
@ -2964,6 +2981,8 @@ StickerSetId StickersManager::on_get_input_sticker_set(FileId sticker_file_id,
case telegram_api::inputStickerSetAnimatedEmoji::ID:
case telegram_api::inputStickerSetAnimatedEmojiAnimations::ID:
case telegram_api::inputStickerSetPremiumGifts::ID:
case telegram_api::inputStickerSetEmojiGenericAnimations::ID:
case telegram_api::inputStickerSetEmojiDefaultStatuses::ID:
return add_special_sticker_set(SpecialStickerSetType(set_ptr)).id_;
case telegram_api::inputStickerSetDice::ID:
return StickerSetId();

View File

@ -1721,6 +1721,8 @@ void UpdatesManager::try_reload_data() {
td_->stickers_manager_->reload_special_sticker_set_by_type(SpecialStickerSetType::animated_emoji());
td_->stickers_manager_->reload_special_sticker_set_by_type(SpecialStickerSetType::animated_emoji_click());
td_->stickers_manager_->reload_special_sticker_set_by_type(SpecialStickerSetType::premium_gifts());
td_->stickers_manager_->reload_special_sticker_set_by_type(SpecialStickerSetType::generic_animations());
td_->stickers_manager_->reload_special_sticker_set_by_type(SpecialStickerSetType::default_statuses());
schedule_data_reload();
}