From 20b931138c81b3a93c6417178976e2fe14d1e1ee Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 2 Nov 2020 14:11:26 +0600 Subject: [PATCH] update FlowsUpdatesFilter --- .../utils/shortcuts/FlowsUpdatesFilter.kt | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index 6e08232a35..3c5fe89a8a 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -6,8 +6,7 @@ import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.* -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent +import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate @@ -101,6 +100,12 @@ fun Flow.audioMessages() = filterContentMessages(scopeToIncludeChannels) +fun FlowsUpdatesFilter.audioMessagesWithMediaGroups( + scopeToIncludeChannels: CoroutineScope? = null +) = merge( + filterContentMessages(scopeToIncludeChannels), + mediaGroupAudioMessages(scopeToIncludeChannels).flatMap() +) fun Flow.contactMessages() = filterContentMessages() fun FlowsUpdatesFilter.contactMessages( @@ -116,6 +121,12 @@ fun Flow.documentMessages() = filterContentMessages(scopeToIncludeChannels) +fun FlowsUpdatesFilter.documentMessagesWithMediaGroups( + scopeToIncludeChannels: CoroutineScope? = null +) = merge( + filterContentMessages(scopeToIncludeChannels), + mediaGroupDocumentMessages(scopeToIncludeChannels).flatMap() +) fun Flow.gameMessages() = filterContentMessages() fun FlowsUpdatesFilter.gameMessages( @@ -210,3 +221,18 @@ fun Flow.mediaGroupVideosMessages() = filterMediaGroupMess fun FlowsUpdatesFilter.mediaGroupVideosMessages( scopeToIncludeChannels: CoroutineScope? = null ) = filterMediaGroupMessages(scopeToIncludeChannels) + +fun Flow.mediaGroupVisualMessages() = filterMediaGroupMessages() +fun FlowsUpdatesFilter.mediaGroupVisualMessages( + scopeToIncludeChannels: CoroutineScope? = null +) = filterMediaGroupMessages(scopeToIncludeChannels) + +fun Flow.mediaGroupAudioMessages() = filterMediaGroupMessages() +fun FlowsUpdatesFilter.mediaGroupAudioMessages( + scopeToIncludeChannels: CoroutineScope? = null +) = filterMediaGroupMessages(scopeToIncludeChannels) + +fun Flow.mediaGroupDocumentMessages() = filterMediaGroupMessages() +fun FlowsUpdatesFilter.mediaGroupDocumentMessages( + scopeToIncludeChannels: CoroutineScope? = null +) = filterMediaGroupMessages(scopeToIncludeChannels)