mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-14 11:00:20 +00:00
add extension of containsCommand
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.SpecialMutableStateFlow
|
||||
import dev.inmo.micro_utils.coroutines.MutableRedeliverStateFlow
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingLogging
|
||||
import dev.inmo.micro_utils.coroutines.subscribeAsync
|
||||
import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions
|
||||
@@ -49,7 +49,7 @@ internal fun <BC : BehaviourContext, T> BC.on(
|
||||
}
|
||||
val handler: suspend (Pair<Update, T>) -> Unit = subcontextUpdatesFilter ?.let {
|
||||
{ (update, triggerData) ->
|
||||
val contextStateFlow = SpecialMutableStateFlow<BC?>(null)
|
||||
val contextStateFlow = MutableRedeliverStateFlow<BC?>(null)
|
||||
createSubContextAndDoSynchronouslyWithUpdatesFilter(
|
||||
updatesUpstreamFlow = contextStateFlow.flatMapLatest { context ->
|
||||
if (context == null) {
|
||||
|
||||
@@ -46,6 +46,9 @@ suspend fun containsCommand(commandRegex: Regex) = textSources.any {
|
||||
false
|
||||
}
|
||||
|
||||
context(textSources: TextSourcesList, bc: BehaviourContext)
|
||||
suspend fun containsCommand(command: String) = containsCommand(Regex(command))
|
||||
|
||||
@Warning("It is internal API and can be changed without notes")
|
||||
fun <BC : BehaviourContext, R, U : Update> CustomBehaviourContextAndTypeReceiver<BC, R, U>.withDefaultReceiver(
|
||||
data: BehaviourContextData
|
||||
|
||||
Reference in New Issue
Block a user