mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-06-01 23:45:15 +00:00
26 lines
860 B
Kotlin
26 lines
860 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")
|
||
|
|
||
|
FSMPlaguBot(json, config).start().join()
|
||
|
}
|