mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-15 21:29:25 +00:00
updates
This commit is contained in:
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.update.*
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
interface FlowsUpdatesFilter : UpdatesFilter {
|
||||
@@ -43,9 +44,10 @@ fun FlowsUpdatesFilter(
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||
class DefaultFlowsUpdatesFilter(
|
||||
broadcastChannelsSize: Int = 100
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND
|
||||
): FlowsUpdatesFilter {
|
||||
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize)
|
||||
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize, onBufferOverflow = onBufferOverflow)
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
override val allUpdatesFlow: Flow<Update> = updatesSharedFlow.asSharedFlow()
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@@ -79,4 +81,4 @@ class DefaultFlowsUpdatesFilter(
|
||||
override val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user