From af83ac79e7818d1dc88815bebb685c4b2781758a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 18:35:17 +0600 Subject: [PATCH 01/14] start 0.38.12 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e41dab8fc..0eaa55e1e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.38.12 + ## 0.38.11 * `Common`: diff --git a/gradle.properties b/gradle.properties index a9333b0c5f..931ddee8f3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ javax_activation_version=1.1.1 dokka_version=1.6.10 library_group=dev.inmo -library_version=0.38.11 +library_version=0.38.12 github_release_plugin_version=2.2.12 From d426cb1210e7776badb658c7d87210884fde60b9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:06:27 +0600 Subject: [PATCH 02/14] TextedMediaContent --- CHANGELOG.md | 4 ++++ .../extensions/api/send/CopyMessages.kt | 6 +----- .../api/send/media/SendMediaGroup.kt | 4 ++-- .../expectations/WaitContent.kt | 1 - .../expectations/WaitMediaGroup.kt | 3 +-- .../triggers_handling/MediaGroupTriggers.kt | 3 +-- .../requests/send/media/SendMediaGroup.kt | 4 ++-- .../types/message/ChannelMediaGroupMessage.kt | 2 +- .../types/message/CommonMediaGroupMessage.kt | 2 +- .../message/abstracts/MediaGroupMessage.kt | 2 +- .../abstracts/AudioMediaGroupContent.kt | 4 ++++ .../abstracts/DocumentMediaGroupContent.kt | 4 ++++ .../content/abstracts/MediaGroupContent.kt | 18 ++---------------- .../abstracts/VisualMediaGroupContent.kt | 4 ++++ .../message/content/media/AnimationContent.kt | 2 +- .../message/content/media/AudioContent.kt | 1 - .../content/media/AudioMediaGroupContent.kt | 7 +++++++ .../message/content/media/DocumentContent.kt | 1 - .../content/media/DocumentMediaGroupContent.kt | 8 ++++++++ .../message/content/media/MediaGroupContent.kt | 7 +++++++ .../message/content/media/PhotoContent.kt | 1 - .../content/media/TextedMediaContent.kt | 6 ++++++ .../message/content/media/VideoContent.kt | 3 +-- .../content/media/VisualMediaGroupContent.kt | 7 +++++++ .../message/content/media/VoiceContent.kt | 2 +- .../ChannelPostMediaGroupUpdate.kt | 2 +- .../EditChannelPostMediaGroupUpdate.kt | 4 ++-- .../EditMessageMediaGroupUpdate.kt | 2 +- .../MediaGroupUpdates/MediaGroupUpdate.kt | 2 +- .../MessageMediaGroupUpdate.kt | 4 ++-- .../tgbotapi/extensions/utils/WithContent.kt | 1 + .../utils/shortcuts/MediaGroupsShortcuts.kt | 2 +- 32 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/AudioMediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/DocumentMediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/VisualMediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/MediaGroupContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eaa55e1e8..796f4ec536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.38.12 +* `Core`: + * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` + * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` + ## 0.38.11 * `Common`: diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt index 88780f3ba2..6588139c24 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -2,18 +2,14 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup -import dev.inmo.tgbotapi.requests.send.CopyMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent -import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate /** diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index be8f180f54..47afdfbd36 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -6,8 +6,8 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.content.media.AudioContent import dev.inmo.tgbotapi.types.message.content.media.DocumentContent import dev.inmo.tgbotapi.utils.RiskFeature diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index b93449737e..baeaef5b3c 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -16,7 +16,6 @@ import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList -import kotlin.reflect.KClass typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index d4602bc334..d2d3a4acfe 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -5,8 +5,7 @@ import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.abstracts.* -import dev.inmo.tgbotapi.types.message.content.media.PhotoContent -import dev.inmo.tgbotapi.types.message.content.media.VideoContent +import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.utils.PreviewFeature import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index b523abbc3a..53db2ad4be 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -10,8 +10,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.Mar import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.abstracts.* -import dev.inmo.tgbotapi.types.message.content.media.PhotoContent -import dev.inmo.tgbotapi.types.message.content.media.VideoContent +import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt index 5159222625..794a054f34 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt @@ -8,8 +8,8 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.content.media.AudioContent import dev.inmo.tgbotapi.types.message.content.media.DocumentContent import dev.inmo.tgbotapi.utils.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt index 36e9a1bfb5..745c42ff34 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent data class ChannelMediaGroupMessage( override val messageId: MessageIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt index cdaa34a5a5..0bc79cce09 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent data class CommonMediaGroupMessage( override val messageId: MessageIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt index 307ba6e78c..f6d2dd2538 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.MediaGroupIdentifier -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent interface MediaGroupMessage : CommonMessage { val mediaGroupId: MediaGroupIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/AudioMediaGroupContent.kt new file mode 100644 index 0000000000..0200d93012 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/AudioMediaGroupContent.kt @@ -0,0 +1,4 @@ +package dev.inmo.tgbotapi.types.message.content.abstracts + +@Deprecated("This class has been moved to the other package", ReplaceWith("AudioMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent")) +typealias AudioMediaGroupContent = dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/DocumentMediaGroupContent.kt new file mode 100644 index 0000000000..4eb6efc539 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/DocumentMediaGroupContent.kt @@ -0,0 +1,4 @@ +package dev.inmo.tgbotapi.types.message.content.abstracts + +@Deprecated("This class has been moved to the other package", ReplaceWith("DocumentMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent")) +typealias DocumentMediaGroupContent = dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index be20aa5ca8..aee066e415 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt @@ -1,18 +1,4 @@ package dev.inmo.tgbotapi.types.message.content.abstracts -import dev.inmo.tgbotapi.CommonAbstracts.TextedInput -import dev.inmo.tgbotapi.types.InputMedia.* - -interface MediaGroupContent : MediaContent, TextedInput { - fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia -} - -interface VisualMediaGroupContent : MediaGroupContent { - override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia -} -interface AudioMediaGroupContent : MediaGroupContent { - override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia -} -interface DocumentMediaGroupContent : MediaGroupContent { - override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia -} +@Deprecated("This class has been moved to the other package", ReplaceWith("MediaGroupContent", "dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent")) +typealias MediaGroupContent = dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/VisualMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/VisualMediaGroupContent.kt new file mode 100644 index 0000000000..96761afeae --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/VisualMediaGroupContent.kt @@ -0,0 +1,4 @@ +package dev.inmo.tgbotapi.types.message.content.abstracts + +@Deprecated("This class has been moved to the other package", ReplaceWith("VisualMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent")) +typealias VisualMediaGroupContent = dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt index 0b25a2d2fe..1812450b8e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt @@ -20,7 +20,7 @@ data class AnimationContent( val includedDocument: DocumentFile?, override val text: String?, override val textSources: TextSourcesList = emptyList() -) : MediaContent, TextedInput { +) : TextedMediaContent { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index 9cdb6892c6..67c3c138e7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -10,7 +10,6 @@ import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent import kotlinx.serialization.Serializable @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt new file mode 100644 index 0000000000..ad3ecd298e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.content.media + +import dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia + +interface AudioMediaGroupContent : MediaGroupContent { + override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index 387eac84c5..865d8b814f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -12,7 +12,6 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.asDocumentFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt new file mode 100644 index 0000000000..52c50c8ec0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types.message.content.media + +import dev.inmo.tgbotapi.types.InputMedia.* +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent + +interface DocumentMediaGroupContent : MediaGroupContent { + override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/MediaGroupContent.kt new file mode 100644 index 0000000000..0052cfe362 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/MediaGroupContent.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.content.media + +import dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia + +interface MediaGroupContent : TextedMediaContent { + fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 5f24f08e8c..c56826a5e1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MediaCollectionContent -import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent import kotlinx.serialization.Serializable @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaContent.kt new file mode 100644 index 0000000000..3eab0b0746 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaContent.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.types.message.content.media + +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput +import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent + +sealed interface TextedMediaContent : MediaContent, TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 79369429bc..7337fa2408 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -10,7 +10,6 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.toInputMediaVideo import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent import kotlinx.serialization.Serializable @Serializable @@ -18,7 +17,7 @@ data class VideoContent( override val media: VideoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : VisualMediaGroupContent { +) : VisualMediaGroupContent, TextedMediaContent { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt new file mode 100644 index 0000000000..5402b716a2 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.content.media + +import dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia + +interface VisualMediaGroupContent : MediaGroupContent { + override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt index a6bd70398a..9f069902c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt @@ -18,7 +18,7 @@ data class VoiceContent( override val media: VoiceFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : MediaContent, TextedInput { +) : TextedMediaContent { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt index 505caf47ef..15a4e4e3d6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate data class ChannelPostMediaGroupUpdate( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt index 8c0935d199..6a3efbdf32 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate data class EditChannelPostMediaGroupUpdate( @@ -10,4 +10,4 @@ data class EditChannelPostMediaGroupUpdate( ) : EditMediaGroupUpdate { override val updateId: UpdateIdentifier = origin.updateId override val data: MediaGroupMessage = origin.data as MediaGroupMessage -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt index 075b3c38d2..e2121c9e40 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.EditMessageUpdate data class EditMessageMediaGroupUpdate( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt index 740d7fab8e..5661d6d0f9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.abstracts.* /** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt index 3dd3c86cb0..3d1b34797b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate data class MessageMediaGroupUpdate( @@ -10,4 +10,4 @@ data class MessageMediaGroupUpdate( ) : SentMediaGroupUpdate { override val updateId: UpdateIdentifier = origins.last().updateId override val data: List> = origins.mapNotNull { it.data as? MediaGroupMessage } -} \ No newline at end of file +} diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt index 4b6e861577..4e2b2f18ba 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt @@ -4,6 +4,7 @@ package dev.inmo.tgbotapi.extensions.utils import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.content.abstracts.* +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent inline fun ContentMessage<*>.withContent() = if (content is T) { this as ContentMessage } else { null } inline fun ContentMessage<*>.requireWithContent() = withContent()!! diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt index f879f804f4..8e25886336 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate val List>.forwardInfo: ForwardInfo? From 49da0faf458d1b2845eb3c866f43c6872096a396 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:21:38 +0600 Subject: [PATCH 03/14] replies with texted content --- CHANGELOG.md | 1 + .../tgbotapi/extensions/api/send/Replies.kt | 152 +++++++++++++++++- .../inmo/tgbotapi/types/files/DocumentFile.kt | 21 ++- .../content/media/AudioMediaGroupContent.kt | 4 + .../media/DocumentMediaGroupContent.kt | 4 + 5 files changed, 173 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 796f4ec536..a4df7efbad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * `Core`: * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` + * Add `reply` functions with the texted content with including of text ## 0.38.11 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 0ee552946d..7f1e6278a4 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InputMedia.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -24,7 +25,7 @@ import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent -import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile +import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* @@ -1061,6 +1062,14 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) + is PhotoSize -> reply( + to = to, + photoSize = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) else -> reply( to = to, document = mediaFile.asDocumentFile(), @@ -1071,3 +1080,144 @@ suspend fun TelegramBot.reply( ) } } + +suspend fun TelegramBot.reply( + to: Message, + content: TextedMediaContent, + text: String?, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + when (content) { + is VoiceContent -> reply( + to = to, + voice = content.media, + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is AudioMediaGroupContent -> reply( + to = to, + audio = content.media, + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is PhotoContent -> reply( + to = to, + photoSize = content.media, + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is VideoContent -> reply( + to = to, + video = content.media, + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is AnimationContent -> reply( + to = to, + animation = content.media, + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + else -> reply( + to = to, + document = content.media.asDocumentFile(), + text = text, + parseMode = parseMode, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + } +} + +suspend fun TelegramBot.reply( + to: Message, + content: TextedMediaContent, + entities: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + when (content) { + is VoiceContent -> reply( + to = to, + voice = content.media, + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is AudioMediaGroupContent -> reply( + to = to, + audio = content.media, + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is PhotoContent -> reply( + to = to, + photoSize = content.media, + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is VideoContent -> reply( + to = to, + video = content.media, + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is AnimationContent -> reply( + to = to, + animation = content.media, + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + else -> reply( + to = to, + document = content.media.asDocumentFile(), + entities = entities, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt index 103fbb78d5..d869f4cb69 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.FileUniqueId import dev.inmo.tgbotapi.types.fileUniqueIdField import dev.inmo.tgbotapi.types.files.abstracts.* +import dev.inmo.tgbotapi.types.message.content.media.DocumentContent import dev.inmo.tgbotapi.utils.MimeType import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -24,11 +25,15 @@ data class DocumentFile( ) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile @Suppress("NOTHING_TO_INLINE") -inline fun TelegramMediaFile.asDocumentFile() = DocumentFile( - fileId, - fileUniqueId, - fileSize, - (this as? ThumbedMediaFile) ?.thumb, - (this as? MimedMediaFile) ?.mimeType, - (this as? CustomNamedMediaFile) ?.fileName -) +inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) { + this +} else { + DocumentFile( + fileId, + fileUniqueId, + fileSize, + (this as? ThumbedMediaFile) ?.thumb, + (this as? MimedMediaFile) ?.mimeType, + (this as? CustomNamedMediaFile) ?.fileName + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt index ad3ecd298e..15af16d802 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt @@ -1,7 +1,11 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia +import dev.inmo.tgbotapi.types.files.AudioFile +import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile interface AudioMediaGroupContent : MediaGroupContent { + override val media: AudioFile + override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt index 52c50c8ec0..ffd083806a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt @@ -1,8 +1,12 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.* +import dev.inmo.tgbotapi.types.files.DocumentFile +import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent interface DocumentMediaGroupContent : MediaGroupContent { + override val media: DocumentFile + override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia } From 97d122c7702a3606614f4b31ca1a8eb9753b0662 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:29:48 +0600 Subject: [PATCH 04/14] TextedMediaContent fixes --- .../triggers_handling/ContentTriggers.kt | 26 +++++++++++++++++++ .../tgbotapi/extensions/utils/ClassCasts.kt | 15 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 21a867bc4b..d6d0b019d2 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -14,6 +14,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate @@ -326,6 +328,30 @@ suspend fun BC.onDocumentMediaGroupContent( scenarioReceiver ) +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onTextedMediaContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onContent( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 91925eee57..d505b89d6e 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -43,6 +43,10 @@ import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.passport.* @@ -2671,6 +2675,17 @@ inline fun ResendableContent.asMediaCollectionContent(): MediaCollectionContent< inline fun ResendableContent.requireMediaCollectionContent(): MediaCollectionContent = this as MediaCollectionContent +@PreviewFeature +inline fun ResendableContent.whenTextedMediaContent(block: (TextedMediaContent) -> T) = asTextedMediaContent() ?.let(block) + +@PreviewFeature +inline fun ResendableContent.asTextedMediaContent(): TextedMediaContent? = + this as? TextedMediaContent + +@PreviewFeature +inline fun ResendableContent.requireTextedMediaContent(): TextedMediaContent = + this as TextedMediaContent + @PreviewFeature inline fun ResendableContent.whenMediaContent(block: (MediaContent) -> T) = asMediaContent() ?.let(block) From ee1c7c65336d1b6a46b4d89512a257bf7feee94d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:37:56 +0600 Subject: [PATCH 05/14] TextedMediaGroupMediaInput --- CHANGELOG.md | 1 + .../content/media/AudioMediaGroupContent.kt | 2 +- .../content/media/DocumentMediaGroupContent.kt | 2 +- .../media/TextedMediaGroupMediaInput.kt | 3 +++ .../content/media/VisualMediaGroupContent.kt | 2 +- .../utils/shortcuts/FlowsUpdatesFilter.kt | 18 ++++++++++++++++++ 6 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a4df7efbad..46bb5a6fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `Core`: * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` + * New type `TextedMediaGroupMediaInput` which will unite `TextedMediaContent` and `MediaGroupContent` * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` * Add `reply` functions with the texted content with including of text diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt index 15af16d802..f04c1a3905 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -interface AudioMediaGroupContent : MediaGroupContent { +interface AudioMediaGroupContent : TextedMediaGroupMediaInput { override val media: AudioFile override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt index ffd083806a..7c95c0239f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent -interface DocumentMediaGroupContent : MediaGroupContent { +interface DocumentMediaGroupContent : TextedMediaGroupMediaInput { override val media: DocumentFile override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt new file mode 100644 index 0000000000..8f6c370a06 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.content.media + +sealed interface TextedMediaGroupMediaInput : TextedMediaContent, MediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt index 5402b716a2..0e9c87879e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia -interface VisualMediaGroupContent : MediaGroupContent { +interface VisualMediaGroupContent : TextedMediaGroupMediaInput { override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index 8964dd1ad3..acd9324c3e 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -8,6 +8,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate @@ -203,6 +205,17 @@ fun FlowsUpdatesFilter.videoMessagesWithMediaGroups( mediaGroupVideosMessages(scopeToIncludeChannels).flatMap() ) +fun Flow.textedMediaContentMessages() = filterContentMessages() +fun FlowsUpdatesFilter.textedMediaContentMessages( + scopeToIncludeChannels: CoroutineScope? = null +) = filterContentMessages(scopeToIncludeChannels) +fun FlowsUpdatesFilter.textedMediaContentMessagesWithMediaGroups( + scopeToIncludeChannels: CoroutineScope? = null +) = merge( + filterContentMessages(scopeToIncludeChannels), + mediaGroupTextedMediaGroupMediaInput(scopeToIncludeChannels).flatMap() +) + fun Flow.videoNoteMessages() = filterContentMessages() fun FlowsUpdatesFilter.videoNoteMessages( scopeToIncludeChannels: CoroutineScope? = null @@ -243,3 +256,8 @@ fun Flow.mediaGroupDocumentMessages() = filterMediaGroupMe fun FlowsUpdatesFilter.mediaGroupDocumentMessages( scopeToIncludeChannels: CoroutineScope? = null ) = filterMediaGroupMessages(scopeToIncludeChannels) + +fun Flow.mediaGroupTextedMediaGroupMediaInput() = filterMediaGroupMessages() +fun FlowsUpdatesFilter.mediaGroupTextedMediaGroupMediaInput( + scopeToIncludeChannels: CoroutineScope? = null +) = filterMediaGroupMessages(scopeToIncludeChannels) From 3d458b2dc6d32109f5e0d51e92c1b178b3809819 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:48:48 +0600 Subject: [PATCH 06/14] fixes in builds and filling up functionality related to new classes --- CHANGELOG.md | 2 +- .../expectations/WaitContent.kt | 20 ++++++++ .../expectations/WaitEditedContent.kt | 20 ++++++++ .../expectations/WaitMediaGroup.kt | 10 ++++ .../triggers_handling/ContentTriggers.kt | 24 +++++++++ .../EditedContentTriggers.kt | 50 +++++++++++++++++++ .../triggers_handling/MediaGroupTriggers.kt | 24 ++++++++- .../content/media/AudioMediaGroupContent.kt | 3 +- .../media/DocumentMediaGroupContent.kt | 4 +- .../media/TextedMediaGroupMediaContent.kt | 3 ++ .../media/TextedMediaGroupMediaInput.kt | 3 -- .../content/media/VisualMediaGroupContent.kt | 2 +- .../utils/shortcuts/FlowsUpdatesFilter.kt | 8 +-- 13 files changed, 158 insertions(+), 15 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 46bb5a6fab..d929e5dad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * `Core`: * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` - * New type `TextedMediaGroupMediaInput` which will unite `TextedMediaContent` and `MediaGroupContent` + * New type `TextedMediaGroupMediaContent` which will unite `TextedMediaContent` and `MediaGroupContent` * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` * Add `reply` functions with the texted content with including of text diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index baeaef5b3c..fe0375c605 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -11,6 +11,10 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate @@ -197,6 +201,22 @@ suspend fun BehaviourContext.waitVisualMediaGroupContent( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitTextedMediaGroupMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + includeMediaGroups: Boolean = true, + filter: SimpleFilter>? = null, + mapper: CommonMessageToContentMapper? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitTextedMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + includeMediaGroups: Boolean = true, + filter: SimpleFilter>? = null, + mapper: CommonMessageToContentMapper? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index 9ca984ccc2..1056c1e4aa 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -12,6 +12,10 @@ import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate import kotlinx.coroutines.flow.toList @@ -173,6 +177,22 @@ suspend fun BehaviourContext.waitEditedVisualMediaGroupContent( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitEditedTextedMediaGroupMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + includeMediaGroups: Boolean = true, + filter: SimpleFilter>? = null, + mapper: CommonMessageToContentMapper? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitEditedTextedMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + includeMediaGroups: Boolean = true, + filter: SimpleFilter>? = null, + mapper: CommonMessageToContentMapper? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) suspend fun BehaviourContext.waitEditedAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index d2d3a4acfe..5f8367c52e 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -6,6 +6,10 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.utils.PreviewFeature import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList @@ -66,3 +70,9 @@ suspend fun BehaviourContext.waitVideoGallery( count: Int = 1, filter: MediaGroupFilter? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) +suspend fun BehaviourContext.waitTextedMediaGroupMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: MediaGroupFilter? = null +) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index d6d0b019d2..5b9b67cf42 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -352,6 +352,30 @@ suspend fun BC.onTextedMediaContent( scenarioReceiver ) +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onTextedMediaGroupMediaContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onContent( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index ba36d62331..9240a137cb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -27,6 +27,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update @@ -262,6 +264,54 @@ suspend fun BC.onEditedDocumentMediaGroupContent( scenarioReceiver ) +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onEditedTextedMediaGroupMediaContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +)= onEditedContent( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onEditedTextedMediaContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +)= onEditedContent( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index 53db2ad4be..eb5db29da0 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -9,8 +9,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByC import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature @@ -104,6 +107,25 @@ suspend fun BC.onVisualGallery( scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onTextedMediaGroupMediaContent( + initialFilter: SimpleFilter>>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> +) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt index f04c1a3905..087f9f90be 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt @@ -2,9 +2,8 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia import dev.inmo.tgbotapi.types.files.AudioFile -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -interface AudioMediaGroupContent : TextedMediaGroupMediaInput { +interface AudioMediaGroupContent : TextedMediaGroupMediaContent { override val media: AudioFile override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt index 7c95c0239f..eaa165b444 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt @@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.files.DocumentFile -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent -interface DocumentMediaGroupContent : TextedMediaGroupMediaInput { +interface DocumentMediaGroupContent : TextedMediaGroupMediaContent { override val media: DocumentFile override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt new file mode 100644 index 0000000000..7bde8528b4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.content.media + +sealed interface TextedMediaGroupMediaContent : TextedMediaContent, MediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt deleted file mode 100644 index 8f6c370a06..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaInput.kt +++ /dev/null @@ -1,3 +0,0 @@ -package dev.inmo.tgbotapi.types.message.content.media - -sealed interface TextedMediaGroupMediaInput : TextedMediaContent, MediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt index 0e9c87879e..b83073ee6d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia -interface VisualMediaGroupContent : TextedMediaGroupMediaInput { +interface VisualMediaGroupContent : TextedMediaGroupMediaContent { override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index acd9324c3e..2450410b48 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -213,7 +213,7 @@ fun FlowsUpdatesFilter.textedMediaContentMessagesWithMediaGroups( scopeToIncludeChannels: CoroutineScope? = null ) = merge( filterContentMessages(scopeToIncludeChannels), - mediaGroupTextedMediaGroupMediaInput(scopeToIncludeChannels).flatMap() + mediaGroupTextedMediaGroupMediaContent(scopeToIncludeChannels).flatMap() ) fun Flow.videoNoteMessages() = filterContentMessages() @@ -257,7 +257,7 @@ fun FlowsUpdatesFilter.mediaGroupDocumentMessages( scopeToIncludeChannels: CoroutineScope? = null ) = filterMediaGroupMessages(scopeToIncludeChannels) -fun Flow.mediaGroupTextedMediaGroupMediaInput() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupTextedMediaGroupMediaInput( +fun Flow.mediaGroupTextedMediaGroupMediaContent() = filterMediaGroupMessages() +fun FlowsUpdatesFilter.mediaGroupTextedMediaGroupMediaContent( scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) +) = filterMediaGroupMessages(scopeToIncludeChannels) From 87ee2f280b4941fb7c08da1e7371e4700c590c93 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:56:34 +0600 Subject: [PATCH 07/14] remove redundant TextedMediaInputMediaContent --- CHANGELOG.md | 2 +- .../expectations/WaitContent.kt | 8 ------- .../expectations/WaitEditedContent.kt | 8 ------- .../expectations/WaitMediaGroup.kt | 6 ----- .../triggers_handling/ContentTriggers.kt | 24 ------------------- .../EditedContentTriggers.kt | 24 ------------------- .../triggers_handling/MediaGroupTriggers.kt | 19 --------------- .../content/media/AudioMediaGroupContent.kt | 2 +- .../media/DocumentMediaGroupContent.kt | 2 +- .../media/TextedMediaGroupMediaContent.kt | 3 --- .../content/media/VisualMediaGroupContent.kt | 2 +- .../utils/shortcuts/FlowsUpdatesFilter.kt | 16 ------------- 12 files changed, 4 insertions(+), 112 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d929e5dad2..f212b39e1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ * `Core`: * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` - * New type `TextedMediaGroupMediaContent` which will unite `TextedMediaContent` and `MediaGroupContent` * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` + * `MediaGroupContent` Now extends `TextedMediaContent` instead of `MediaContent` * Add `reply` functions with the texted content with including of text ## 0.38.11 diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index fe0375c605..44dbd7d524 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -201,14 +201,6 @@ suspend fun BehaviourContext.waitVisualMediaGroupContent( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) -suspend fun BehaviourContext.waitTextedMediaGroupMediaContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index 1056c1e4aa..eab0ec1962 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -177,14 +177,6 @@ suspend fun BehaviourContext.waitEditedVisualMediaGroupContent( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) -suspend fun BehaviourContext.waitEditedTextedMediaGroupMediaContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) suspend fun BehaviourContext.waitEditedTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index 5f8367c52e..353a0be526 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -70,9 +70,3 @@ suspend fun BehaviourContext.waitVideoGallery( count: Int = 1, filter: MediaGroupFilter? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) -suspend fun BehaviourContext.waitTextedMediaGroupMediaContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: MediaGroupFilter? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 5b9b67cf42..d6d0b019d2 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -352,30 +352,6 @@ suspend fun BC.onTextedMediaContent( scenarioReceiver ) -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -suspend fun BC.onTextedMediaGroupMediaContent( - initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onContent( - initialFilter, - subcontextUpdatesFilter, - markerFactory, - scenarioReceiver -) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index 9240a137cb..c1b617bbbd 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -264,30 +264,6 @@ suspend fun BC.onEditedDocumentMediaGroupContent( scenarioReceiver ) -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -suspend fun BC.onEditedTextedMediaGroupMediaContent( - initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -)= onEditedContent( - initialFilter, - subcontextUpdatesFilter, - markerFactory, - scenarioReceiver -) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index eb5db29da0..4a00fc3801 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -107,25 +107,6 @@ suspend fun BC.onVisualGallery( scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -suspend fun BC.onTextedMediaGroupMediaContent( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt index 087f9f90be..adc46e7b42 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioMediaGroupContent.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia import dev.inmo.tgbotapi.types.files.AudioFile -interface AudioMediaGroupContent : TextedMediaGroupMediaContent { +interface AudioMediaGroupContent : MediaGroupContent { override val media: AudioFile override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt index eaa165b444..8319c3dc16 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentMediaGroupContent.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.files.DocumentFile -interface DocumentMediaGroupContent : TextedMediaGroupMediaContent { +interface DocumentMediaGroupContent : MediaGroupContent { override val media: DocumentFile override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt deleted file mode 100644 index 7bde8528b4..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/TextedMediaGroupMediaContent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package dev.inmo.tgbotapi.types.message.content.media - -sealed interface TextedMediaGroupMediaContent : TextedMediaContent, MediaGroupContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt index b83073ee6d..5402b716a2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VisualMediaGroupContent.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.content.media import dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia -interface VisualMediaGroupContent : TextedMediaGroupMediaContent { +interface VisualMediaGroupContent : MediaGroupContent { override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index 2450410b48..9669f9ffa0 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -205,17 +205,6 @@ fun FlowsUpdatesFilter.videoMessagesWithMediaGroups( mediaGroupVideosMessages(scopeToIncludeChannels).flatMap() ) -fun Flow.textedMediaContentMessages() = filterContentMessages() -fun FlowsUpdatesFilter.textedMediaContentMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.textedMediaContentMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = merge( - filterContentMessages(scopeToIncludeChannels), - mediaGroupTextedMediaGroupMediaContent(scopeToIncludeChannels).flatMap() -) - fun Flow.videoNoteMessages() = filterContentMessages() fun FlowsUpdatesFilter.videoNoteMessages( scopeToIncludeChannels: CoroutineScope? = null @@ -256,8 +245,3 @@ fun Flow.mediaGroupDocumentMessages() = filterMediaGroupMe fun FlowsUpdatesFilter.mediaGroupDocumentMessages( scopeToIncludeChannels: CoroutineScope? = null ) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupTextedMediaGroupMediaContent() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupTextedMediaGroupMediaContent( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) From 4207d89c92572c07d124acf1a9b45ed5a268fc77 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 4 Apr 2022 13:16:18 +0600 Subject: [PATCH 08/14] accumulated updates improvements --- CHANGELOG.md | 2 + .../utils/updates/retrieving/LongPolling.kt | 105 ++++++++++-------- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f212b39e1c..7659f30c43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` * `MediaGroupContent` Now extends `TextedMediaContent` instead of `MediaContent` * Add `reply` functions with the texted content with including of text +* `Utils`: + * Improve work with retrieving of accumulated updates ## 0.38.11 diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt index e972a61121..b58806440a 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt @@ -15,6 +15,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.* import dev.inmo.tgbotapi.utils.* import io.ktor.client.features.HttpRequestTimeoutException +import io.ktor.utils.io.CancellationException import kotlinx.coroutines.* import kotlinx.coroutines.flow.* @@ -89,6 +90,29 @@ fun TelegramBot.startGettingOfUpdatesByLongPolling( updatesReceiver ) +/** + * @return [kotlinx.coroutines.flow.Flow] which will emit updates to the collector while they will be accumulated. Works + * the same as [longPollingFlow], but it will cancel the flow after the first one [HttpRequestTimeoutException] + */ +fun TelegramBot.createAccumulatedUpdatesRetrieverFlow( + avoidInlineQueries: Boolean = false, + avoidCallbackQueries: Boolean = false, + exceptionsHandler: ExceptionHandler? = null, + allowedUpdates: List? = null +): Flow = longPollingFlow( + timeoutSeconds = 0, + exceptionsHandler = { + if (it is HttpRequestTimeoutException) { + throw CancellationException("Cancel due to absence of new updates") + } else { + exceptionsHandler ?.invoke(it) + } + }, + allowedUpdates = allowedUpdates +).filter { + !(it is InlineQueryUpdate && avoidInlineQueries || it is CallbackQueryUpdate && avoidCallbackQueries) +} + fun TelegramBot.retrieveAccumulatedUpdates( avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, @@ -96,51 +120,15 @@ fun TelegramBot.retrieveAccumulatedUpdates( exceptionsHandler: (ExceptionHandler)? = null, allowedUpdates: List? = null, updatesReceiver: UpdateReceiver -): Job = scope.launch { - safelyWithoutExceptions { - startGettingOfUpdatesByLongPolling( - 0, - CoroutineScope(coroutineContext + SupervisorJob()), - { - if (it is HttpRequestTimeoutException) { - throw CancellationException("Cancel due to absence of new updates") - } else { - exceptionsHandler ?.invoke(it) - } - }, - allowedUpdates - ) { - when { - it is InlineQueryUpdate && avoidInlineQueries || - it is CallbackQueryUpdate && avoidCallbackQueries -> return@startGettingOfUpdatesByLongPolling - else -> updatesReceiver(it) - } - }.join() - } -} - -/** - * @return [kotlinx.coroutines.flow.Flow] which will emit updates to the collector while they will be accumulated. Works - * the same as [retrieveAccumulatedUpdates], but pass [kotlinx.coroutines.flow.FlowCollector.emit] as a callback - */ -fun TelegramBot.createAccumulatedUpdatesRetrieverFlow( - avoidInlineQueries: Boolean = false, - avoidCallbackQueries: Boolean = false, - exceptionsHandler: ExceptionHandler? = null, - allowedUpdates: List? = null -): Flow = channelFlow { - val parentContext = kotlin.coroutines.coroutineContext - channel.apply { - retrieveAccumulatedUpdates( - avoidInlineQueries, - avoidCallbackQueries, - CoroutineScope(parentContext), - exceptionsHandler, - allowedUpdates, - ::send - ).join() - close() - } +): Job = createAccumulatedUpdatesRetrieverFlow( + avoidInlineQueries, + avoidCallbackQueries, + exceptionsHandler, + allowedUpdates +).subscribeSafelyWithoutExceptions( + scope.LinkedSupervisorScope() +) { + updatesReceiver(it) } fun TelegramBot.retrieveAccumulatedUpdates( @@ -149,9 +137,30 @@ fun TelegramBot.retrieveAccumulatedUpdates( avoidCallbackQueries: Boolean = false, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler? = null -) = flowsUpdatesFilter.run { - retrieveAccumulatedUpdates(avoidInlineQueries, avoidCallbackQueries, scope, exceptionsHandler, allowedUpdates, asUpdateReceiver) -} +) = retrieveAccumulatedUpdates( + avoidInlineQueries, + avoidCallbackQueries, + scope, + exceptionsHandler, + flowsUpdatesFilter.allowedUpdates, + flowsUpdatesFilter.asUpdateReceiver +) + +suspend fun TelegramBot.flushAccumulatedUpdates( + avoidInlineQueries: Boolean = false, + avoidCallbackQueries: Boolean = false, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default), + allowedUpdates: List? = null, + exceptionsHandler: ExceptionHandler? = null, + updatesReceiver: UpdateReceiver = {} +) = retrieveAccumulatedUpdates( + avoidInlineQueries, + avoidCallbackQueries, + scope, + exceptionsHandler, + allowedUpdates, + updatesReceiver +).join() /** * Will [startGettingOfUpdatesByLongPolling] using incoming [flowsUpdatesFilter]. It is assumed that you ALREADY CONFIGURE From 1769fcacfd5a194c4571aaa5d1bfef53115d602d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 6 Apr 2022 11:44:12 +0600 Subject: [PATCH 09/14] update gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cde1e36e1a..0dfb4f8c7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip From be284c4d9628c43fa0cb63505e6ad31aaa294adc Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 8 Apr 2022 02:08:21 +0600 Subject: [PATCH 10/14] Update dependencies --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 931ddee8f3..b0173ec17b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,13 +6,13 @@ kotlin.incremental=true kotlin.incremental.js=true kotlin_version=1.6.10 -kotlin_coroutines_version=1.6.0 +kotlin_coroutines_version=1.6.1 kotlin_serialisation_runtime_version=1.3.2 klock_version=2.7.0 uuid_version=0.4.0 ktor_version=1.6.8 -micro_utils_version=0.9.17 +micro_utils_version=0.9.19 javax_activation_version=1.1.1 From fa74f125057a3a7b7c090455bb520634de5d7f84 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 8 Apr 2022 02:09:22 +0600 Subject: [PATCH 11/14] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7659f30c43..9aff62aa7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.38.12 +* `Common`: + * `Version`: + * `MicroUtils`: `0.9.17` -> `0.9.19` + * `Coroutines`: `1.6.0` -> `1.6.1` * `Core`: * New type `TextedMediaContent` which will unite `TextedInput` and `MediaContent` * `MediaGroupContent` and all subsequent inheritors have been replaced to the package `dev.inmo.tgbotapi.types.message.content.media` From 81b9ccdf6a888c30bbbeceb84b73cdd177313ad1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 8 Apr 2022 09:29:07 +0600 Subject: [PATCH 12/14] Update VideoContent.kt --- .../inmo/tgbotapi/types/message/content/media/VideoContent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 7337fa2408..1de12b940e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -17,7 +17,7 @@ data class VideoContent( override val media: VideoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : VisualMediaGroupContent, TextedMediaContent { +) : VisualMediaGroupContent { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, From 52204d8df13d4be85ebd20e89d39d6fcb9f3e6c6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 8 Apr 2022 09:44:37 +0600 Subject: [PATCH 13/14] Experemtally update kotlin --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b0173ec17b..cc46e7f1a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -kotlin_version=1.6.10 +kotlin_version=1.6.20 kotlin_coroutines_version=1.6.1 kotlin_serialisation_runtime_version=1.3.2 klock_version=2.7.0 From 83ea4f64359495845b659ac53ec67da545220921 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 8 Apr 2022 09:49:06 +0600 Subject: [PATCH 14/14] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index cc46e7f1a8..b0173ec17b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -kotlin_version=1.6.20 +kotlin_version=1.6.10 kotlin_coroutines_version=1.6.1 kotlin_serialisation_runtime_version=1.3.2 klock_version=2.7.0