From 87ee2f280b4941fb7c08da1e7371e4700c590c93 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Apr 2022 19:56:34 +0600 Subject: [PATCH] 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)