@file:Suppress("NOTHING_TO_INLINE", "unused") package dev.inmo.tgbotapi.extensions.utils.shortcuts import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.flow.* @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 } @RiskFeature("Use with caution") inline fun > Flow>.filterByChatEvent(): Flow = mapNotNull { if (it.chatEvent is T) { it as? O } else { null } } @RiskFeature("Use with caution") inline fun Flow>.channelEvents() = filterByChatEvent>() inline fun Flow>.channelCreatedEvents() = channelEvents() inline fun Flow>.deletedChannelPhotoEvents() = channelEvents() inline fun Flow>.newChannelPhotoEvents() = channelEvents() inline fun Flow>.newChannelTitleEvents() = channelEvents() inline fun Flow>.newChannelPinnedMessageEvents() = channelEvents() @RiskFeature("Use with caution") inline fun Flow>.groupEvents() = filterByChatEvent>() inline fun Flow>.groupCreatedEvents() = groupEvents() inline fun Flow>.deletedGroupPhotoEvents() = groupEvents() inline fun Flow>.newGroupMembersEvents() = groupEvents() inline fun Flow>.leftGroupMemberEvents() = groupEvents() inline fun Flow>.newGroupPhotoEvents() = groupEvents() inline fun Flow>.newGroupTitleEvents() = groupEvents() inline fun Flow>.newGroupPinnedMessageEvents() = groupEvents() inline fun Flow>.proximityAlertTriggeredInGroupEvents() = groupEvents() @RiskFeature("Use with caution") inline fun Flow>.supergroupEvents() = filterByChatEvent>() inline fun Flow>.supergroupCreatedEvents() = supergroupEvents() inline fun Flow>.deletedSupergroupPhotoEvents() = supergroupEvents() inline fun Flow>.newSupergroupMembersEvents() = supergroupEvents() inline fun Flow>.leftSupergroupMemberEvents() = supergroupEvents() inline fun Flow>.newSupergroupPhotoEvents() = supergroupEvents() inline fun Flow>.newSupergroupTitleEvents() = supergroupEvents() inline fun Flow>.newSupergroupPinnedMessageEvents() = supergroupEvents() inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents()