From b698019f36ddba5eeac4511042405604b24eaa60 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 19 Apr 2020 21:21:17 +0300 Subject: [PATCH] Add SpecialStickerSetType::get_dice_emoji. GitOrigin-RevId: 6f61536c84fdb19a743d9ed78d5bf514db04c353 --- td/telegram/SpecialStickerSetType.cpp | 14 +++++++++++--- td/telegram/SpecialStickerSetType.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/td/telegram/SpecialStickerSetType.cpp b/td/telegram/SpecialStickerSetType.cpp index 544d1b2c..7e0eed43 100644 --- a/td/telegram/SpecialStickerSetType.cpp +++ b/td/telegram/SpecialStickerSetType.cpp @@ -16,6 +16,7 @@ string SpecialStickerSetType::animated_emoji() { } string SpecialStickerSetType::animated_dice(const string &emoji) { + CHECK(!emoji.empty()); return PSTRING() << "animated_dice_sticker_set#" << emoji; } @@ -35,13 +36,20 @@ SpecialStickerSetType::SpecialStickerSetType( } } +string SpecialStickerSetType::get_dice_emoji() const { + if (begins_with(type_, "animated_dice_sticker_set#")) { + return type_.substr(Slice("animated_dice_sticker_set#").size()); + } + return string(); +} + telegram_api::object_ptr SpecialStickerSetType::get_input_sticker_set() const { if (type_ == "animated_emoji_sticker_set") { return telegram_api::make_object(); } - if (begins_with(type_, "animated_dice_sticker_set#")) { - return telegram_api::make_object( - type_.substr(Slice("animated_dice_sticker_set#").size())); + auto emoji = get_dice_emoji(); + if (!emoji.empty()) { + return telegram_api::make_object(emoji); } UNREACHABLE(); diff --git a/td/telegram/SpecialStickerSetType.h b/td/telegram/SpecialStickerSetType.h index 7788eccc..7597c079 100644 --- a/td/telegram/SpecialStickerSetType.h +++ b/td/telegram/SpecialStickerSetType.h @@ -19,6 +19,8 @@ struct SpecialStickerSetType { static string animated_dice(const string &emoji); + string get_dice_emoji() const; + SpecialStickerSetType() = default; explicit SpecialStickerSetType(const telegram_api::object_ptr &input_sticker_set);