mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-21 06:45:46 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb72ff1c94 | |||
| 6b3fabdb30 | |||
| 402e695f99 | |||
| a87560bc40 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,6 +1,16 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
## 20.1.0
|
## 21.0.0
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `2.0.21` -> `2.1.0`
|
||||||
|
* `MicroUtils`: `0.23.0` -> `0.23.1`
|
||||||
|
* `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
|
## 20.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=20.1.0
|
library_version=21.0.0
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "2.0.21"
|
kotlin = "2.1.0"
|
||||||
kotlin-serialization = "1.7.3"
|
kotlin-serialization = "1.7.3"
|
||||||
kotlin-coroutines = "1.9.0"
|
kotlin-coroutines = "1.9.0"
|
||||||
|
|
||||||
@@ -10,10 +10,10 @@ korlibs = "5.4.0"
|
|||||||
uuid = "0.8.4"
|
uuid = "0.8.4"
|
||||||
ktor = "3.0.1"
|
ktor = "3.0.1"
|
||||||
|
|
||||||
ksp = "2.0.21-1.0.26"
|
ksp = "2.1.0-1.0.29"
|
||||||
kotlin-poet = "1.18.1"
|
kotlin-poet = "1.18.1"
|
||||||
|
|
||||||
microutils = "0.23.0"
|
microutils = "0.23.1"
|
||||||
kslog = "1.3.6"
|
kslog = "1.3.6"
|
||||||
|
|
||||||
versions = "0.51.0"
|
versions = "0.51.0"
|
||||||
|
|||||||
@@ -82,6 +82,27 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourConte
|
|||||||
public static final fun stop (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;)V
|
public static final fun stop (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction {
|
||||||
|
public fun <init> (Ljava/util/List;Ldev/inmo/kslog/common/KSLog;)V
|
||||||
|
public synthetic fun <init> (Ljava/util/List;Ldev/inmo/kslog/common/KSLog;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun getSubactions ()Ljava/util/List;
|
||||||
|
public final fun getSubcontextInitialAction ()Lkotlin/jvm/functions/Function3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface class dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction$SubAction {
|
||||||
|
public abstract fun invoke (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction$SubAction$Callback : dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialAction$SubAction {
|
||||||
|
public fun <init> (Lkotlin/jvm/functions/Function3;)V
|
||||||
|
public fun invoke (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/CombinedSubcontextInitialActionKt {
|
||||||
|
public static final fun buildSubcontextInitialAction (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function3;
|
||||||
|
public static final fun buildSubcontextInitialActionWithSubActions (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function3;
|
||||||
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContext : dev/inmo/tgbotapi/updateshandlers/AbstractFlowsUpdatesFilter, dev/inmo/tgbotapi/bot/RequestsExecutor, dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext, kotlinx/coroutines/CoroutineScope {
|
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehaviourContext : dev/inmo/tgbotapi/updateshandlers/AbstractFlowsUpdatesFilter, dev/inmo/tgbotapi/bot/RequestsExecutor, dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext, kotlinx/coroutines/CoroutineScope {
|
||||||
public fun <init> (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)V
|
public fun <init> (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;)V
|
||||||
public synthetic fun <init> (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
public synthetic fun <init> (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlinx/coroutines/CoroutineScope;ILkotlinx/coroutines/channels/BufferOverflow;Lkotlinx/coroutines/flow/Flow;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/handlers_registrar/TriggersHolder;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
class Callback(private val action: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>) : SubAction {
|
||||||
|
override suspend fun BehaviourContext.invoke(update: Update) {
|
||||||
|
action(update)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val subcontextInitialAction: CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update> = { update ->
|
||||||
|
subactions.forEach { subaction ->
|
||||||
|
with(subaction) {
|
||||||
|
runCatching {
|
||||||
|
invoke(update)
|
||||||
|
}.onFailure {
|
||||||
|
logger.error("Unable to execute $subaction for update $update", it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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> {
|
||||||
|
val list = mutableListOf<CombinedSubcontextInitialAction.SubAction>()
|
||||||
|
list.block()
|
||||||
|
return CombinedSubcontextInitialAction(
|
||||||
|
list.toList()
|
||||||
|
).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> {
|
||||||
|
val list = mutableListOf<CustomBehaviourContextAndTypeReceiver<BehaviourContext, Unit, Update>>()
|
||||||
|
list.block()
|
||||||
|
return CombinedSubcontextInitialAction(
|
||||||
|
list.map {
|
||||||
|
CombinedSubcontextInitialAction.SubAction.Callback(it)
|
||||||
|
}
|
||||||
|
).subcontextInitialAction
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user