diff --git a/CHANGELOG.md b/CHANGELOG.md index 65bdf0e602..992462dc57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,9 @@ for receivers. * Removed deprecated method `T#toJsonWithoutNulls()` * Renamed instances of `MediaGroupMessage`s and refactored their interfaces. `ChannelMediaGroupMessage` will not contain `user` field (but `CommonMediaGroupMessage` will have) +* Now `MediaCollectionContent` is `MediaContent` (classes of this interface must choose best +media for present out) + * `PhotoContent` now choose biggest photo size from its collection as `media` ## 0.11.0 diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaCollectionContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaCollectionContent.kt index a815289302..7e673c624b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaCollectionContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaCollectionContent.kt @@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstrac import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile -interface MediaCollectionContent: MessageContent { - val media: List +interface MediaCollectionContent: MessageContent, MediaContent { + val mediaCollection: List } 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 3a15314fb5..de31836ac8 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 @@ -16,10 +16,12 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstract import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions data class PhotoContent( - override val media: List, + override val mediaCollection: List, override val caption: String? = null, override val captionEntities: List = emptyList() ) : MediaCollectionContent, CaptionedMediaContent, MediaGroupContent { + override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") + override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, @@ -27,7 +29,7 @@ data class PhotoContent( replyMarkup: KeyboardMarkup? ): Request = SendPhoto( chatId, - media.biggest() ?.fileId ?: throw IllegalStateException("Empty list of media"), + media.fileId, toMarkdownCaptions().firstOrNull(), MarkdownParseMode, disableNotification, @@ -36,7 +38,7 @@ data class PhotoContent( ) override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto( - media.biggest() ?.fileId ?: throw IllegalStateException("Can't locate any photo size for this content"), + media.fileId, toMarkdownCaptions().firstOrNull(), MarkdownParseMode )