mirror of
https://github.com/InsanusMokrassar/ConfigurableInlineTelegramBot.git
synced 2024-06-14 05:45:13 +00:00
28 lines
663 B
Kotlin
28 lines
663 B
Kotlin
package dev.inmo.configurable_inline_telegram_bot
|
|
|
|
import kotlinx.coroutines.*
|
|
import java.io.File
|
|
|
|
fun main(vararg args: String) {
|
|
val config = args.first()
|
|
val bot = try {
|
|
serialFormat.decodeFromString(
|
|
FormatterBot.serializer(),
|
|
config
|
|
)
|
|
} catch (e: Throwable) {
|
|
File(config).readText().let {
|
|
serialFormat.decodeFromString(
|
|
FormatterBot.serializer(),
|
|
it
|
|
)
|
|
}
|
|
}
|
|
val scope = CoroutineScope(Dispatchers.Default)
|
|
scope.launch {
|
|
bot.start(scope)
|
|
}
|
|
runBlocking {
|
|
scope.coroutineContext[Job]!!.join()
|
|
}
|
|
} |