PlaguBot/bot/src/main/kotlin/dev/inmo/plagubot/App.kt

31 lines
833 B
Kotlin
Raw Normal View History

2020-11-08 13:23:01 +00:00
package dev.inmo.plagubot
2020-11-08 13:04:44 +00:00
2021-02-16 19:21:41 +00:00
import dev.inmo.plagubot.config.*
2020-11-11 17:05:21 +00:00
import kotlinx.coroutines.*
2020-11-12 05:52:09 +00:00
import kotlinx.serialization.InternalSerializationApi
2020-11-11 17:05:21 +00:00
import java.io.File
2020-11-08 13:04:44 +00:00
2021-04-03 16:04:18 +00:00
@Deprecated(
"This method is redundant due to new class PlaguBot",
ReplaceWith(
"PlaguBot(config).start(scope)",
"dev.inmo.plagubot.PlaguBot"
)
)
2020-11-13 05:25:04 +00:00
suspend inline fun initPlaguBot(
config: Config,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
2021-04-03 16:04:18 +00:00
): Job = PlaguBot(config).start(scope)
2020-11-12 06:20:18 +00:00
2020-11-13 05:25:04 +00:00
/**
* This method by default expects one argument in [args] field: path to config
*/
@InternalSerializationApi
suspend fun main(args: Array<String>) {
val (configPath) = args
val file = File(configPath)
2021-02-22 13:08:49 +00:00
val config = configJsonFormat.decodeFromString(ConfigSerializer, file.readText())
2020-11-13 05:25:04 +00:00
2021-04-03 16:04:18 +00:00
PlaguBot(config).start().join()
2020-11-08 13:04:44 +00:00
}