From 6b3fabdb3090305a6c4a3d3488a443ea3e511428 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 30 Nov 2024 14:38:40 +0600 Subject: [PATCH] fill changelog and add docs for CombinedSubcontextInitialAction --- CHANGELOG.md | 7 +++++++ .../CombinedSubcontextInitialAction.kt | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7cd9eb4ef..d32174f6a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## 21.0.0 +* `BehaviourBuilder`: + * Add special `val data: BehaviourContextData` into all realizations of `BehaviourContext` + * Add `CombinedSubcontextInitialAction` and functions +`buildSubcontextInitialAction`/`buildSubcontextInitialActionWithSubActions` + * Add `subcontextInitialAction` for all the functions-builders of `BehaviourContext` and +`additionalSubcontextInitialAction` to all triggers + ## 20.0.1 * `Core`: diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction.kt index 5099ba9f00..b4b4ae66a1 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction.kt @@ -4,10 +4,17 @@ import dev.inmo.kslog.common.KSLog import dev.inmo.kslog.common.error import dev.inmo.tgbotapi.types.update.abstracts.Update +/** + * Contains [SubAction]s which will be used in [subcontextInitialAction] in order they has been passed in [subactions]. + */ class CombinedSubcontextInitialAction( val subactions: List, private val logger: KSLog = KSLog("CombinedSubcontextInitialAction_${subactions.size}") ) { + /** + * Represents interface-like variant of [CustomBehaviourContextAndTypeReceiver] useful for [BehaviourContext] + * builders + */ fun interface SubAction { suspend operator fun BehaviourContext.invoke(update: Update) @@ -30,6 +37,10 @@ class CombinedSubcontextInitialAction( } } +/** + * Build [CombinedSubcontextInitialAction] with [block] and return callback, which appropriate for [BehaviourContext] + * builders with `subcontextInitialAction` argument + */ inline fun buildSubcontextInitialActionWithSubActions( block: MutableList.() -> Unit ): CustomBehaviourContextAndTypeReceiver { @@ -40,6 +51,10 @@ inline fun buildSubcontextInitialActionWithSubActions( ).subcontextInitialAction } +/** + * Build [CombinedSubcontextInitialAction] with [block] and return callback, which appropriate for [BehaviourContext] + * builders with `subcontextInitialAction` argument + */ inline fun buildSubcontextInitialAction( block: MutableList>.() -> Unit ): CustomBehaviourContextAndTypeReceiver {