mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-21 15:53:47 +00:00
commit
5c67ea1325
@ -6,3 +6,9 @@
|
||||
* Add implementation of `MediaGroupMessage`
|
||||
* Add generating of `MediaGroupMessage` in `RawMessage`
|
||||
|
||||
## 0.8.2
|
||||
|
||||
* Add `FromUserMessage` which must be implemented in all messages realisations which have `user` field
|
||||
* Add `CommonMediaGroupMessage` which in fact extension of `MediaGroupMessage` with implementation of `FromUserMessage`
|
||||
* `CommonMessageImpl` now implementing `FromUserMessage`
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.8.1"
|
||||
project.version = "0.8.2"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||
import org.joda.time.DateTime
|
||||
|
||||
data class CommonMediaGroupMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
override val chat: Chat,
|
||||
override val date: DateTime,
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: MediaGroupContent
|
||||
) : Message, MediaGroupMessage, FromUserMessage
|
@ -3,15 +3,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||
import org.joda.time.DateTime
|
||||
|
||||
data class CommonMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
val user: User,
|
||||
override val user: User,
|
||||
override val chat: Chat,
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
@ -19,4 +18,4 @@ data class CommonMessageImpl<T: MessageContent>(
|
||||
override val forwarded: ForwardedMessage?,
|
||||
override val replyTo: Message?,
|
||||
val paymentInfo: PaymentInfo?
|
||||
) : Message, CommonMessage<T>
|
||||
) : Message, CommonMessage<T>, FromUserMessage
|
@ -208,17 +208,31 @@ data class RawMessage(
|
||||
} ?: content ?.let {
|
||||
content ->
|
||||
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 (from) {
|
||||
null -> MediaGroupMessage(
|
||||
messageId,
|
||||
chat,
|
||||
date.asDate,
|
||||
it,
|
||||
when (content) {
|
||||
is PhotoContent -> content
|
||||
is VideoContent -> content
|
||||
else -> throw IllegalStateException("Unsupported content for media group")
|
||||
}
|
||||
)
|
||||
else -> CommonMediaGroupMessage(
|
||||
messageId,
|
||||
from,
|
||||
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,
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
|
||||
interface FromUserMessage {
|
||||
val user: User
|
||||
}
|
Loading…
Reference in New Issue
Block a user