diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fcf776..fdbad96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 9.3.0 +* Add opportunity to use config in setup bot client + ## 9.2.0 * `Versions`: diff --git a/bot/src/main/kotlin/dev/inmo/plagubot/PlaguBot.kt b/bot/src/main/kotlin/dev/inmo/plagubot/PlaguBot.kt index 53312f8..7616453 100644 --- a/bot/src/main/kotlin/dev/inmo/plagubot/PlaguBot.kt +++ b/bot/src/main/kotlin/dev/inmo/plagubot/PlaguBot.kt @@ -42,9 +42,16 @@ data class PlaguBot( token = config.botToken, apiUrl = config.botApiServer ) { - setupBotClient() + setupBotClient(json) } + override fun KtorRequestsExecutorBuilder.setupBotClient(params: JsonObject) { + config.botPlugins.forEach { + with(it) { + setupBotClient(params) + } + } + } override fun KtorRequestsExecutorBuilder.setupBotClient() { config.botPlugins.forEach { with(it) { diff --git a/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt b/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt index bc5af6c..99f0ab0 100644 --- a/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt +++ b/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt @@ -21,6 +21,7 @@ import org.koin.core.module.Module @Serializable(PluginSerializer::class) interface Plugin : StartPlugin { fun KtorRequestsExecutorBuilder.setupBotClient() {} + fun KtorRequestsExecutorBuilder.setupBotClient(params: JsonObject) = setupBotClient() /** * This method will be called when this plugin should configure di module based on the incoming params