1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 00:27:14 +00:00

fill changelog and add docs for CombinedSubcontextInitialAction

This commit is contained in:
InsanusMokrassar 2024-11-30 14:38:40 +06:00
parent 402e695f99
commit 6b3fabdb30
2 changed files with 22 additions and 0 deletions

View File

@ -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`:

View File

@ -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)
@ -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> {
@ -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> {