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 5513976b8a..1990b89eba 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 @@ -1,16 +1,13 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder -import dev.inmo.kslog.common.e 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.extensions.DefaultKTgBotAPIPrivacyCommand import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling 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.updateshandlers.FlowsUpdatesFilter -import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog import kotlinx.coroutines.* /** 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 e430e22578..98fcf9f84e 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 @@ -52,6 +52,8 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { val triggersHolder: TriggersHolder + val data: BehaviourContextData + fun copy( bot: TelegramBot = this.bot, scope: CoroutineScope = this.scope, @@ -92,6 +94,8 @@ class DefaultBehaviourContext( }.accumulatorFlow(WeakScope(scope)) override val asUpdateReceiver: UpdateReceiver = additionalUpdatesSharedFlow::emit + override val data: BehaviourContextData = BehaviourContextData() + override fun copy( bot: TelegramBot, scope: CoroutineScope, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData.kt new file mode 100644 index 0000000000..225db1b3d0 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextData.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +data class BehaviourContextData( + val data: MutableMap = mutableMapOf() +) { + fun mergedWith(other: BehaviourContextData): BehaviourContextData = BehaviourContextData( + data.toMutableMap().apply { + putAll(other.data) + } + ) + + operator fun plus(other: BehaviourContextData): BehaviourContextData = mergedWith(other) +}