Add class td_api::animatedEmoji.

This commit is contained in:
levlam 2021-10-26 16:15:01 +03:00
parent d019d89d39
commit 9addfaf6fe
4 changed files with 20 additions and 19 deletions

View File

@ -298,6 +298,12 @@ videoNote duration:int32 length:int32 minithumbnail:minithumbnail thumbnail:thum
//@waveform A waveform representation of the voice note in 5-bit format @mime_type MIME type of the file; as defined by the sender @voice File containing the voice note
voiceNote duration:int32 waveform:bytes mime_type:string voice:file = VoiceNote;
//@description Describes an animated representation of an emoji
//@sticker Animated sticker for the emoji
//@color_replacements List of colors to be replaced while the sticker is rendered
//@sound File containing the sound to be played when the animated emoji is clicked if any; may be null. The sound is encoded with the Opus codec, and stored inside an OGG container
animatedEmoji sticker:sticker color_replacements:vector<colorReplacement> sound:file = AnimatedEmoji;
//@description Describes a user contact @phone_number Phone number of the user @first_name First name of the user; 1-255 characters in length @last_name Last name of the user @vcard Additional data about the user in a form of vCard; 0-2048 bytes in length @user_id Identifier of the user, if known; otherwise 0
contact phone_number:string first_name:string last_name:string vcard:string user_id:int53 = Contact;
@ -1728,12 +1734,8 @@ messageVenue venue:venue = MessageContent;
//@description A message with a user contact @contact The contact description
messageContact contact:contact = MessageContent;
//@description A message with an animated emoji
//@emoji The corresponding emoji
//@sticker Animated sticker with the emoji animation
//@color_replacements List of colors to be replaced while the sticker is rendered
//@sound File containing the sound to be played when the animated emoji is clicked if any; may be null. The sound is encoded with the Opus codec, and stored inside an OGG container
messageAnimatedEmoji emoji:string sticker:sticker color_replacements:vector<colorReplacement> sound:file = MessageContent;
//@description A message with an animated emoji @animated_emoji Description of the animated emoji @emoji The corresponding emoji
messageAnimatedEmoji animated_emoji:animatedEmoji emoji:string = MessageContent;
//@description A dice message. The dice value is randomly generated by the server
//@initial_state The animated stickers with the initial dice animation; may be null if unknown. updateMessageContent will be sent when the sticker became known

View File

@ -4830,7 +4830,10 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
case MessageContentType::Text: {
const auto *m = static_cast<const MessageText *>(content);
if (can_be_animated_emoji(m->text) && !m->web_page_id.is_valid()) {
return td->stickers_manager_->get_message_content_animated_emoji_object(m->text.text);
auto animated_emoji = td->stickers_manager_->get_animated_emoji_object(m->text.text);
if (animated_emoji != nullptr) {
return td_api::make_object<td_api::messageAnimatedEmoji>(std::move(animated_emoji), m->text.text);
}
}
return make_tl_object<td_api::messageText>(
get_formatted_text_object(m->text, skip_bot_commands, max_media_timestamp),

View File

@ -2012,21 +2012,17 @@ vector<td_api::object_ptr<td_api::colorReplacement>> StickersManager::get_color_
return result;
}
td_api::object_ptr<td_api::MessageContent> StickersManager::get_message_content_animated_emoji_object(
const string &emoji) {
td_api::object_ptr<td_api::animatedEmoji> StickersManager::get_animated_emoji_object(const string &emoji) {
auto it = emoji_messages_.find(emoji);
auto animated_sticker =
it != emoji_messages_.end() ? it->second.animated_emoji_sticker : get_animated_emoji_sticker(emoji);
if (animated_sticker.first.is_valid()) {
auto sound_file_id =
it != emoji_messages_.end() ? it->second.sound_file_id : get_animated_emoji_sound_file_id(emoji);
return td_api::make_object<td_api::messageAnimatedEmoji>(
emoji, get_sticker_object(animated_sticker.first, true), get_color_replacements_object(animated_sticker.second),
sound_file_id.is_valid() ? td_->file_manager_->get_file_object(sound_file_id) : nullptr);
if (!animated_sticker.first.is_valid()) {
return nullptr;
}
return td_api::make_object<td_api::messageText>(
td_api::make_object<td_api::formattedText>(emoji, std::vector<td_api::object_ptr<td_api::textEntity>>()),
nullptr);
auto sound_file_id = it != emoji_messages_.end() ? it->second.sound_file_id : get_animated_emoji_sound_file_id(emoji);
return td_api::make_object<td_api::animatedEmoji>(
get_sticker_object(animated_sticker.first, true), get_color_replacements_object(animated_sticker.second),
sound_file_id.is_valid() ? td_->file_manager_->get_file_object(sound_file_id) : nullptr);
}
tl_object_ptr<telegram_api::InputStickerSet> StickersManager::get_input_sticker_set(StickerSetId sticker_set_id) const {

View File

@ -64,7 +64,7 @@ class StickersManager final : public Actor {
const vector<StickerSetId> &sticker_set_ids,
size_t covers_limit) const;
td_api::object_ptr<td_api::MessageContent> get_message_content_animated_emoji_object(const string &emoji);
td_api::object_ptr<td_api::animatedEmoji> get_animated_emoji_object(const string &emoji);
tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set(StickerSetId sticker_set_id) const;