diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ab6ea..320aff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.1.3 +* `Bot` + * `initPlaguBot` now will return `Job` * `Plugin` * Plugin serializer diff --git a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt index 5d0d004..ae68245 100644 --- a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt +++ b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt @@ -15,12 +15,12 @@ import java.io.File suspend inline fun initPlaguBot( config: Config, scope: CoroutineScope = CoroutineScope(Dispatchers.Default) -) { +): Job { val bot = telegramBot(config.botToken) val paramsMap = config.params ?.toMap() ?: emptyMap() val database = config.params ?.database ?: config.database.database - bot.buildBehaviour(scope) { + return bot.buildBehaviour(scope) { val commands = config.plugins.flatMap { it.apply { invoke(database, paramsMap) } it.getCommands() @@ -45,6 +45,5 @@ suspend fun main(args: Array) { val config = configSerialFormat.decodeFromString(Config.serializer(), file.readText()) val scope = CoroutineScope(Dispatchers.Default) - initPlaguBot(config, scope) - scope.coroutineContext.job.join() + initPlaguBot(config, scope).join() }