mirror of
https://github.com/InsanusMokrassar/ConfigurableInlineTelegramBot.git
synced 2026-04-03 14:42:22 +00:00
init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user