From 9808823f7615bf0f85805c2ec345d571f393cfb7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 1 Jan 2019 18:11:28 +0800 Subject: [PATCH 1/2] update version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3ca197c8df..38a59e822b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -project.version = "0.8" +project.version = "0.8.1" project.group = "com.github.insanusmokrassar" buildscript { From 19c42933d3e429d9dfb66586201221140bcfdaa8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 1 Jan 2019 18:15:01 +0800 Subject: [PATCH 2/2] MediaGroupMessage implementation --- CHANGELOG | 9 ++++++++- .../types/message/MediaGroupMessage.kt | 17 +++++++++++++++++ .../TelegramBotAPI/types/message/RawMessage.kt | 14 +++++++++++++- .../message/abstracts/MediaGroupMessage.kt | 7 ++++--- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/MediaGroupMessage.kt diff --git a/CHANGELOG b/CHANGELOG index 8597f6cc7b..2491f7630a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1 +1,8 @@ -# TelegramBotAPI changelog \ No newline at end of file +# TelegramBotAPI changelog + +## 0.8.1 + +* Update `MediaGroupMessage` interface +* Add implementation of `MediaGroupMessage` +* Add generating of `MediaGroupMessage` in `RawMessage` + diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/MediaGroupMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/MediaGroupMessage.kt new file mode 100644 index 0000000000..b20c3eaf3a --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/MediaGroupMessage.kt @@ -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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index 922dd39a96..2599172aec 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -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, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/MediaGroupMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/MediaGroupMessage.kt index 96f376b51c..29b53ca253 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/MediaGroupMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/MediaGroupMessage.kt @@ -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 { - val mediaGroupId: String - val content: T +interface MediaGroupMessage : Message { + val mediaGroupId: MediaGroupIdentifier + val content: MediaGroupContent }