mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2025-12-05 13:55:53 +00:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbe166f2b4 | |||
| 30cf190461 | |||
| 9d72d79321 | |||
| 33057dd2cb | |||
| e1bb8e9799 | |||
| fd5e979f11 | |||
| 20e1f042f1 | |||
| 0e65a425c3 | |||
| 517ab1e1a4 | |||
| 977cf32669 | |||
| 5bd1916fb5 | |||
| 8c22b418f8 | |||
| 3663f987bc | |||
| 93d15af80d | |||
| 27c5f379a4 | |||
| ae7a7b84ac | |||
| 5b98aef237 | |||
| 3755972394 | |||
| 5d5312c66f | |||
| f79fef3dae | |||
| 2c8dc80eae | |||
| a2a2fe7ef4 | |||
| 34cadab809 | |||
| 784e041519 | |||
| 4784f05c8e | |||
| e89b0a6ba2 | |||
| b48d278446 | |||
| 072a64362d | |||
| 7715f519e3 | |||
| 7982f27217 | |||
| eeb3ae1dbe | |||
| 8a73fda6fa | |||
| 05e94249af | |||
| 74c36c66f1 | |||
| 5153f732ce | |||
| fb23e9be79 | |||
| 292640b465 | |||
| a863d91bab | |||
| d1064bb9cd | |||
| a9c3b937e7 | |||
| 6757354652 | |||
| c65efb6ffb | |||
| f9cc279854 | |||
| b2d00cb5ae | |||
| 782721751a | |||
| 01086766ba | |||
| bf0a6ab659 | |||
| a3e6f8a6b5 | |||
| cd9ba5dc19 | |||
| 8e0d35a80d | |||
| a49fb60555 | |||
| ec26179d2a | |||
| daed26cba6 | |||
| 7c820b70ac | |||
| edb15f11db | |||
| 18000429b0 | |||
| d975e61966 | |||
| 663e00cad6 | |||
| 6725193545 | |||
| ccfd91b1ac | |||
| c8b69d641f | |||
| 7af11fc427 | |||
| 59b91fc1ff | |||
| 4293096ed2 | |||
| 42dd98426c | |||
| 744520c73f | |||
| 1b8ae09866 | |||
| 3027e39665 | |||
| b77fe446f8 | |||
| bc11d7508f | |||
| cd9af3c216 | |||
| c60face0e6 | |||
| 334ca1a184 | |||
| b7bb6f10a9 |
138
CHANGELOG.md
138
CHANGELOG.md
@@ -1,5 +1,143 @@
|
||||
# Changelog
|
||||
|
||||
## 7.2.2
|
||||
|
||||
* `Bot`:
|
||||
* Now you may customize both `onStart` and `onUpdate` conflicts resolvers
|
||||
|
||||
## 7.2.1
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `9.2.1`
|
||||
* `ktor`: `2.3.4`
|
||||
|
||||
## 7.2.0
|
||||
|
||||
* `Version`:
|
||||
* `tgbotapi`: `9.2.0`
|
||||
* `kslog`: `1.1.2`
|
||||
* `sqlite`: `3.43.0.0`
|
||||
|
||||
## 7.1.0
|
||||
|
||||
* `Version`:
|
||||
* `microutils`: `0.19.9`
|
||||
* `tgbotapi`: `9.1.0`
|
||||
* `ktor`: `2.3.3`
|
||||
* `coroutines`: `1.7.3`
|
||||
* `koin`: `3.4.3`
|
||||
|
||||
## 7.0.0
|
||||
|
||||
* `Version`:
|
||||
* `microutils`: `0.19.7`
|
||||
* `tgbotapi`: `9.0.0`
|
||||
* `ktor`: `2.3.2`
|
||||
* `coroutines`: `1.7.2`
|
||||
|
||||
## 6.1.0
|
||||
|
||||
* `Version`:
|
||||
* `kotlin`: `1.8.22`
|
||||
* `microutils`: `0.19.4`
|
||||
* `tgbotapi`: `8.1.0`
|
||||
* `koin`: `3.4.2`
|
||||
* `sqlite`: `3.42.0.0`
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* `Version`:
|
||||
* `microutils`: `0.19.2`
|
||||
* `tgbotapi`: `8.0.1`
|
||||
* `uuid`: `0.7.1`
|
||||
* `ktor`: `2.3.1`
|
||||
* `koin`: `3.4.1`
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* `Versions`:
|
||||
* `microutils`: `0.19.1`
|
||||
* `tgbotapi`: `8.0.0`
|
||||
* `klock`: `4.0.3`
|
||||
|
||||
## 5.1.3
|
||||
|
||||
* `Versions`:
|
||||
* `serialization`: `1.5.1`
|
||||
* `microutils`: `0.18.4`
|
||||
* `tgbotapi`: `7.1.3`
|
||||
|
||||
## 5.1.2
|
||||
|
||||
* `Versions`:
|
||||
* `microutils`: `0.18.1`
|
||||
* `tgbotapi`: `7.1.2`
|
||||
|
||||
## 5.1.1
|
||||
|
||||
* `Versions`:
|
||||
* `kotlin`: `1.8.21`
|
||||
* `microutils`: `0.18.0`
|
||||
* `tgbotapi`: `7.1.1`
|
||||
|
||||
## 5.1.0
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `7.1.0`
|
||||
* `sqlite`: `3.41.2.1`
|
||||
|
||||
## 5.0.2
|
||||
|
||||
* `Versions`:
|
||||
* `kotlin`: `1.8.20`
|
||||
* `microutils`: `0.17.8`
|
||||
* `tgbotapi`: `7.0.2`
|
||||
* `kslog`: `1.1.1`
|
||||
* `ktor`: `2.3.0`
|
||||
* `koin`: `3.4.0`
|
||||
|
||||
## 5.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `7.0.1`
|
||||
|
||||
## 5.0.0
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `7.0.0`
|
||||
* `microutils`: `0.17.5`
|
||||
|
||||
## 4.1.0
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `6.1.0`
|
||||
* `microutils`: `0.17.3`
|
||||
|
||||
## 4.0.3
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `6.0.3`
|
||||
* `microutils`: `0.17.2`
|
||||
|
||||
## 4.0.2
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `6.0.2`
|
||||
|
||||
## 4.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `tgbotapi`: `6.0.1`
|
||||
* `microutils`: `17.0.1`
|
||||
* `ktor`: `2.2.4`
|
||||
|
||||
## 4.0.0
|
||||
|
||||
* `Versions`:
|
||||
* `kotlin`: `1.8.10`
|
||||
* `tgbotapi`: `6.0.0`
|
||||
* `microutils`: `0.17.0`
|
||||
|
||||
## 3.5.0
|
||||
|
||||
* `Versions`:
|
||||
|
||||
@@ -2,6 +2,7 @@ plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id 'application'
|
||||
id "com.google.devtools.ksp"
|
||||
}
|
||||
|
||||
project.group="$group"
|
||||
@@ -18,6 +19,7 @@ dependencies {
|
||||
api libs.tgbotapi
|
||||
api libs.tgbotapi.behaviourBuilder.fsm
|
||||
api libs.microutils.repos.exposed
|
||||
api libs.microutils.koin
|
||||
api libs.kslog
|
||||
|
||||
api libs.sqlite
|
||||
@@ -36,3 +38,6 @@ java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
ksp { // this generator do not require any arguments and we should left `ksp` empty
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.plagubot
|
||||
|
||||
import dev.inmo.micro_utils.fsm.common.State
|
||||
|
||||
fun interface OnStartContextsConflictResolver {
|
||||
/**
|
||||
* @param old Old state which is currently placed on the [State.context]
|
||||
* @param new New state pretend to replace [old] one
|
||||
* @return Should return:
|
||||
*
|
||||
* * Null in case when current realization unable to resolve conflict
|
||||
* * False when current realization knows that [new] [State] must **not** replace [old] one
|
||||
* * True when current realization knows that [new] [State] must replace [old] one
|
||||
*/
|
||||
suspend operator fun invoke(old: State, new: State): Boolean?
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.plagubot
|
||||
|
||||
import dev.inmo.micro_utils.fsm.common.State
|
||||
|
||||
fun interface OnUpdateContextsConflictResolver {
|
||||
/**
|
||||
* This method will be called when [sourceStateWithOldContext] [State.context] and [newStateWithNewContext] are not equal and currently there is
|
||||
* launched [currentStateOnNewContext] state on the chain with [State.context] from [currentStateOnNewContext]
|
||||
*
|
||||
* @param sourceStateWithOldContext Old state where from [newStateWithNewContext] came
|
||||
* @param newStateWithNewContext New state with changing [State.context] (it is different with [sourceStateWithOldContext] [State.context])
|
||||
* @param currentStateOnNewContext State which is currently running on [newStateWithNewContext] [State.context]
|
||||
* @return Should return:
|
||||
*
|
||||
* * Null in case when current realization unable to resolve conflict
|
||||
* * False when [currentStateOnNewContext] **should not** be stopped in favor to [newStateWithNewContext]
|
||||
* * True when [currentStateOnNewContext] **should** be stopped in favor to [newStateWithNewContext]
|
||||
*/
|
||||
suspend operator fun invoke(sourceStateWithOldContext: State, newStateWithNewContext: State, currentStateOnNewContext: State): Boolean?
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.micro_utils.fsm.common.State
|
||||
import dev.inmo.micro_utils.fsm.common.StatesManager
|
||||
import dev.inmo.micro_utils.fsm.common.managers.*
|
||||
import dev.inmo.micro_utils.koin.getAllDistinct
|
||||
import dev.inmo.plagubot.config.*
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.webhook.deleteWebhook
|
||||
@@ -94,6 +95,8 @@ data class PlaguBot(
|
||||
GlobalContext.startKoin(koinApp)
|
||||
logger.i("Koin started")
|
||||
lateinit var behaviourContext: BehaviourContext
|
||||
val onStartContextsConflictResolver by lazy { koinApp.koin.getAllDistinct<OnStartContextsConflictResolver>() }
|
||||
val onUpdateContextsConflictResolver by lazy { koinApp.koin.getAllDistinct<OnUpdateContextsConflictResolver>() }
|
||||
bot.buildBehaviourWithFSM(
|
||||
scope = scope,
|
||||
defaultExceptionsHandler = {
|
||||
@@ -101,7 +104,8 @@ data class PlaguBot(
|
||||
},
|
||||
statesManager = koinApp.koin.getOrNull<StatesManager<State>>() ?: DefaultStatesManager(
|
||||
koinApp.koin.getOrNull<DefaultStatesManagerRepo<State>>() ?: InMemoryDefaultStatesManagerRepo<State>(),
|
||||
onStartContextsConflictResolver = { _, _ -> false }
|
||||
onStartContextsConflictResolver = { old, new -> onStartContextsConflictResolver.firstNotNullOfOrNull { it(old, new) } ?: false },
|
||||
onUpdateContextsConflictResolver = { old, new, currentNew -> onUpdateContextsConflictResolver.firstNotNullOfOrNull { it(old, new, currentNew) } ?: false }
|
||||
),
|
||||
onStateHandlingErrorHandler = koinApp.koin.getOrNull<StateHandlingErrorHandler<State>>() ?: { state, e ->
|
||||
logger.eS(e) { "Unable to handle state $state" }
|
||||
|
||||
@@ -8,6 +8,7 @@ buildscript {
|
||||
classpath libs.buildscript.kt.gradle
|
||||
classpath libs.buildscript.kt.serialization
|
||||
classpath libs.buildscript.gh.release
|
||||
classpath libs.buildscript.ksp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ kotlin.js.generate.externals=true
|
||||
kotlin.incremental=true
|
||||
|
||||
group=dev.inmo
|
||||
version=4.0.0
|
||||
version=7.2.2
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
[versions]
|
||||
|
||||
kt = "1.8.10"
|
||||
kt-serialization = "1.5.0"
|
||||
kt-coroutines = "1.6.4"
|
||||
kt = "1.8.22"
|
||||
kt-serialization = "1.5.1"
|
||||
kt-coroutines = "1.7.3"
|
||||
|
||||
microutils = "0.17.0"
|
||||
tgbotapi = "6.0.0"
|
||||
kslog = "1.0.0"
|
||||
microutils = "0.19.9"
|
||||
tgbotapi = "9.2.1"
|
||||
kslog = "1.1.2"
|
||||
|
||||
ksp = "1.8.22-1.0.11"
|
||||
|
||||
jb-exposed = "0.41.1"
|
||||
jb-dokka = "1.7.20"
|
||||
jb-dokka = "1.8.20"
|
||||
|
||||
sqlite = "3.40.0.0"
|
||||
sqlite = "3.43.0.0"
|
||||
|
||||
klock = "3.4.0"
|
||||
uuid = "0.7.0"
|
||||
klock = "4.0.3"
|
||||
uuid = "0.7.1"
|
||||
|
||||
ktor = "2.2.3"
|
||||
ktor = "2.3.4"
|
||||
|
||||
gh-release = "2.4.1"
|
||||
|
||||
koin = "3.3.2"
|
||||
koin = "3.4.3"
|
||||
|
||||
[libraries]
|
||||
|
||||
@@ -32,6 +34,8 @@ kt-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json"
|
||||
tgbotapi = { module = "dev.inmo:tgbotapi", version.ref = "tgbotapi" }
|
||||
tgbotapi-behaviourBuilder-fsm = { module = "dev.inmo:tgbotapi.behaviour_builder.fsm", version.ref = "tgbotapi" }
|
||||
microutils-repos-exposed = { module = "dev.inmo:micro_utils.repos.exposed", version.ref = "microutils" }
|
||||
microutils-koin = { module = "dev.inmo:micro_utils.koin", version.ref = "microutils" }
|
||||
microutils-koin-generator = { module = "dev.inmo:micro_utils.koin.generator", version.ref = "microutils" }
|
||||
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
|
||||
|
||||
koin = { module = "io.insert-koin:koin-core", version.ref = "koin" }
|
||||
@@ -48,3 +52,4 @@ buildscript-kt-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin",
|
||||
buildscript-kt-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kt" }
|
||||
buildscript-jb-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "jb-dokka" }
|
||||
buildscript-gh-release = { module = "com.github.breadmoirai:github-release", version.ref = "gh-release" }
|
||||
buildscript-ksp = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user