mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-21 13:45:50 +00:00
add several functions and changelog notes
This commit is contained in:
@@ -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<ChatEventMessage<*>> {
|
||||
return channelPostFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messageFlow.mapNotNull { it.data as? ChatEventMessage<*> }
|
||||
}
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
inline fun FlowsUpdatesFilter.channelEvents(): Flow<ChannelEventMessage<*>> = channelPostFlow.mapNotNull {
|
||||
it.data as? ChannelEventMessage<*>
|
||||
}
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
inline fun <reified T: GroupEventMessage<*>> FlowsUpdatesFilter.groupEvents(): Flow<T> = messageFlow.mapNotNull {
|
||||
it.data as? T
|
||||
inline fun FlowsUpdatesFilter.groupEvents(): Flow<GroupEventMessage<*>> = messageFlow.mapNotNull {
|
||||
it.data as? GroupEventMessage<*>
|
||||
}
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
inline fun FlowsUpdatesFilter.supergroupEvents(): Flow<SupergroupEventMessage<*>> = messageFlow.mapNotNull {
|
||||
it.data as? SupergroupEventMessage<*>
|
||||
}
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
|
||||
Reference in New Issue
Block a user