From 7809fc7c69c21c3e512d288260eeac553ef3e916 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 7 Feb 2019 12:32:32 +0800 Subject: [PATCH] add Video InlineQueryResult --- .../CommonAbstracts/MimeTyped.kt | 5 ++ .../TelegramBotAPI/types/Common.kt | 19 +++++-- .../InlineQueryResultVideoCachedImpl.kt | 38 ++++++++++++++ .../InlineQueryResultVideoImpl.kt | 49 +++++++++++++++++++ .../results/video/InlineQueryResultVideo.kt | 6 +++ .../video/InlineQueryResultVideoCached.kt | 5 ++ .../video/InlineQueryResultVideoCommon.kt | 15 ++++++ .../types/files/abstracts/MimedMediaFile.kt | 6 +-- 8 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/MimeTyped.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideo.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCached.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/MimeTyped.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/MimeTyped.kt new file mode 100644 index 0000000000..e1c4f3f8b7 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/MimeTyped.kt @@ -0,0 +1,5 @@ +package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts + +interface MimeTyped { + val mimeType: String? // TODO::replace by something like enum or interface +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt index a76cd5f48c..a1fb1ef1a8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt @@ -60,27 +60,40 @@ const val untilDateField = "until_date" const val errorMessageField = "error_message" const val messageTextField = "message_text" + const val photoUrlField = "photo_url" const val photoSizeField = "photo_size" const val photoFileIdField = "photo_file_id" +const val photoWidthField = "photo_width" +const val photoHeightField = "photo_height" + const val gifUrlField = "gif_url" const val gifFileIdField = "gif_file_id" const val gifWidthField = "gif_width" const val gifHeightField = "gif_height" const val gifDurationField = "gif_duration" + const val mpeg4GifUrlField = "mpeg4_url" const val mpeg4GifFileIdField = "mpeg4_file_id" const val mpeg4GifWidthField = "mpeg4_width" const val mpeg4GifHeightField = "mpeg4_height" const val mpeg4GifDurationField = "mpeg4_duration" + +const val videoUrlField = "video_url" +const val videoFileIdField = "video_file_id" +const val videoWidthField = "video_width" +const val videoHeightField = "video_height" +const val videoDurationField = "video_duration" + +const val gameShortNameField = "game_short_name" + const val thumbUrlField = "thumb_url" const val thumbWidthField = "thumb_width" const val thumbHeightField = "thumb_height" -const val photoWidthField = "photo_width" -const val photoHeightField = "photo_height" + const val inputMessageContentField = "input_message_content" const val hideUrlField = "hide_url" -const val gameShortNameField = "game_short_name" + const val canSendMessagesField = "can_send_messages" const val canSendMediaMessagesField = "can_send_media_messages" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt new file mode 100644 index 0000000000..df26bd3ebd --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt @@ -0,0 +1,38 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult + +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.mimeTypeField +import kotlinx.serialization.Optional +import kotlinx.serialization.SerialName + +data class InlineQueryResultVideoCachedImpl( + @SerialName(idField) + override val id: String, + @SerialName(videoFileIdField) + override val fileId: FileId, + @SerialName(titleField) + @Optional + override val title: String? = null, + @SerialName(descriptionField) + @Optional + override val description: String? = null, + @SerialName(captionField) + @Optional + override val caption: String? = null, + @SerialName(parseModeField) + @Optional + override val parseMode: ParseMode? = null, + @SerialName(replyMarkupField) + @Optional + override val replyMarkup: InlineKeyboardMarkup? = null, + @SerialName(inputMessageContentField) + @Optional + override val inputMessageContent: InputMessageContent? = null +) : InlineQueryResultVideoCached diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt new file mode 100644 index 0000000000..5d57a9e26d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -0,0 +1,49 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult + +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.mimeTypeField +import kotlinx.serialization.Optional +import kotlinx.serialization.SerialName + +data class InlineQueryResultVideoImpl( + @SerialName(idField) + override val id: String, + @SerialName(videoUrlField) + override val url: String, + @SerialName(thumbUrlField) + override val thumbUrl: String, + @SerialName(mimeTypeField) + override val mimeType: String?, + @SerialName(videoWidthField) + @Optional + override val width: Int? = null, + @SerialName(videoHeightField) + @Optional + override val height: Int? = null, + @SerialName(videoDurationField) + @Optional + override val duration: Int? = null, + @SerialName(titleField) + @Optional + override val title: String? = null, + @SerialName(descriptionField) + @Optional + override val description: String? = null, + @SerialName(captionField) + @Optional + override val caption: String? = null, + @SerialName(parseModeField) + @Optional + override val parseMode: ParseMode? = null, + @SerialName(replyMarkupField) + @Optional + override val replyMarkup: InlineKeyboardMarkup? = null, + @SerialName(inputMessageContentField) + @Optional + override val inputMessageContent: InputMessageContent? = null +) : InlineQueryResultVideo diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideo.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideo.kt new file mode 100644 index 0000000000..81dfcfa602 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideo.kt @@ -0,0 +1,6 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.MimeTyped +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVideo : InlineQueryResultVideoCommon, UrlInlineQueryResult, ThumbedInlineQueryResult, MimeTyped, SizedInlineQueryResult, DuratedInlineResultQuery \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCached.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCached.kt new file mode 100644 index 0000000000..6232e95eab --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCached.kt @@ -0,0 +1,5 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video + +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVideoCached : InlineQueryResultVideoCommon, WithFileIdInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt new file mode 100644 index 0000000000..7f64bcae3b --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt @@ -0,0 +1,15 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.MimeTyped +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVideoCommon : InlineQueryResult, + TitledInlineQueryResult, + DescribedInlineQueryResult, + Captioned, + WithInputMessageContentInlineQueryResult +{ + override val type: String + get() = "video" +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/abstracts/MimedMediaFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/abstracts/MimedMediaFile.kt index 2ab9ffcf0a..0bc4b4e350 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/abstracts/MimedMediaFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/abstracts/MimedMediaFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.MimeTyped + internal const val mimeTypeField = "mime_type" -interface MimedMediaFile : TelegramMediaFile { - val mimeType: String? // TODO::replace by something like enum or interface -} \ No newline at end of file +interface MimedMediaFile : TelegramMediaFile, MimeTyped \ No newline at end of file