mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
deprecations in old functions
This commit is contained in:
parent
98f68a9e1e
commit
71dac70635
@ -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 <T : ChatEventMessage> Flow<ChatEventMessage>.divideBySource(contentType: KClass<T>) = mapNotNull {
|
||||
@Deprecated("Refactored, replaced and renamed", ReplaceWith("filterByChatEvent", "dev.inmo.tgbotapi.extensions.utils.shortcuts.filterByChatEvent"))
|
||||
fun <T : ChatEventMessage<*>> Flow<ChatEventMessage<*>>.divideBySource(contentType: KClass<T>) = mapNotNull {
|
||||
if (contentType.isInstance(it)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
it as T
|
||||
@ -16,6 +19,9 @@ fun <T : ChatEventMessage> Flow<ChatEventMessage>.divideBySource(contentType: KC
|
||||
}
|
||||
}
|
||||
|
||||
fun Flow<ChatEventMessage>.onlyChannelEvents() = divideBySource(ChannelEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlyGroupEvents() = divideBySource(CommonGroupEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlySupergroupEvents() = divideBySource(CommonSupergroupEventMessage::class)
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("allChannelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allChannelEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlyChannelEvents() = allChannelEvents()
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("allGroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allGroupEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlyGroupEvents() = allGroupEvents()
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("allSupergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allSupergroupEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlySupergroupEvents() = allSupergroupEvents()
|
||||
|
@ -36,6 +36,7 @@ inline fun Flow<ChatEventMessage<*>>.deletedChannelPhotoEvents() = channelEvents
|
||||
inline fun Flow<ChatEventMessage<*>>.newChannelPhotoEvents() = channelEvents<NewChatPhoto>()
|
||||
inline fun Flow<ChatEventMessage<*>>.newChannelTitleEvents() = channelEvents<NewChatTitle>()
|
||||
inline fun Flow<ChatEventMessage<*>>.newChannelPinnedMessageEvents() = channelEvents<PinnedMessage>()
|
||||
inline fun Flow<ChatEventMessage<*>>.allChannelEvents() = channelEvents<ChannelEvent>()
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
inline fun <reified T : GroupEvent> Flow<ChatEventMessage<*>>.groupEvents() = filterByChatEvent<T, GroupEventMessage<T>>()
|
||||
@ -47,6 +48,7 @@ inline fun Flow<ChatEventMessage<*>>.newGroupPhotoEvents() = groupEvents<NewChat
|
||||
inline fun Flow<ChatEventMessage<*>>.newGroupTitleEvents() = groupEvents<NewChatTitle>()
|
||||
inline fun Flow<ChatEventMessage<*>>.newGroupPinnedMessageEvents() = groupEvents<PinnedMessage>()
|
||||
inline fun Flow<ChatEventMessage<*>>.proximityAlertTriggeredInGroupEvents() = groupEvents<ProximityAlertTriggered>()
|
||||
inline fun Flow<ChatEventMessage<*>>.allGroupEvents() = groupEvents<GroupEvent>()
|
||||
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
@ -59,3 +61,4 @@ inline fun Flow<ChatEventMessage<*>>.newSupergroupPhotoEvents() = supergroupEven
|
||||
inline fun Flow<ChatEventMessage<*>>.newSupergroupTitleEvents() = supergroupEvents<NewChatTitle>()
|
||||
inline fun Flow<ChatEventMessage<*>>.newSupergroupPinnedMessageEvents() = supergroupEvents<PinnedMessage>()
|
||||
inline fun Flow<ChatEventMessage<*>>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents<ProximityAlertTriggered>()
|
||||
inline fun Flow<ChatEventMessage<*>>.allSupergroupEvents() = supergroupEvents<SupergroupEvent>()
|
||||
|
Loading…
Reference in New Issue
Block a user