mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-11-25 17:08:43 +00:00
26 lines
857 B
Kotlin
26 lines
857 B
Kotlin
package dev.inmo.plagubot
|
|
|
|
import dev.inmo.kslog.common.KSLog
|
|
import dev.inmo.kslog.common.i
|
|
import dev.inmo.plagubot.config.Config
|
|
import dev.inmo.plagubot.config.defaultJsonFormat
|
|
import kotlinx.serialization.InternalSerializationApi
|
|
import kotlinx.serialization.json.jsonObject
|
|
import java.io.File
|
|
|
|
/**
|
|
* This method by default expects one argument in [args] field: path to config
|
|
*/
|
|
@InternalSerializationApi
|
|
suspend fun main(args: Array<String>) {
|
|
KSLog.default = KSLog("PlaguBot")
|
|
val (configPath) = args
|
|
val file = File(configPath)
|
|
KSLog.i("Start read config from ${file.absolutePath}")
|
|
val json = defaultJsonFormat.parseToJsonElement(file.readText()).jsonObject
|
|
val config = defaultJsonFormat.decodeFromJsonElement(Config.serializer(), json)
|
|
KSLog.i("Config has been read")
|
|
|
|
PlaguBot(json, config).start().join()
|
|
}
|