mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-10-25 09:10:07 +00:00
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 24.0.2
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `2.1.10` -> `2.1.20`
|
||||||
|
* `Ktor`: `3.1.0` -> `3.1.1`
|
||||||
|
* `MicroUtils`: `0.24.7` -> `0.25.3`
|
||||||
|
* `DefaultKTgBotAPIKSLog` will drop `CancellationException`s by default
|
||||||
|
* You may configure `DefaultKTgBotAPIKSLog` in simple way with `SetDefaultKTgBotAPIKSLog`
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* `FSM`:
|
||||||
|
* Fix chains cancelling on their ends
|
||||||
|
|
||||||
## 24.0.1
|
## 24.0.1
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
|||||||
@@ -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=24.0.1
|
library_version=24.0.2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "2.1.10"
|
kotlin = "2.1.20"
|
||||||
kotlin-serialization = "1.8.0"
|
kotlin-serialization = "1.8.0"
|
||||||
kotlin-coroutines = "1.10.1"
|
kotlin-coroutines = "1.10.1"
|
||||||
|
|
||||||
@@ -8,12 +8,12 @@ javax-activation = "1.1.1"
|
|||||||
|
|
||||||
korlibs = "5.4.0"
|
korlibs = "5.4.0"
|
||||||
uuid = "0.8.4"
|
uuid = "0.8.4"
|
||||||
ktor = "3.1.0"
|
ktor = "3.1.1"
|
||||||
|
|
||||||
ksp = "2.1.10-1.0.30"
|
ksp = "2.1.20-1.0.31"
|
||||||
kotlin-poet = "1.18.1"
|
kotlin-poet = "1.18.1"
|
||||||
|
|
||||||
microutils = "0.24.7"
|
microutils = "0.25.3"
|
||||||
kslog = "1.4.1"
|
kslog = "1.4.1"
|
||||||
|
|
||||||
versions = "0.51.0"
|
versions = "0.51.0"
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||||
|
|||||||
@@ -144,10 +144,12 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
state.context
|
state.context
|
||||||
).apply {
|
).apply {
|
||||||
stateInitialAction(state)
|
stateInitialAction(state)
|
||||||
}.launchStateHandling(
|
}.run {
|
||||||
state,
|
launchStateHandling(
|
||||||
actualHandlersList
|
state,
|
||||||
)
|
actualHandlersList
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
|
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
|
||||||
@@ -188,7 +190,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
statesJobsMutex.withLock {
|
statesJobsMutex.withLock {
|
||||||
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
||||||
}
|
}
|
||||||
updatesFlows.remove(it.context)
|
updatesFlows.remove(it.context) ?.cancel()
|
||||||
}
|
}
|
||||||
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
|
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
|
||||||
statesJobsMutex.withLock {
|
statesJobsMutex.withLock {
|
||||||
@@ -197,7 +199,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) }
|
statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) }
|
||||||
}
|
}
|
||||||
if (old.context != new.context) {
|
if (old.context != new.context) {
|
||||||
updatesFlows.remove(old.context)
|
updatesFlows.remove(old.context) ?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27147,6 +27147,8 @@ public final class dev/inmo/tgbotapi/utils/ByteReadChannelAllocatorDeserializati
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/utils/DefaultKSLogKt {
|
public final class dev/inmo/tgbotapi/utils/DefaultKSLogKt {
|
||||||
|
public static final fun SetDefaultKTgBotAPIKSLog (ZLkotlin/jvm/functions/Function1;)V
|
||||||
|
public static synthetic fun SetDefaultKTgBotAPIKSLog$default (ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||||
public static final fun getDefaultKTgBotAPIKSLog ()Ldev/inmo/kslog/common/KSLog;
|
public static final fun getDefaultKTgBotAPIKSLog ()Ldev/inmo/kslog/common/KSLog;
|
||||||
public static final fun getDefaultKTgBotAPIKSLogSystemTag ()Ljava/lang/String;
|
public static final fun getDefaultKTgBotAPIKSLogSystemTag ()Ljava/lang/String;
|
||||||
public static final fun setDefaultKTgBotAPIKSLog (Ldev/inmo/kslog/common/KSLog;)V
|
public static final fun setDefaultKTgBotAPIKSLog (Ldev/inmo/kslog/common/KSLog;)V
|
||||||
|
|||||||
@@ -2,18 +2,59 @@ package dev.inmo.tgbotapi.utils
|
|||||||
|
|
||||||
import dev.inmo.kslog.common.KSLog
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.kslog.common.LogLevel
|
import dev.inmo.kslog.common.LogLevel
|
||||||
|
import dev.inmo.kslog.common.MessageFilter
|
||||||
import dev.inmo.kslog.common.TagLogger
|
import dev.inmo.kslog.common.TagLogger
|
||||||
|
import dev.inmo.kslog.common.filter.filtered
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default tag for [DefaultKTgBotAPIKSLog]. You may change it and tag will be changed since the near logging
|
* Default tag for [DefaultKTgBotAPIKSLog]. You may change it and tag will be changed since the near logging
|
||||||
*/
|
*/
|
||||||
var DefaultKTgBotAPIKSLogSystemTag: String = "KTgBot"
|
var DefaultKTgBotAPIKSLogSystemTag: String = "KTgBot"
|
||||||
|
|
||||||
|
private inline fun CreateDefaultKSLogger(
|
||||||
|
crossinline loggerTagGetter: () -> String,
|
||||||
|
dropCancellationExceptions: Boolean = true,
|
||||||
|
noinline additionalLoggerMapper: (KSLog.() -> KSLog)? = null
|
||||||
|
): KSLog {
|
||||||
|
val filter: MessageFilter? = if (dropCancellationExceptions) {
|
||||||
|
{ ll, message, e ->
|
||||||
|
e !is CancellationException
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
return KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
|
||||||
|
TagLogger(loggerTagGetter()).performLog(level, tag, message, throwable)
|
||||||
|
}.let {
|
||||||
|
if (filter == null) {
|
||||||
|
additionalLoggerMapper ?.invoke(it) ?: it
|
||||||
|
} else {
|
||||||
|
val base = it.filtered(filter)
|
||||||
|
additionalLoggerMapper ?.invoke(base) ?: base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Default realization of [KSLog] which will be used everywhere where there is no some custom variant of [KSLog]
|
* Default realization of [KSLog] which will be used everywhere where there is no some custom variant of [KSLog]
|
||||||
*
|
*
|
||||||
* By default, uses [KSLog] factory with lambda and tag [DefaultKTgBotAPIKSLogSystemTag] (which in fact falling back to
|
* By default, uses [KSLog] factory with lambda and tag [DefaultKTgBotAPIKSLogSystemTag] (which in fact falling back to
|
||||||
* [KSLog.default] with `KTgBot` default tag)
|
* [KSLog.default] with `KTgBot` default tag)
|
||||||
|
*
|
||||||
|
* @see SetDefaultKTgBotAPIKSLog
|
||||||
*/
|
*/
|
||||||
var DefaultKTgBotAPIKSLog: KSLog = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
|
var DefaultKTgBotAPIKSLog: KSLog = CreateDefaultKSLogger({ DefaultKTgBotAPIKSLogSystemTag } )
|
||||||
TagLogger(DefaultKTgBotAPIKSLogSystemTag).performLog(level, tag, message, throwable)
|
|
||||||
|
/**
|
||||||
|
* Setting [DefaultKTgBotAPIKSLog] with applying of [dropCancellationExceptions] and [additionalFilter] to it
|
||||||
|
*
|
||||||
|
* @param dropCancellationExceptions Will drap coroutines job [CancellationException]s
|
||||||
|
* @param additionalLoggerMapper Receives [KSLog] to allow you to use extensions like [filtered]. Returned
|
||||||
|
* [KSLog] will be used as the result [KSLog] in [DefaultKTgBotAPIKSLog]
|
||||||
|
*/
|
||||||
|
fun SetDefaultKTgBotAPIKSLog(
|
||||||
|
dropCancellationExceptions: Boolean = true,
|
||||||
|
additionalLoggerMapper: (KSLog.() -> KSLog)? = null
|
||||||
|
) {
|
||||||
|
DefaultKTgBotAPIKSLog = CreateDefaultKSLogger({ DefaultKTgBotAPIKSLogSystemTag }, dropCancellationExceptions, additionalLoggerMapper)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user