From 1926a9141b7314f8b7ca3c6616664899389737d6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Jun 2019 18:43:54 +0800 Subject: [PATCH] Common Captioned --- CHANGELOG.md | 3 +++ .../TelegramBotAPI/CommonAbstracts/Captioned.kt | 10 +++++++++- .../results/audio/InlineQueryResultAudioCommon.kt | 4 ++-- .../document/InlineQueryResultDocumentCommon.kt | 4 ++-- .../results/gif/InlineQueryResultGifCommon.kt | 4 ++-- .../mpeg4gif/InlineQueryResultMpeg4GifCommon.kt | 4 ++-- .../results/photo/InlineQueryResultPhotoCommon.kt | 4 ++-- .../results/video/InlineQueryResultVideoCommon.kt | 4 ++-- .../results/voice/InlineQueryResultVoiceCommon.kt | 4 ++-- .../InputMessageContent/InputTextMessageContent.kt | 4 ++-- .../types/InputMedia/CaptionedInputMedia.kt | 11 ++++++----- .../types/InputMedia/InputMediaAnimation.kt | 3 ++- .../types/InputMedia/InputMediaAudio.kt | 3 ++- .../types/InputMedia/InputMediaDocument.kt | 3 ++- .../types/InputMedia/InputMediaPhoto.kt | 2 +- .../types/InputMedia/InputMediaVideo.kt | 2 +- .../types/InputMedia/MediaGroupMemberInputMedia.kt | 3 ++- .../content/abstracts/CaptionedMediaContent.kt | 11 ++++++----- .../message/content/abstracts/MediaGroupContent.kt | 3 ++- .../types/message/content/media/AudioContent.kt | 3 ++- .../types/message/content/media/DocumentContent.kt | 3 ++- .../types/message/content/media/PhotoContent.kt | 2 +- .../types/message/content/media/VideoContent.kt | 2 +- .../types/message/content/media/VoiceContent.kt | 3 ++- .../insanusmokrassar/TelegramBotAPI/utils/Captions.kt | 4 ++-- .../TelegramBotAPI/utils/HtmlCaptionSourcer.kt | 4 ++-- .../TelegramBotAPI/utils/MarkdownCaptionSourcer.kt | 6 +++--- 27 files changed, 67 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d353bce531..ac4a12c738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ### 0.16.1 +* Now old uncommon `CaptionedMediaContent` and `CaptionedInputMedia` are replaced by almost the same +interfaces `CaptionedInput` and `CaptionedOutput`. They are both implementing `Captioned` interface + ## 0.15.0 * Old `UpdatesPoller` removed (was deprecated) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Captioned.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Captioned.kt index 7b3c72c6f5..7a80c885a1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Captioned.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Captioned.kt @@ -1,8 +1,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode interface Captioned { val caption: String? +} + +interface CaptionedOutput : Captioned { val parseMode: ParseMode? -} \ No newline at end of file +} + +interface CaptionedInput : Captioned { + val captionEntities: List +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt index 16ab18ef6d..c5d27e259e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.audio -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult const val inlineQueryResultAudioType = "audio" interface InlineQueryResultAudioCommon : InlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt index a2d33c3a56..e4a5f7f81b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.document -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultDocumentType = "document" @@ -8,5 +8,5 @@ const val inlineQueryResultDocumentType = "document" interface InlineQueryResultDocumentCommon : InlineQueryResult, TitledInlineQueryResult, DescribedInlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt index 4ceb8e2766..6dc1a7abb8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.gif -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultGifType = "gif" interface InlineQueryResultGifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt index 6b2611ba2a..e1eda2c3a5 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultMpeg4GifType = "mpeg4_gif" interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt index f0d78f077a..dc3eb814c6 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.photo -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultPhotoType = "photo" @@ -8,5 +8,5 @@ const val inlineQueryResultPhotoType = "photo" interface InlineQueryResultPhotoCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, DescribedInlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult 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 index a4e29a8d61..e553cdae76 100644 --- 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 @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultVideoType = "video" @@ -8,5 +8,5 @@ const val inlineQueryResultVideoType = "video" interface InlineQueryResultVideoCommon : InlineQueryResult, TitledInlineQueryResult, DescribedInlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt index 779da1e701..a7fddfe1a8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultVoiceType = "voice" interface InlineQueryResultVoiceCommon : InlineQueryResult, - Captioned, + CaptionedOutput, WithInputMessageContentInlineQueryResult, TitledInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt index 2b09e22ac9..1e5b51f5aa 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode @@ -18,4 +18,4 @@ data class InputTextMessageContent( override val parseMode: ParseMode? = null, @SerialName(disableWebPagePreviewField) override val disableWebPagePreview: Boolean? = null -) : Captioned, DisableWebPagePreview, InputMessageContent \ No newline at end of file +) : CaptionedOutput, DisableWebPagePreview, InputMessageContent \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/CaptionedInputMedia.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/CaptionedInputMedia.kt index d1191a90bf..3d909db385 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/CaptionedInputMedia.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/CaptionedInputMedia.kt @@ -1,8 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia -import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput -interface CaptionedInputMedia: InputMedia { - val caption: String? - val parseMode: ParseMode? -} \ No newline at end of file +@Deprecated( + "Deprecated due to replace by common type CaptionedOutput", + ReplaceWith("CaptionedOutput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput") +) +typealias CaptionedInputMedia = CaptionedOutput \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt index 8e11c95934..8ce52cad55 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField @@ -17,7 +18,7 @@ data class InputMediaAnimation( override val height: Int? = null, override val duration: Long? = null, override val thumb: InputFile? = null -) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia { +) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedOutput { override val type: String = "animation" @SerialName(mediaField) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt index e19b26e832..cf5d2f2125 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode @@ -18,7 +19,7 @@ data class InputMediaAudio( override val performer: String? = null, override val title: String? = null, override val thumb: InputFile? = null -) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedInputMedia, Performerable { +) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedOutput, Performerable { override val type: String = "audio" @SerialName(mediaField) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt index e95b209f36..2c27daca2f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField @@ -14,7 +15,7 @@ data class InputMediaDocument( @SerialName(parseModeField) override val parseMode: ParseMode? = null, override val thumb: InputFile? = null -) : InputMedia, ThumbedInputMedia, CaptionedInputMedia { +) : InputMedia, ThumbedInputMedia, CaptionedOutput { override val type: String = "document" @SerialName(mediaField) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt index 1b49e61a4c..da05c99286 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt @@ -13,7 +13,7 @@ data class InputMediaPhoto( override val caption: String? = null, @SerialName(parseModeField) override val parseMode: ParseMode? = null -) : InputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { +) : InputMedia, MediaGroupMemberInputMedia { override val type: String = "photo" override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt index 718864d90a..21bfa5df21 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt @@ -16,7 +16,7 @@ data class InputMediaVideo( override val height: Int? = null, override val duration: Long? = null, override val thumb: InputFile? = null -) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { +) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, MediaGroupMemberInputMedia { override val type: String = "video" override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt index a98b4d6f10..5e9a429c20 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt @@ -1,10 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput import kotlinx.serialization.Serializable import kotlinx.serialization.StringFormat @Serializable(MediaGroupMemberInputMediaSerializer::class) -interface MediaGroupMemberInputMedia: InputMedia { +interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput { fun serialize(format: StringFormat): String val arguments: Map } diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/CaptionedMediaContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/CaptionedMediaContent.kt index 5f64ac8cb2..340813e617 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/CaptionedMediaContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/CaptionedMediaContent.kt @@ -1,8 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts -import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput -interface CaptionedMediaContent { - val caption: String? - val captionEntities: List -} \ No newline at end of file +@Deprecated( + "Deprecated due to replace by common type CaptionedInput", + ReplaceWith("CaptionedInput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput") +) +typealias CaptionedMediaContent = CaptionedInput \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt index b81147f76b..746befe2eb 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt @@ -1,7 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia -interface MediaGroupContent : MediaContent { +interface MediaGroupContent : MediaContent, CaptionedInput { fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia } \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt index 8ab8411d54..818a3f1764 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier @@ -17,7 +18,7 @@ data class AudioContent( override val media: AudioFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent { +) : MediaContent, CaptionedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt index 2f901939f7..4a6e363fc4 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier @@ -17,7 +18,7 @@ data class DocumentContent( override val media: DocumentFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent { +) : MediaContent, CaptionedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt index ff79b8572d..919e8751ce 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt @@ -19,7 +19,7 @@ data class PhotoContent( override val mediaCollection: List, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaCollectionContent, CaptionedMediaContent, MediaGroupContent { +) : MediaCollectionContent, MediaGroupContent { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") override fun createResend( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt index 0fdd814209..765acd5806 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt @@ -19,7 +19,7 @@ data class VideoContent( override val media: VideoFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : CaptionedMediaContent, MediaGroupContent { +) : MediaGroupContent { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt index ecc524e975..c0f84cd2f1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier @@ -17,7 +18,7 @@ data class VoiceContent( override val media: VoiceFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent { +) : MediaContent, CaptionedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Captions.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Captions.kt index 7763f3ad6d..2a4584a44a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Captions.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Captions.kt @@ -1,12 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent -import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent -fun CaptionedMediaContent.fullEntitiesList(): List = caption ?.let { +fun CaptionedInput.fullEntitiesList(): List = caption ?.let { convertToFullMessageEntityList(it, captionEntities) } ?: emptyList() diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/HtmlCaptionSourcer.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/HtmlCaptionSourcer.kt index b75bb4b178..7a8bc212ce 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/HtmlCaptionSourcer.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/HtmlCaptionSourcer.kt @@ -1,10 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent -import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.textLength fun createHtmlText( @@ -12,7 +12,7 @@ fun createHtmlText( partLength: Int = 4096 ): List = createFormattedText(entities, partLength, HTMLParseMode) -fun CaptionedMediaContent.toHtmlCaptions(): List = createHtmlText( +fun CaptionedInput.toHtmlCaptions(): List = createHtmlText( fullEntitiesList(), captionLength.endInclusive + 1 ) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MarkdownCaptionSourcer.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MarkdownCaptionSourcer.kt index 21d1b490c7..f1ebbc0f6d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MarkdownCaptionSourcer.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MarkdownCaptionSourcer.kt @@ -1,10 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent -import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.textLength @Deprecated( @@ -31,9 +31,9 @@ fun createMarkdownText( "com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions" ) ) -fun CaptionedMediaContent.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull() +fun CaptionedInput.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull() -fun CaptionedMediaContent.toMarkdownCaptions(): List = createMarkdownText( +fun CaptionedInput.toMarkdownCaptions(): List = createMarkdownText( fullEntitiesList(), captionLength.endInclusive + 1 )