mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-02 22:59:48 +00:00
add extension of containsCommand
This commit is contained in:
@@ -1610,6 +1610,7 @@ public abstract interface class dev/inmo/tgbotapi/extensions/behaviour_builder/u
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/DefaultCustomBehaviourContextAndTypeReceiverKt {
|
||||
public static final fun botInfo (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun containsCommand (Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun containsCommand (Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Lkotlin/text/Regex;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun optionallyWithDefaultReceiver (Lkotlin/jvm/functions/Function3;ZLdev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData;)Lkotlin/jvm/functions/Function3;
|
||||
public static final fun withDefaultReceiver (Lkotlin/jvm/functions/Function3;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/DefaultCustomBehaviourContextAndTypeReceiver;
|
||||
|
@@ -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