1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-04 07:39:39 +00:00

add data on behaviour contexts

This commit is contained in:
2024-11-29 01:09:47 +06:00
parent 3658403f01
commit 6d300de470
38 changed files with 1448 additions and 853 deletions

View File

@@ -2,24 +2,22 @@ public abstract interface class dev/inmo/tgbotapi/extensions/behaviour_builder/B
public static final field Companion Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM$Companion;
public abstract fun add (Lkotlin/reflect/KClass;ZLdev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;)V
public abstract fun addStrict (Lkotlin/reflect/KClass;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;)V
public abstract fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public abstract fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public abstract fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public abstract fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public abstract fun getStateInitialAction ()Lkotlin/jvm/functions/Function3;
public abstract fun start (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM$Companion {
public final fun invoke (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ljava/util/List;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public static synthetic fun invoke$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM$Companion;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ljava/util/List;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public final fun getDATA_FSM_KEY ()Ljava/lang/String;
public final fun invoke (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ljava/util/List;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public static synthetic fun invoke$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM$Companion;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ljava/util/List;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM$DefaultImpls {
public static synthetic fun add$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Lkotlin/reflect/KClass;ZLdev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;ILjava/lang/Object;)V
public static fun addStrict (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Lkotlin/reflect/KClass;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;)V
public static fun copy (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public static fun copy (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public static fun getAllowedUpdates (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;)Ljava/util/List;
public static fun getBot (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
public static fun getChannelPostMediaGroupsFlow (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;)Lkotlinx/coroutines/flow/Flow;
@@ -34,14 +32,19 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourConte
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilderKt {
public static final fun buildBehaviourWithFSM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSMAndStartLongPolling (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSMAndStartLongPolling (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSMAndStartLongPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSMAndStartLongPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSMAndStartLongPolling (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun buildBehaviourWithFSMAndStartLongPolling (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSMAndStartLongPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun buildBehaviourWithFSMAndStartLongPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMKt {
public static final fun fsmOrNull (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;)Ldev/inmo/micro_utils/fsm/common/StatesMachine;
public static final fun fsmOrThrow (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;)Ldev/inmo/micro_utils/fsm/common/StatesMachine;
}
public abstract interface class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler : dev/inmo/micro_utils/fsm/common/StatesHandler {
@@ -62,18 +65,17 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithF
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM : dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext, dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM {
public fun <init> (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun add (Lkotlin/reflect/KClass;ZLdev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;)V
public fun addStrict (Lkotlin/reflect/KClass;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler;)V
public fun close ()V
public synthetic fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;
public synthetic fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public synthetic fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;
public synthetic fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public fun copy (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM;
public fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun fsm ()Ldev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContextWithFSM;
public fun getAllUpdatesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getAllowedUpdates ()Ljava/util/List;
public fun getAsUpdateReceiver ()Lkotlin/jvm/functions/Function2;
@@ -91,6 +93,7 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehavio
public fun getChatMessageReactionsCountUpdatedUpdateFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getChosenInlineResultsFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public fun getData ()Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData;
public fun getDeleteBusinessMessageUpdatesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getEditBusinessMessageUpdatesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getEditedChannelPostMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow;
@@ -108,6 +111,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehavio
public fun getPreCheckoutQueriesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getScope ()Lkotlinx/coroutines/CoroutineScope;
public fun getShippingQueriesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun getStateInitialAction ()Lkotlin/jvm/functions/Function3;
public fun getSubcontextInitialAction ()Lkotlin/jvm/functions/Function3;
public fun getTriggersHolder ()Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;
public fun getUnknownUpdatesFlow ()Lkotlinx/coroutines/flow/Flow;
public fun handleState (Ldev/inmo/micro_utils/fsm/common/StatesMachine;Ldev/inmo/micro_utils/fsm/common/State;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -119,9 +124,9 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehavio
}
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSMKt {
public static final fun telegramBotWithBehaviourAndFSM (Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun telegramBotWithBehaviourAndFSM$default (Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun telegramBotWithBehaviourAndFSMAndStartLongPolling (Ljava/lang/String;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun telegramBotWithBehaviourAndFSMAndStartLongPolling$default (Ljava/lang/String;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun telegramBotWithBehaviourAndFSM (Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun telegramBotWithBehaviourAndFSM$default (Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun telegramBotWithBehaviourAndFSMAndStartLongPolling (Ljava/lang/String;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun telegramBotWithBehaviourAndFSMAndStartLongPolling$default (Ljava/lang/String;Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Ldev/inmo/micro_utils/fsm/common/StatesManager;Ljava/util/List;Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder;ZLkotlin/jvm/functions/Function3;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}

View File

@@ -5,6 +5,7 @@ import dev.inmo.micro_utils.fsm.common.*
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextWithFSM.Companion.DATA_FSM_KEY
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
import kotlinx.coroutines.*
@@ -22,6 +23,11 @@ import kotlin.reflect.KClass
* @see buildBehaviourWithFSM
*/
interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T> {
/**
* Will be called BEFORE handling of [State] will be started
*/
val stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T>
suspend fun start() = start(this)
/**
@@ -49,7 +55,8 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
broadcastChannelsSize: Int,
onBufferOverflow: BufferOverflow,
upstreamUpdatesFlow: Flow<Update>?,
triggersHolder: TriggersHolder
triggersHolder: TriggersHolder,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>
): BehaviourContextWithFSM<T>
fun copy(
@@ -58,35 +65,11 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
broadcastChannelsSize: Int = 100,
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
upstreamUpdatesFlow: Flow<Update>? = null,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
triggersHolder: TriggersHolder = this.triggersHolder,
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = this.stateInitialAction,
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
): BehaviourContextWithFSM<T> = copy(
bot,
scope,
broadcastChannelsSize,
onBufferOverflow,
upstreamUpdatesFlow,
triggersHolder
)
fun copy(
bot: TelegramBot = this.bot,
scope: CoroutineScope = this.scope,
broadcastChannelsSize: Int = 100,
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
upstreamUpdatesFlow: Flow<Update>? = null,
triggersHolder: TriggersHolder = this.triggersHolder,
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
): BehaviourContextWithFSM<T> = copy(
bot,
scope,
broadcastChannelsSize,
onBufferOverflow,
upstreamUpdatesFlow,
triggersHolder,
onStateHandlingErrorHandler
)
): BehaviourContextWithFSM<T>
companion object {
operator fun <T : State> invoke(
@@ -94,8 +77,11 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
statesManager: StatesManager<T>,
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, fallbackHandler, onStateHandlingErrorHandler)
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, fallbackHandler, stateInitialAction, onStateHandlingErrorHandler)
val DATA_FSM_KEY = "ktgbotapi_fsm"
}
}
@@ -131,6 +117,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
private val statesManager: StatesManager<T>,
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
private val fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
override val stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
@@ -140,6 +127,10 @@ class DefaultBehaviourContextWithFSM<T : State>(
protected val statesJobs = mutableMapOf<T, Job>()
protected val statesJobsMutex = Mutex()
init {
data[DATA_FSM_KEY] = this
}
override suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T? {
return launchStateHandling(state, handlers, onStateHandlingErrorHandler)
}
@@ -151,7 +142,9 @@ class DefaultBehaviourContextWithFSM<T : State>(
override suspend fun StatesMachine<in T>.handleState(state: T): T? {
return getSubContext(
state.context
).launchStateHandling(
).apply {
stateInitialAction(state)
}.launchStateHandling(
state,
actualHandlersList
)
@@ -247,13 +240,23 @@ class DefaultBehaviourContextWithFSM<T : State>(
broadcastChannelsSize: Int,
onBufferOverflow: BufferOverflow,
upstreamUpdatesFlow: Flow<Update>?,
triggersHolder: TriggersHolder
triggersHolder: TriggersHolder,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
handlers,
statesManager,
fallbackHandler,
onStateHandlingErrorHandler
behaviourContext = behaviourContext.copy(
bot = bot,
scope = scope,
broadcastChannelsSize = broadcastChannelsSize,
onBufferOverflow = onBufferOverflow,
upstreamUpdatesFlow = upstreamUpdatesFlow,
subcontextInitialAction = subcontextInitialAction,
triggersHolder = triggersHolder
),
handlers = handlers,
statesManager = statesManager,
fallbackHandler = fallbackHandler,
onStateHandlingErrorHandler = onStateHandlingErrorHandler,
stateInitialAction = stateInitialAction
)
override fun copy(
@@ -262,13 +265,40 @@ class DefaultBehaviourContextWithFSM<T : State>(
broadcastChannelsSize: Int,
onBufferOverflow: BufferOverflow,
upstreamUpdatesFlow: Flow<Update>?,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>,
triggersHolder: TriggersHolder,
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T>,
onStateHandlingErrorHandler: StateHandlingErrorHandler<T>
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
handlers,
statesManager,
fallbackHandler,
onStateHandlingErrorHandler
): BehaviourContextWithFSM<T> = BehaviourContextWithFSM(
behaviourContext = behaviourContext.copy(
bot = bot,
scope = scope,
broadcastChannelsSize = broadcastChannelsSize,
onBufferOverflow = onBufferOverflow,
upstreamUpdatesFlow = upstreamUpdatesFlow,
subcontextInitialAction = subcontextInitialAction,
triggersHolder = triggersHolder
),
handlers = handlers,
statesManager = statesManager,
fallbackHandler = fallbackHandler,
stateInitialAction = stateInitialAction,
onStateHandlingErrorHandler = onStateHandlingErrorHandler
)
fun fsm() = this
}
/**
* Extracting from [BehaviourContext.data] exists [StatesMachine] by key [DATA_FSM_KEY], which usually some [BehaviourContextWithFSM].
* In case if value absent in [BehaviourContext.data] will return null
*/
fun <T : State> BehaviourContext.fsmOrNull(): StatesMachine<T>? = data[DATA_FSM_KEY] as? StatesMachine<T>
/**
* Extracting from [BehaviourContext.data] exists [StatesMachine] by key [DATA_FSM_KEY], which usually some [BehaviourContextWithFSM].
* In case if value absent in [BehaviourContext.data] will throw [NullPointerException]
*
* @throws NullPointerException
*/
fun <T : State> BehaviourContext.fsmOrThrow(): StatesMachine<T> = fsmOrNull<T>()!!

View File

@@ -33,17 +33,21 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
DefaultBehaviourContext(
this,
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
upstreamUpdatesFlow = upstreamUpdatesFlow
behaviourContext = DefaultBehaviourContext(
bot = this,
scope = defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
upstreamUpdatesFlow = upstreamUpdatesFlow,
subcontextInitialAction = subcontextInitialAction
),
presetHandlers,
statesManager,
fallbackHandler,
onStateHandlingErrorHandler
handlers = presetHandlers,
statesManager = statesManager,
fallbackHandler = fallbackHandler,
stateInitialAction = stateInitialAction,
onStateHandlingErrorHandler = onStateHandlingErrorHandler
).apply { block() }
/**
@@ -67,16 +71,20 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
autoDisableWebhooks: Boolean = true,
autoSkipTimeoutExceptions: Boolean = true,
mediaGroupsDebounceTimeMillis: Long? = 1000L,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
): Pair<DefaultBehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
upstreamUpdatesFlow,
scope,
defaultExceptionsHandler,
statesManager,
presetHandlers,
fallbackHandler,
onStateHandlingErrorHandler,
block
upstreamUpdatesFlow = upstreamUpdatesFlow,
scope = scope,
defaultExceptionsHandler = defaultExceptionsHandler,
statesManager = statesManager,
presetHandlers = presetHandlers,
fallbackHandler = fallbackHandler,
onStateHandlingErrorHandler = onStateHandlingErrorHandler,
subcontextInitialAction = subcontextInitialAction,
stateInitialAction = stateInitialAction,
block = block
).run {
this to scope.launch {
start()
@@ -110,16 +118,20 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
DefaultBehaviourContext(
this,
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow,
subcontextInitialAction = subcontextInitialAction
),
presetHandlers,
statesManager,
fallbackHandler,
stateInitialAction,
onStateHandlingErrorHandler
).apply { block() }
@@ -149,27 +161,31 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
autoDisableWebhooks: Boolean = true,
autoSkipTimeoutExceptions: Boolean = true,
mediaGroupsDebounceTimeMillis: Long? = 1000L,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
) = FlowsUpdatesFilter().let {
buildBehaviourWithFSM(
it,
scope,
defaultExceptionsHandler,
statesManager,
presetHandlers,
fallbackHandler,
onStateHandlingErrorHandler,
block
flowUpdatesFilter = it,
scope = scope,
defaultExceptionsHandler = defaultExceptionsHandler,
statesManager = statesManager,
presetHandlers = presetHandlers,
fallbackHandler = fallbackHandler,
onStateHandlingErrorHandler = onStateHandlingErrorHandler,
subcontextInitialAction = subcontextInitialAction,
stateInitialAction = stateInitialAction,
block = block
).run {
start()
longPolling(
flowsUpdatesFilter,
timeoutSeconds,
scope,
autoDisableWebhooks,
autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis,
defaultExceptionsHandler
updatesFilter = flowsUpdatesFilter,
timeoutSeconds = timeoutSeconds,
scope = scope,
autoDisableWebhooks = autoDisableWebhooks,
autoSkipTimeoutExceptions = autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis,
exceptionsHandler = defaultExceptionsHandler
)
}
}

View File

@@ -13,6 +13,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
import dev.inmo.tgbotapi.types.Seconds
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
import kotlinx.coroutines.CoroutineScope
@@ -53,6 +54,8 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
autoDisableWebhooks: Boolean = true,
autoSkipTimeoutExceptions: Boolean = true,
mediaGroupsDebounceTimeMillis: Long? = 1000L,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
): TelegramBot = telegramBot(
token,
@@ -61,18 +64,20 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
builder
).apply {
buildBehaviourWithFSMAndStartLongPolling(
flowsUpdatesFilter.allUpdatesFlow,
scope ?: CoroutineScope(coroutineContext),
defaultExceptionsHandler,
statesManager,
presetHandlers,
fallbackHandler,
onStateHandlingErrorHandler,
timeoutSeconds,
autoDisableWebhooks,
autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis,
block
upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow,
scope = scope ?: CoroutineScope(coroutineContext),
defaultExceptionsHandler = defaultExceptionsHandler,
statesManager = statesManager,
presetHandlers = presetHandlers,
fallbackHandler = fallbackHandler,
onStateHandlingErrorHandler = onStateHandlingErrorHandler,
timeoutSeconds = timeoutSeconds,
autoDisableWebhooks = autoDisableWebhooks,
autoSkipTimeoutExceptions = autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis,
subcontextInitialAction = subcontextInitialAction,
stateInitialAction = stateInitialAction,
block = block
)
}
@@ -106,6 +111,8 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
autoDisableWebhooks: Boolean = true,
autoSkipTimeoutExceptions: Boolean = true,
mediaGroupsDebounceTimeMillis: Long? = 1000L,
subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = {},
stateInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContextWithFSM<T>, Unit, T> = {},
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
): Pair<TelegramBot, Job> {
return telegramBot(
@@ -115,17 +122,19 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
builder
).let {
it to it.buildBehaviourWithFSMAndStartLongPolling (
scope ?: CoroutineScope(coroutineContext),
defaultExceptionsHandler,
statesManager,
presetHandlers,
fallbackHandler,
onStateHandlingErrorHandler,
timeoutSeconds,
autoDisableWebhooks,
autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis,
block
scope = scope ?: CoroutineScope(coroutineContext),
defaultExceptionsHandler = defaultExceptionsHandler,
statesManager = statesManager,
presetHandlers = presetHandlers,
fallbackHandler = fallbackHandler,
onStateHandlingErrorHandler = onStateHandlingErrorHandler,
timeoutSeconds = timeoutSeconds,
autoDisableWebhooks = autoDisableWebhooks,
autoSkipTimeoutExceptions = autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis,
subcontextInitialAction = subcontextInitialAction,
stateInitialAction = stateInitialAction,
block = block
)
}
}