diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f6ffa0f19..1445175932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * `Common`: * `Version`: - * `MicroUtils`: `0.3.1` -> `0.3.2` + * `MicroUtils`: `0.3.1` -> `0.3.3` * `Core`: * `MultilevelTextSource#textSources` has been safely renamed to `subsources` * `TextContent#fullEntitiesList` has been deprecated @@ -14,7 +14,13 @@ * `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent` * Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages) * `Utils`: - * A lot of extensions for `Flow` has been added + * Old extensions related to chat events are deprecated: + * `Flow>#divideBySource` + * `Flow>#onlyChannelEvents` + * `Flow>#onlyGroupEvents` + * `Flow>#onlySupergroupEvents` + * A lot of extensions for `Flow` has been added: + * `FlowsUpdatesFilter#channelEvents` ## 0.30.3 diff --git a/gradle.properties b/gradle.properties index 865aaa403b..59e7102e0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=1.12.1 uuid_version=0.2.2 ktor_version=1.4.2 -micro_utils_version=0.3.2 +micro_utils_version=0.3.3 javax_activation_version=1.1.1 diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index 21a093595a..381af8efa4 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts +import dev.inmo.micro_utils.coroutines.plus import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -10,14 +11,24 @@ import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.flow.* +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.events(): Flow> { + return channelPostFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messageFlow.mapNotNull { it.data as? ChatEventMessage<*> } +} + @RiskFeature("Use with caution") inline fun FlowsUpdatesFilter.channelEvents(): Flow> = channelPostFlow.mapNotNull { it.data as? ChannelEventMessage<*> } @RiskFeature("Use with caution") -inline fun > FlowsUpdatesFilter.groupEvents(): Flow = messageFlow.mapNotNull { - it.data as? T +inline fun FlowsUpdatesFilter.groupEvents(): Flow> = messageFlow.mapNotNull { + it.data as? GroupEventMessage<*> +} + +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.supergroupEvents(): Flow> = messageFlow.mapNotNull { + it.data as? SupergroupEventMessage<*> } @RiskFeature("Use with caution")