2020-04-19 15:30:04 +02:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2020-04-19 15:30:04 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/SpecialStickerSetType.h"
|
|
|
|
|
|
|
|
#include "td/utils/misc.h"
|
2020-04-21 02:29:20 +02:00
|
|
|
#include "td/utils/Slice.h"
|
2021-05-17 14:21:11 +02:00
|
|
|
#include "td/utils/SliceBuilder.h"
|
2020-04-19 15:30:04 +02:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-12-01 17:59:45 +01:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::animated_emoji() {
|
|
|
|
return SpecialStickerSetType("animated_emoji_sticker_set");
|
2020-04-19 15:30:04 +02:00
|
|
|
}
|
|
|
|
|
2021-12-01 17:59:45 +01:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::animated_emoji_click() {
|
|
|
|
return SpecialStickerSetType("animated_emoji_click_sticker_set");
|
2021-09-15 13:44:11 +02:00
|
|
|
}
|
|
|
|
|
2021-12-01 17:59:45 +01:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::animated_dice(const string &emoji) {
|
2020-04-19 20:21:17 +02:00
|
|
|
CHECK(!emoji.empty());
|
2021-12-01 17:59:45 +01:00
|
|
|
return SpecialStickerSetType(PSTRING() << "animated_dice_sticker_set#" << emoji);
|
2020-04-19 15:30:04 +02:00
|
|
|
}
|
|
|
|
|
2022-07-15 14:24:08 +02:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::premium_gifts() {
|
|
|
|
return SpecialStickerSetType("premium_gifts_sticker_set");
|
|
|
|
}
|
|
|
|
|
2022-09-02 12:59:49 +02:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::generic_animations() {
|
|
|
|
return SpecialStickerSetType("generic_animations_sticker_set");
|
|
|
|
}
|
|
|
|
|
|
|
|
SpecialStickerSetType SpecialStickerSetType::default_statuses() {
|
|
|
|
return SpecialStickerSetType("default_statuses_sticker_set");
|
|
|
|
}
|
|
|
|
|
2022-10-27 09:06:13 +02:00
|
|
|
SpecialStickerSetType SpecialStickerSetType::default_topic_icons() {
|
|
|
|
return SpecialStickerSetType("default_topic_icons_sticker_set");
|
|
|
|
}
|
|
|
|
|
2020-04-19 15:30:04 +02:00
|
|
|
SpecialStickerSetType::SpecialStickerSetType(
|
|
|
|
const telegram_api::object_ptr<telegram_api::InputStickerSet> &input_sticker_set) {
|
|
|
|
CHECK(input_sticker_set != nullptr);
|
|
|
|
switch (input_sticker_set->get_id()) {
|
|
|
|
case telegram_api::inputStickerSetAnimatedEmoji::ID:
|
2021-12-01 17:59:45 +01:00
|
|
|
*this = animated_emoji();
|
2020-04-19 15:30:04 +02:00
|
|
|
break;
|
2021-09-15 13:44:11 +02:00
|
|
|
case telegram_api::inputStickerSetAnimatedEmojiAnimations::ID:
|
2021-12-01 17:59:45 +01:00
|
|
|
*this = animated_emoji_click();
|
2021-09-15 13:44:11 +02:00
|
|
|
break;
|
2020-04-19 15:30:04 +02:00
|
|
|
case telegram_api::inputStickerSetDice::ID:
|
2021-12-01 17:59:45 +01:00
|
|
|
*this = animated_dice(static_cast<const telegram_api::inputStickerSetDice *>(input_sticker_set.get())->emoticon_);
|
2020-04-19 15:30:04 +02:00
|
|
|
break;
|
2022-07-15 14:24:08 +02:00
|
|
|
case telegram_api::inputStickerSetPremiumGifts::ID:
|
|
|
|
*this = premium_gifts();
|
|
|
|
break;
|
2022-09-02 12:59:49 +02:00
|
|
|
case telegram_api::inputStickerSetEmojiGenericAnimations::ID:
|
|
|
|
*this = generic_animations();
|
|
|
|
break;
|
|
|
|
case telegram_api::inputStickerSetEmojiDefaultStatuses::ID:
|
|
|
|
*this = default_statuses();
|
|
|
|
break;
|
2022-10-07 17:04:00 +02:00
|
|
|
case telegram_api::inputStickerSetEmojiDefaultTopicIcons::ID:
|
2022-10-27 09:06:13 +02:00
|
|
|
*this = default_topic_icons();
|
2022-10-07 17:04:00 +02:00
|
|
|
break;
|
2023-12-05 10:30:12 +01:00
|
|
|
case telegram_api::inputStickerSetEmojiChannelDefaultStatuses::ID:
|
|
|
|
*this = default_statuses();
|
|
|
|
break;
|
2020-04-19 15:30:04 +02:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-19 20:21:17 +02:00
|
|
|
string SpecialStickerSetType::get_dice_emoji() const {
|
2021-12-01 17:59:45 +01:00
|
|
|
auto prefix = Slice("animated_dice_sticker_set#");
|
|
|
|
if (begins_with(type_, prefix)) {
|
|
|
|
return type_.substr(prefix.size());
|
2020-04-19 20:21:17 +02:00
|
|
|
}
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
2020-04-19 15:30:04 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::InputStickerSet> SpecialStickerSetType::get_input_sticker_set() const {
|
2021-12-01 17:59:45 +01:00
|
|
|
if (*this == animated_emoji()) {
|
2020-04-19 15:30:04 +02:00
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetAnimatedEmoji>();
|
|
|
|
}
|
2021-12-01 17:59:45 +01:00
|
|
|
if (*this == animated_emoji_click()) {
|
2021-09-15 13:44:11 +02:00
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetAnimatedEmojiAnimations>();
|
|
|
|
}
|
2022-07-15 14:24:08 +02:00
|
|
|
if (*this == premium_gifts()) {
|
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetPremiumGifts>();
|
|
|
|
}
|
2022-09-02 12:59:49 +02:00
|
|
|
if (*this == generic_animations()) {
|
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetEmojiGenericAnimations>();
|
|
|
|
}
|
|
|
|
if (*this == default_statuses()) {
|
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetEmojiDefaultStatuses>();
|
|
|
|
}
|
2022-10-27 09:06:13 +02:00
|
|
|
if (*this == default_topic_icons()) {
|
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetEmojiDefaultTopicIcons>();
|
|
|
|
}
|
2020-04-19 20:21:17 +02:00
|
|
|
auto emoji = get_dice_emoji();
|
|
|
|
if (!emoji.empty()) {
|
|
|
|
return telegram_api::make_object<telegram_api::inputStickerSetDice>(emoji);
|
2020-04-19 15:30:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|