mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
Merge pull request #576 from xzima/fix_new_BehaviourContext_ignored
fix: new BehaviourContext ignored
This commit is contained in:
commit
901c1e8956
@ -90,7 +90,7 @@ class DefaultBehaviourContext(
|
|||||||
onBufferOverflow: BufferOverflow,
|
onBufferOverflow: BufferOverflow,
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
upstreamUpdatesFlow: Flow<Update>?,
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||||
): BehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter)
|
): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BehaviourContext(
|
fun BehaviourContext(
|
||||||
@ -116,19 +116,20 @@ suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithUpdatesFilter(
|
|||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||||
): T = copy(
|
): T {
|
||||||
scope = scope,
|
val newContext = copy(
|
||||||
updatesFilter = updatesFilter ?.let { _ ->
|
scope = scope,
|
||||||
{
|
updatesFilter = updatesFilter ?.let { _ ->
|
||||||
(this as? BC) ?.run {
|
{
|
||||||
updatesFilter(it)
|
(this as? BC) ?.run {
|
||||||
} ?: true
|
updatesFilter(it)
|
||||||
}
|
} ?: true
|
||||||
},
|
}
|
||||||
upstreamUpdatesFlow = updatesUpstreamFlow
|
},
|
||||||
).run {
|
upstreamUpdatesFlow = updatesUpstreamFlow
|
||||||
withContext(coroutineContext) {
|
) as BC
|
||||||
behaviourContextReceiver().also { if (stopOnCompletion) stop() }
|
return withContext(currentCoroutineContext()) {
|
||||||
|
newContext.behaviourContextReceiver().also { if (stopOnCompletion) newContext.stop() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user