mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-11-22 07:33:46 +00:00
initPlaguBot
This commit is contained in:
parent
f515c7548b
commit
b4106d7710
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 0.0.3
|
## 0.0.3
|
||||||
|
|
||||||
|
* `Bot`:
|
||||||
|
* New function `initPlaguBot` which actually will launch the bot
|
||||||
|
|
||||||
## 0.0.2
|
## 0.0.2
|
||||||
|
|
||||||
* `Versions`
|
* `Versions`
|
||||||
|
@ -11,17 +11,10 @@ import kotlinx.coroutines.*
|
|||||||
import kotlinx.serialization.InternalSerializationApi
|
import kotlinx.serialization.InternalSerializationApi
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
suspend inline fun initPlaguBot(
|
||||||
* This method by default expects one argument in [args] field: path to config
|
config: Config,
|
||||||
*/
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
@InternalSerializationApi
|
) {
|
||||||
suspend fun main(args: Array<String>) {
|
|
||||||
val (configPath) = args
|
|
||||||
val file = File(configPath)
|
|
||||||
val config = configSerialFormat.decodeFromString(Config.serializer(), file.readText())
|
|
||||||
|
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
|
||||||
|
|
||||||
val bot = telegramBot(config.botToken)
|
val bot = telegramBot(config.botToken)
|
||||||
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
||||||
@ -41,6 +34,18 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
val config = configSerialFormat.decodeFromString(Config.serializer(), file.readText())
|
||||||
|
|
||||||
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
initPlaguBot(config, scope)
|
||||||
scope.coroutineContext.job.join()
|
scope.coroutineContext.job.join()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user