From 8a3538d9c7ed6f1a5d5a2d0fa860f9f7fafcfc24 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 18 May 2022 17:05:47 +0600 Subject: [PATCH] fixes in relate to main behaviourBuilder fun --- .../behaviour_builder/BehaviourContextWithFSMBuilder.kt | 6 ++++-- .../extensions/behaviour_builder/TelegramBotWithFSM.kt | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt index ed26ea6d35..eef8542281 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -104,8 +104,8 @@ suspend fun TelegramBot.buildBehaviourWithFSM( upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow ), presetHandlers, - onStateHandlingErrorHandler, - statesManager + statesManager, + onStateHandlingErrorHandler ).apply { block() } /** @@ -124,6 +124,7 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: List> = listOf(), + onStateHandlingErrorHandler: StateHandlingErrorHandler = defaultStateHandlingErrorHandler(), block: CustomBehaviourContextReceiver, Unit> ) = FlowsUpdatesFilter().let { buildBehaviourWithFSM( @@ -132,6 +133,7 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler, statesManager, presetHandlers, + onStateHandlingErrorHandler, block ).run { start() diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt index bcbe3d7116..9588f1e648 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -39,6 +39,7 @@ suspend fun telegramBotWithBehaviourAndFSM( statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: List> = listOf(), testServer: Boolean = false, + onStateHandlingErrorHandler: StateHandlingErrorHandler = defaultStateHandlingErrorHandler(), block: CustomBehaviourContextReceiver, Unit> ): TelegramBot = telegramBot( token, @@ -52,6 +53,7 @@ suspend fun telegramBotWithBehaviourAndFSM( defaultExceptionsHandler, statesManager, presetHandlers, + onStateHandlingErrorHandler, block ) } @@ -76,6 +78,7 @@ suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: List> = listOf(), testServer: Boolean = false, + onStateHandlingErrorHandler: StateHandlingErrorHandler = defaultStateHandlingErrorHandler(), block: CustomBehaviourContextReceiver, Unit> ): Pair { return telegramBot( @@ -89,6 +92,7 @@ suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( defaultExceptionsHandler, statesManager, presetHandlers, + onStateHandlingErrorHandler, block ) }