diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt index eabe98cddc..af0a1bad5c 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt @@ -1,13 +1,16 @@ package dev.inmo.tgbotapi.extensions.utils.chat_events +import dev.inmo.tgbotapi.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.mapNotNull import kotlin.reflect.KClass - -fun Flow.divideBySource(contentType: KClass) = mapNotNull { +@Deprecated("Refactored, replaced and renamed", ReplaceWith("filterByChatEvent", "dev.inmo.tgbotapi.extensions.utils.shortcuts.filterByChatEvent")) +fun > Flow>.divideBySource(contentType: KClass) = mapNotNull { if (contentType.isInstance(it)) { @Suppress("UNCHECKED_CAST") it as T @@ -16,6 +19,9 @@ fun Flow.divideBySource(contentType: KC } } -fun Flow.onlyChannelEvents() = divideBySource(ChannelEventMessage::class) -fun Flow.onlyGroupEvents() = divideBySource(CommonGroupEventMessage::class) -fun Flow.onlySupergroupEvents() = divideBySource(CommonSupergroupEventMessage::class) +@Deprecated("Replaced and renamed", ReplaceWith("allChannelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allChannelEvents")) +fun Flow>.onlyChannelEvents() = allChannelEvents() +@Deprecated("Replaced and renamed", ReplaceWith("allGroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allGroupEvents")) +fun Flow>.onlyGroupEvents() = allGroupEvents() +@Deprecated("Replaced and renamed", ReplaceWith("allSupergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allSupergroupEvents")) +fun Flow>.onlySupergroupEvents() = allSupergroupEvents() 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 24f83fcae4..21a093595a 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 @@ -36,6 +36,7 @@ inline fun Flow>.deletedChannelPhotoEvents() = channelEvents inline fun Flow>.newChannelPhotoEvents() = channelEvents() inline fun Flow>.newChannelTitleEvents() = channelEvents() inline fun Flow>.newChannelPinnedMessageEvents() = channelEvents() +inline fun Flow>.allChannelEvents() = channelEvents() @RiskFeature("Use with caution") inline fun Flow>.groupEvents() = filterByChatEvent>() @@ -47,6 +48,7 @@ inline fun Flow>.newGroupPhotoEvents() = groupEvents>.newGroupTitleEvents() = groupEvents() inline fun Flow>.newGroupPinnedMessageEvents() = groupEvents() inline fun Flow>.proximityAlertTriggeredInGroupEvents() = groupEvents() +inline fun Flow>.allGroupEvents() = groupEvents() @RiskFeature("Use with caution") @@ -59,3 +61,4 @@ inline fun Flow>.newSupergroupPhotoEvents() = supergroupEven inline fun Flow>.newSupergroupTitleEvents() = supergroupEvents() inline fun Flow>.newSupergroupPinnedMessageEvents() = supergroupEvents() inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents() +inline fun Flow>.allSupergroupEvents() = supergroupEvents()