1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

Merge pull request #5 from InsanusMokrassar/0.8.2

0.8.2
This commit is contained in:
InsanusMokrassar 2019-01-10 22:16:48 +08:00 committed by GitHub
commit 5c67ea1325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 16 deletions

View File

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

View File

@ -1,4 +1,4 @@
project.version = "0.8.1" project.version = "0.8.2"
project.group = "com.github.insanusmokrassar" project.group = "com.github.insanusmokrassar"
buildscript { buildscript {

View File

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

View File

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

View File

@ -208,7 +208,8 @@ data class RawMessage(
} ?: content ?.let { } ?: content ?.let {
content -> content ->
media_group_id ?.let { media_group_id ?.let {
MediaGroupMessage( when (from) {
null -> MediaGroupMessage(
messageId, messageId,
chat, chat,
date.asDate, date.asDate,
@ -219,6 +220,19 @@ data class RawMessage(
else -> throw IllegalStateException("Unsupported content for media group") 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,

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.User
interface FromUserMessage {
val user: User
}