1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 19:18:44 +00:00

MediaGroupMessage implementation

This commit is contained in:
InsanusMokrassar 2019-01-01 18:15:01 +08:00
parent 9808823f76
commit 19c42933d3
4 changed files with 42 additions and 5 deletions

View File

@ -1 +1,8 @@
# TelegramBotAPI changelog
# TelegramBotAPI changelog
## 0.8.1
* Update `MediaGroupMessage` interface
* Add implementation of `MediaGroupMessage`
* Add generating of `MediaGroupMessage` in `RawMessage`

View File

@ -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

View File

@ -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,

View File

@ -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
}