mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-24 19:18:44 +00:00
MediaGroupMessage implementation
This commit is contained in:
parent
9808823f76
commit
19c42933d3
@ -1 +1,8 @@
|
||||
# TelegramBotAPI changelog
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.8.1
|
||||
|
||||
* Update `MediaGroupMessage` interface
|
||||
* Add implementation of `MediaGroupMessage`
|
||||
* Add generating of `MediaGroupMessage` in `RawMessage`
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||
import org.joda.time.DateTime
|
||||
|
||||
data class MediaGroupMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: Chat,
|
||||
override val date: DateTime,
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: MediaGroupContent
|
||||
) : Message, MediaGroupMessage
|
@ -207,7 +207,19 @@ data class RawMessage(
|
||||
}
|
||||
} ?: content ?.let {
|
||||
content ->
|
||||
when (chat) {
|
||||
media_group_id ?.let {
|
||||
MediaGroupMessage(
|
||||
messageId,
|
||||
chat,
|
||||
date.asDate,
|
||||
it,
|
||||
when (content) {
|
||||
is PhotoContent -> content
|
||||
is VideoContent -> content
|
||||
else -> throw IllegalStateException("Unsupported content for media group")
|
||||
}
|
||||
)
|
||||
} ?: when (chat) {
|
||||
is ChannelChat -> ChannelMessage(
|
||||
messageId,
|
||||
chat,
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||
|
||||
interface MediaGroupMessage<T: MediaGroupContent> {
|
||||
val mediaGroupId: String
|
||||
val content: T
|
||||
interface MediaGroupMessage : Message {
|
||||
val mediaGroupId: MediaGroupIdentifier
|
||||
val content: MediaGroupContent
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user