mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
MediaCollectionContent as MediaContent
This commit is contained in:
parent
bf3356bea9
commit
7d7a6ccf80
@ -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
|
||||
|
||||
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstrac
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile
|
||||
|
||||
interface MediaCollectionContent<T: TelegramMediaFile>: MessageContent {
|
||||
val media: List<T>
|
||||
interface MediaCollectionContent<T: TelegramMediaFile>: MessageContent, MediaContent<T> {
|
||||
val mediaCollection: List<T>
|
||||
}
|
||||
|
@ -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<PhotoSize>,
|
||||
override val mediaCollection: List<PhotoSize>,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<MessageEntity> = emptyList()
|
||||
) : MediaCollectionContent<PhotoSize>, 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<RawMessage> = 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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user