Skip to content

Commit

Permalink
Add opportunity to use config in setup bot client
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Sep 14, 2024
1 parent d772d27 commit bb06ba1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 9.3.0

* Add opportunity to use config in setup bot client

## 9.2.0

* `Versions`:
Expand Down
9 changes: 8 additions & 1 deletion bot/src/main/kotlin/dev/inmo/plagubot/PlaguBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb06ba1

Please sign in to comment.