Skip to content

Commit

Permalink
fill changelog and add docs for CombinedSubcontextInitialAction
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Nov 30, 2024
1 parent 402e695 commit 6b3fabd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SubAction>,
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)

Expand All @@ -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<CombinedSubcontextInitialAction.SubAction>.() -> Unit
): CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> {
Expand All @@ -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<CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>>.() -> Unit
): CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> {
Expand Down

0 comments on commit 6b3fabd

Please sign in to comment.