1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-15 21:29:25 +00:00
This commit is contained in:
2021-06-28 01:00:20 +06:00
parent 47fe048b10
commit 77dff639f0
7 changed files with 69 additions and 28 deletions

View File

@@ -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()
}
}