From ebf10667b7d6326e81439e0dcb3ea1ef093d0169 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 15 May 2020 19:48:21 +0300 Subject: [PATCH] Added support for animated thumbnails in inline animations. GitOrigin-RevId: 5a8830d6e89256900335b8667405b2f81f22f5bd --- td/generate/scheme/td_api.tl | 15 +++----- td/generate/scheme/td_api.tlo | Bin 171800 -> 171472 bytes td/telegram/InlineQueriesManager.cpp | 54 +++++++++++---------------- 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0b3e4781..a86b9352 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1857,17 +1857,14 @@ httpUrl url:string = HttpUrl; //@class InputInlineQueryResult @description Represents a single result of an inline query; for bots only -//@description Represents a link to an animated GIF @id Unique identifier of the query result @title Title of the query result @thumbnail_url URL of the static result thumbnail (JPEG or GIF), if it exists -//@gif_url The URL of the GIF-file (file size must not exceed 1MB) @gif_duration Duration of the GIF, in seconds @gif_width Width of the GIF @gif_height Height of the GIF +//@description Represents a link to an animated GIF or an animated (i.e. without sound) H.264/MPEG-4 AVC video +//@id Unique identifier of the query result @title Title of the query result +//@thumbnail_url URL of the result thumbnail (JPEG, GIF, or MPEG4), if it exists @thumbnail_mime_type MIME type of the video thumbnail. If non-empty, must be one of "image/jpeg", "image/gif" and "video/mp4" +//@video_url The URL of the video file (file size must not exceed 1MB) @video_mime_type MIME type of the video file. Must be one of "image/gif" and "video/mp4" +//@video_duration Duration of the video, in seconds @video_width Width of the video @video_height Height of the video //@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null //@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageLocation, InputMessageVenue or InputMessageContact -inputInlineQueryResultAnimatedGif id:string title:string thumbnail_url:string gif_url:string gif_duration:int32 gif_width:int32 gif_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult; - -//@description Represents a link to an animated (i.e. without sound) H.264/MPEG-4 AVC video @id Unique identifier of the query result @title Title of the result @thumbnail_url URL of the static result thumbnail (JPEG or GIF), if it exists -//@mpeg4_url The URL of the MPEG4-file (file size must not exceed 1MB) @mpeg4_duration Duration of the video, in seconds @mpeg4_width Width of the video @mpeg4_height Height of the video -//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null -//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageLocation, InputMessageVenue or InputMessageContact -inputInlineQueryResultAnimatedMpeg4 id:string title:string thumbnail_url:string mpeg4_url:string mpeg4_duration:int32 mpeg4_width:int32 mpeg4_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult; +inputInlineQueryResultAnimation id:string title:string thumbnail_url:string thumbnail_mime_type:string video_url:string video_mime_type:string video_duration:int32 video_width:int32 video_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult; //@description Represents a link to an article or web page @id Unique identifier of the query result @url URL of the result, if it exists @hide_url True, if the URL must be not shown @title Title of the result //@param_description A short description of the result @thumbnail_url URL of the result thumbnail, if it exists @thumbnail_width Thumbnail width, if known @thumbnail_height Thumbnail height, if known diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index f2fdb2315cfb21166b0739e0294bf6d8e04b511d..8bded40a17f09cbb89224635c11497209d243b55 100644 GIT binary patch delta 434 zcmbQSkL$v2t_@QJWm|K)WyL)63Q9{n^KvrtQUgmNd5M`h@wu6~sqrP1 z1*y|mnWQEw9Z(YBFUw3x%|}Q~H^^d=oV@jb`s9oQK9d9X#IS%2oV;R_0hqD*&ZZVd zh)~KF9SGyWR*lIQ)+> r_inline_message = Status::Error(500, "Uninited"); switch (input_result->get_id()) { - case td_api::inputInlineQueryResultAnimatedGif::ID: { - auto animated_gif = move_tl_object_as(input_result); + case td_api::inputInlineQueryResultAnimation::ID: { + auto animation = move_tl_object_as(input_result); type = "gif"; - id = std::move(animated_gif->id_); - title = std::move(animated_gif->title_); - thumbnail_url = std::move(animated_gif->thumbnail_url_); - content_url = std::move(animated_gif->gif_url_); - content_type = "image/gif"; - // duration = animated_gif->gif_duration_; - width = animated_gif->gif_width_; - height = animated_gif->gif_height_; + id = std::move(animation->id_); + title = std::move(animation->title_); + thumbnail_url = std::move(animation->thumbnail_url_); + if (!animation->thumbnail_mime_type_.empty()) { + thumbnail_type = std::move(animation->thumbnail_mime_type_); + } + content_url = std::move(animation->video_url_); + content_type = std::move(animation->video_mime_type_); + if (content_type != "image/gif" && content_type != "video/mp4") { + return promise.set_error(Status::Error(400, "Wrong animation MIME type specified")); + } + duration = animation->video_duration_; + width = animation->video_width_; + height = animation->video_height_; is_gallery = true; file_type = FileType::Animation; - r_inline_message = - get_inline_message(std::move(animated_gif->input_message_content_), std::move(animated_gif->reply_markup_), - td_api::inputMessageAnimation::ID); - break; - } - case td_api::inputInlineQueryResultAnimatedMpeg4::ID: { - auto animated_mpeg4 = move_tl_object_as(input_result); - type = "gif"; - id = std::move(animated_mpeg4->id_); - title = std::move(animated_mpeg4->title_); - thumbnail_url = std::move(animated_mpeg4->thumbnail_url_); - content_url = std::move(animated_mpeg4->mpeg4_url_); - content_type = "video/mp4"; - duration = animated_mpeg4->mpeg4_duration_; - width = animated_mpeg4->mpeg4_width_; - height = animated_mpeg4->mpeg4_height_; - is_gallery = true; - - file_type = FileType::Animation; - r_inline_message = - get_inline_message(std::move(animated_mpeg4->input_message_content_), - std::move(animated_mpeg4->reply_markup_), td_api::inputMessageAnimation::ID); + r_inline_message = get_inline_message(std::move(animation->input_message_content_), + std::move(animation->reply_markup_), td_api::inputMessageAnimation::ID); break; } case td_api::inputInlineQueryResultArticle::ID: { @@ -701,7 +688,8 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe attributes.push_back( make_tl_object(thumbnail_width, thumbnail_height)); } - thumbnail = make_tl_object(thumbnail_url, 0, "image/jpeg", std::move(attributes)); + thumbnail = + make_tl_object(thumbnail_url, 0, thumbnail_type, std::move(attributes)); } tl_object_ptr content; if (!content_url.empty() || !content_type.empty()) {