From 6b977e67d03d75083294affb0b239fb7ff13c8f6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 26 Apr 2022 13:05:56 +0600 Subject: [PATCH] Revert "add telegram update handler" This reverts commit ab5937449c716a96241150cf9dbaaf580ed4757e. --- .../BehaviourContextWithFSM.kt | 5 +- .../BehaviourContextWithFSMBuilder.kt | 14 +---- .../behaviour_builder/TelegramBotWithFSM.kt | 6 --- tgbotapi.behaviour_builder/build.gradle | 1 - .../behaviour_builder/BehaviourBuilders.kt | 8 +-- .../behaviour_builder/BehaviourContext.kt | 27 +++------- .../behaviour_builder/TelegramBot.kt | 6 --- .../DefaultTelegramHandlersRegistrar.kt | 51 ------------------- .../handlers/TelegramHandlersRegistrar.kt | 9 ---- .../utils/handlers/TelegramUpdateHandler.kt | 6 --- 10 files changed, 11 insertions(+), 122 deletions(-) delete mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/DefaultTelegramHandlersRegistrar.kt delete mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramHandlersRegistrar.kt delete mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramUpdateHandler.kt diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index 334a8b8f7b..be5cdb8923 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -6,7 +6,6 @@ import dev.inmo.micro_utils.fsm.common.* import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.micro_utils.coroutines.accumulatorFlow -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import kotlinx.coroutines.* import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.* @@ -37,7 +36,6 @@ interface BehaviourContextWithFSM : BehaviourContext, StatesMachine?, - telegramHandlersRegistrar: TelegramHandlersRegistrar, updatesFilter: BehaviourContextAndTypeReceiver? ): BehaviourContextWithFSM @@ -107,10 +105,9 @@ class DefaultBehaviourContextWithFSM( broadcastChannelsSize: Int, onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow?, - telegramHandlersRegistrar: TelegramHandlersRegistrar, updatesFilter: BehaviourContextAndTypeReceiver? ): BehaviourContextWithFSM = BehaviourContextWithFSM( - behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, telegramHandlersRegistrar, updatesFilter), + behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter), handlers, statesManager ) 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 1cedf2184f..7723b81c70 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 @@ -5,8 +5,6 @@ import dev.inmo.micro_utils.fsm.common.* import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.DefaultTelegramHandlersRegistrar -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.types.update.abstracts.Update @@ -97,14 +95,12 @@ suspend fun TelegramBot.buildBehaviourWithFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ): BehaviourContextWithFSM = BehaviourContextWithFSMBuilder( DefaultBehaviourContext( this, defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope, - upstreamUpdatesFlow = upstreamUpdatesFlow, - telegramHandlersRegistrar = telegramHandlersRegistrar + upstreamUpdatesFlow = upstreamUpdatesFlow ), statesManager, presetHandlers @@ -121,7 +117,6 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ): Pair, Job> = buildBehaviourWithFSM( upstreamUpdatesFlow, @@ -129,7 +124,6 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler, statesManager, presetHandlers, - telegramHandlersRegistrar, block ).run { this to scope.launch { @@ -163,14 +157,12 @@ suspend fun TelegramBot.buildBehaviourWithFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ): BehaviourContextWithFSM = BehaviourContextWithFSMBuilder( DefaultBehaviourContext( this, defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope, - upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow, - telegramHandlersRegistrar = telegramHandlersRegistrar + upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow ), statesManager, presetHandlers @@ -193,7 +185,6 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ) = FlowsUpdatesFilter().let { buildBehaviourWithFSM( @@ -202,7 +193,6 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( defaultExceptionsHandler, statesManager, presetHandlers, - telegramHandlersRegistrar, 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 7c1ea560dc..0c5b881580 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 @@ -8,8 +8,6 @@ import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutorBuilder import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.DefaultTelegramHandlersRegistrar -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl @@ -40,7 +38,6 @@ suspend fun telegramBotWithBehaviourAndFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ): TelegramBot = telegramBot( token, @@ -53,7 +50,6 @@ suspend fun telegramBotWithBehaviourAndFSM( defaultExceptionsHandler, statesManager, presetHandlers, - telegramHandlersRegistrar, block ) } @@ -77,7 +73,6 @@ suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: CustomBehaviourContextReceiver, Unit> ): Pair { return telegramBot( @@ -90,7 +85,6 @@ suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( defaultExceptionsHandler, statesManager, presetHandlers, - telegramHandlersRegistrar, block ) } diff --git a/tgbotapi.behaviour_builder/build.gradle b/tgbotapi.behaviour_builder/build.gradle index 537da9052c..68224e8bc7 100644 --- a/tgbotapi.behaviour_builder/build.gradle +++ b/tgbotapi.behaviour_builder/build.gradle @@ -44,7 +44,6 @@ kotlin { dependencies { implementation kotlin('stdlib') api project(":tgbotapi.utils") - api "dev.inmo:micro_utils.handlers.common:$micro_utils_version" } } } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 420f991320..dd17203ef3 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -3,8 +3,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler import dev.inmo.micro_utils.coroutines.ExceptionHandler import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.DefaultTelegramHandlersRegistrar -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter @@ -32,7 +30,6 @@ suspend fun TelegramBot.buildBehaviour( flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(), scope: CoroutineScope = defaultCoroutineScopeProvider(), defaultExceptionsHandler: ExceptionHandler? = null, - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: BehaviourContextReceiver ) { BehaviourContext( @@ -44,8 +41,7 @@ suspend fun TelegramBot.buildBehaviour( it + ContextSafelyExceptionHandler(defaultExceptionsHandler) } }, - flowUpdatesFilter, - telegramHandlersRegistrar + flowUpdatesFilter ).block() } @@ -61,14 +57,12 @@ suspend fun TelegramBot.buildBehaviour( suspend fun TelegramBot.buildBehaviourWithLongPolling( scope: CoroutineScope = defaultCoroutineScopeProvider(), defaultExceptionsHandler: ExceptionHandler? = null, - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: BehaviourContextReceiver ) = FlowsUpdatesFilter().let { buildBehaviour( it, scope, defaultExceptionsHandler, - telegramHandlersRegistrar, block ) longPolling( diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 27630d47e2..2426853a51 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -4,10 +4,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder import dev.inmo.micro_utils.coroutines.* import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.DefaultTelegramHandlersRegistrar -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.* +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.* import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.* @@ -31,7 +30,7 @@ internal inline fun CustomBehaviourContextAndTwoTypesReceiver? = null, - telegramHandlersRegistrar: TelegramHandlersRegistrar = this.telegramHandlersRegistrar, updatesFilter: BehaviourContextAndTypeReceiver? = null ): BehaviourContext } @@ -65,16 +60,11 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope, Te class DefaultBehaviourContext( override val bot: TelegramBot, override val scope: CoroutineScope, - override val telegramHandlersRegistrar: TelegramHandlersRegistrar, broadcastChannelsSize: Int = 100, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, private val upstreamUpdatesFlow: Flow? = null, private val updatesFilter: BehaviourContextAndTypeReceiver? = null -) : AbstractFlowsUpdatesFilter(), - TelegramBot by bot, - CoroutineScope by scope, - TelegramHandlersRegistrar by telegramHandlersRegistrar, - BehaviourContext { +) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext { private val additionalUpdatesSharedFlow = MutableSharedFlow(0, broadcastChannelsSize, onBufferOverflow) override val allUpdatesFlow: Flow = (additionalUpdatesSharedFlow.asSharedFlow()).let { @@ -99,25 +89,22 @@ class DefaultBehaviourContext( broadcastChannelsSize: Int, onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow?, - telegramHandlersRegistrar: TelegramHandlersRegistrar, updatesFilter: BehaviourContextAndTypeReceiver? - ): BehaviourContext = DefaultBehaviourContext(bot, scope, telegramHandlersRegistrar, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter) + ): BehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter) } fun BehaviourContext( bot: TelegramBot, scope: CoroutineScope, - flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), -) = DefaultBehaviourContext(bot, scope, telegramHandlersRegistrar, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow) + flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter() +) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow) inline fun BehaviourContext( bot: TelegramBot, scope: CoroutineScope, flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(), - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), crossinline block: BehaviourContext.() -> T -) = DefaultBehaviourContext(bot, scope, telegramHandlersRegistrar, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow).run(block) +) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow).run(block) /** * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt index cfaeebcf27..6ab989cd08 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt @@ -4,8 +4,6 @@ import dev.inmo.micro_utils.coroutines.ExceptionHandler import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutorBuilder import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.DefaultTelegramHandlersRegistrar -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers.TelegramHandlersRegistrar import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl @@ -32,7 +30,6 @@ suspend fun telegramBotWithBehaviour( apiUrl: String = telegramBotAPIDefaultUrl, builder: KtorRequestsExecutorBuilder.() -> Unit = {}, defaultExceptionsHandler: ExceptionHandler? = null, - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: BehaviourContextReceiver ): TelegramBot = telegramBot( token, @@ -43,7 +40,6 @@ suspend fun telegramBotWithBehaviour( flowsUpdatesFilter, scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, - telegramHandlersRegistrar, block ) } @@ -67,7 +63,6 @@ suspend fun telegramBotWithBehaviourAndLongPolling( apiUrl: String = telegramBotAPIDefaultUrl, builder: KtorRequestsExecutorBuilder.() -> Unit = {}, defaultExceptionsHandler: ExceptionHandler? = null, - telegramHandlersRegistrar: TelegramHandlersRegistrar = DefaultTelegramHandlersRegistrar(), block: BehaviourContextReceiver ): Pair { return telegramBot( @@ -78,7 +73,6 @@ suspend fun telegramBotWithBehaviourAndLongPolling( it to it.buildBehaviourWithLongPolling( scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, - telegramHandlersRegistrar, block ) } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/DefaultTelegramHandlersRegistrar.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/DefaultTelegramHandlersRegistrar.kt deleted file mode 100644 index 4081424dfc..0000000000 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/DefaultTelegramHandlersRegistrar.kt +++ /dev/null @@ -1,51 +0,0 @@ -package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers - -import dev.inmo.micro_utils.handlers.common.HandlersRegistrar -import dev.inmo.tgbotapi.types.update.abstracts.Update - -class DefaultTelegramHandlersRegistrar : TelegramUpdateHandler, TelegramHandlersRegistrar { - private val mainLayer = mutableListOf() - private val defaultsLayer = mutableListOf() - private var defaultHandler: TelegramUpdateHandler? = null - - private val handlersRegistrar = HandlersRegistrar( - listOf( - mainLayer, - defaultsLayer - ), - object : TelegramUpdateHandler { - override suspend fun check(data: Update): Boolean = defaultHandler ?.check(data) ?: false - override suspend fun handle(data: Update) { defaultHandler ?.handle(data) } - } - ) - - override suspend fun check(data: Update): Boolean { - return handlersRegistrar.check(data) - } - - override suspend fun handle(data: Update) { - handlersRegistrar.handle(data) - } - - override suspend fun includeHandler(handler: TelegramUpdateHandler) { - if (handler in mainLayer) { - return - } - mainLayer.add(handler) - } - - override suspend fun excludeHandler(handler: TelegramUpdateHandler) { - mainLayer.remove(handler) - } - - override suspend fun includeDefaultHandler(handler: TelegramUpdateHandler) { - if (handler in defaultsLayer) { - return - } - defaultsLayer.add(handler) - } - - override suspend fun excludeDefaultHandler(handler: TelegramUpdateHandler) { - defaultsLayer.remove(handler) - } -} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramHandlersRegistrar.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramHandlersRegistrar.kt deleted file mode 100644 index 797b3e6477..0000000000 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramHandlersRegistrar.kt +++ /dev/null @@ -1,9 +0,0 @@ -package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers - -interface TelegramHandlersRegistrar { - suspend fun includeHandler(handler: TelegramUpdateHandler) - suspend fun excludeHandler(handler: TelegramUpdateHandler) - - suspend fun includeDefaultHandler(handler: TelegramUpdateHandler) - suspend fun excludeDefaultHandler(handler: TelegramUpdateHandler) -} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramUpdateHandler.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramUpdateHandler.kt deleted file mode 100644 index 41f34fca4b..0000000000 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers/TelegramUpdateHandler.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers - -import dev.inmo.micro_utils.handlers.common.Handler -import dev.inmo.tgbotapi.types.update.abstracts.Update - -interface TelegramUpdateHandler : Handler