mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2025-09-14 21:09:27 +00:00
start 1.1.2 + add opportunity to load object plugins
This commit is contained in:
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user