mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
FromUserMessage
This commit is contained in:
parent
661a8dfa8a
commit
38d4010bc1
@ -6,3 +6,9 @@
|
|||||||
* Add implementation of `MediaGroupMessage`
|
* Add implementation of `MediaGroupMessage`
|
||||||
* Add generating of `MediaGroupMessage` in `RawMessage`
|
* 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`
|
||||||
|
|
||||||
|
@ -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.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
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.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
data class CommonMessageImpl<T: MessageContent>(
|
data class CommonMessageImpl<T: MessageContent>(
|
||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
val user: User,
|
override val user: User,
|
||||||
override val chat: Chat,
|
override val chat: Chat,
|
||||||
override val content: T,
|
override val content: T,
|
||||||
override val date: DateTime,
|
override val date: DateTime,
|
||||||
@ -19,4 +18,4 @@ data class CommonMessageImpl<T: MessageContent>(
|
|||||||
override val forwarded: ForwardedMessage?,
|
override val forwarded: ForwardedMessage?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
val paymentInfo: PaymentInfo?
|
val paymentInfo: PaymentInfo?
|
||||||
) : Message, CommonMessage<T>
|
) : Message, CommonMessage<T>, FromUserMessage
|
@ -208,17 +208,31 @@ data class RawMessage(
|
|||||||
} ?: content ?.let {
|
} ?: content ?.let {
|
||||||
content ->
|
content ->
|
||||||
media_group_id ?.let {
|
media_group_id ?.let {
|
||||||
MediaGroupMessage(
|
when (from) {
|
||||||
messageId,
|
null -> MediaGroupMessage(
|
||||||
chat,
|
messageId,
|
||||||
date.asDate,
|
chat,
|
||||||
it,
|
date.asDate,
|
||||||
when (content) {
|
it,
|
||||||
is PhotoContent -> content
|
when (content) {
|
||||||
is VideoContent -> content
|
is PhotoContent -> content
|
||||||
else -> throw IllegalStateException("Unsupported content for media group")
|
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) {
|
} ?: when (chat) {
|
||||||
is ChannelChat -> ChannelMessage(
|
is ChannelChat -> ChannelMessage(
|
||||||
messageId,
|
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