start 1.1.2 + add opportunity to load object plugins

This commit is contained in:
2022-06-20 20:52:42 +06:00
parent 5ec1c8c55f
commit e0a19bb5e5
6 changed files with 16 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ import org.koin.dsl.module
@Serializable
@SerialName("Hello")
class HelloPlugin : Plugin {
object HelloPlugin : Plugin {
@Serializable
data class HelloPluginConfig(
val print: String

View File

@@ -56,17 +56,17 @@ data class PlaguBot(
}
override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
config.plugins.map {
config.plugins.map { plugin ->
launch {
runCatchingSafely {
logger.i("Start loading of $it")
with(it) {
logger.i("Start loading of $plugin")
with(plugin) {
setupBotPlugin(koin)
}
}.onFailure { e ->
logger.w("Unable to load bot part of $it", e)
logger.w("Unable to load bot part of $plugin", e)
}.onSuccess {
logger.i("Complete loading of $it")
logger.i("Complete loading of $plugin")
}
}
}.joinAll()

View File

@@ -1,9 +1,11 @@
package dev.inmo.plagubot.config
import dev.inmo.micro_utils.common.Warning
import dev.inmo.plagubot.Plugin
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Warning("This API is internal and can be changed without notifications of mentions of changes")
@Serializable
data class Config(
val botToken: String,