diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt index f89e623676..2d516c712a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt @@ -18,6 +18,7 @@ package dev.inmo.tgbotapi.utils ) annotation class PreviewFeature +const val lowLevelRiskFeatureMessage = "This method is low-level and not recommended to direct use" @RequiresOptIn( "This feature can work unstable and may have some restrictions in Telegram System", RequiresOptIn.Level.WARNING diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt index d1cc0925c3..2e95e776fb 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.flow.* @@ -26,7 +27,7 @@ typealias NullableRequestBuilder = suspend (Update) -> Request? * as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory] * will be called too), [errorFactory] and then will be returned null */ -@RiskFeature("This method is not very comfortable to use and too low-level. It is recommended to use methods which already included into library") +@RiskFeature(lowLevelRiskFeatureMessage) suspend fun FlowsUpdatesFilter.expectFlow( bot: TelegramBot, initRequest: Request<*>? = null, @@ -92,7 +93,7 @@ suspend fun BehaviourContext.expectFlow( * as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory] * will be called too), [errorFactory] and then will be returned null */ -@RiskFeature("This method is not very comfortable to use and too low-level. It is recommended to use methods which already included into library") +@RiskFeature(lowLevelRiskFeatureMessage) suspend fun FlowsUpdatesFilter.expectOne( bot: TelegramBot, initRequest: Request<*>? = null, 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 3c5fe89a8a..05b2fc0233 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 @@ -12,9 +12,12 @@ import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.* +@RiskFeature(lowLevelRiskFeatureMessage) inline fun filterForContentMessage(): suspend (ContentMessage<*>) -> ContentMessage? = { if (it.content is T) { @Suppress("UNCHECKED_CAST") @@ -25,9 +28,11 @@ inline fun filterForContentMessage(): suspend (Cont } @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun Flow.filterContentMessages( ): Flow> = asContentMessagesFlow().mapNotNull(filterForContentMessage()) +@RiskFeature("This method is low-level") inline fun Flow.filterMediaGroupMessages( ): Flow>> = map { it.data.mapNotNull { message -> @@ -46,6 +51,7 @@ inline fun Flow.filterMedi * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping */ @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun FlowsUpdatesFilter.filterContentMessages( scopeToIncludeChannels: CoroutineScope? = null ): Flow> { @@ -64,6 +70,7 @@ inline fun FlowsUpdatesFilter.filterContentMessages( * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping */ @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun FlowsUpdatesFilter.filterMediaGroupMessages( scopeToIncludeChannels: CoroutineScope? = null ): Flow>> {