add handling of errors in FSMBot and update up to tgbotapi 1.1.2

This commit is contained in:
InsanusMokrassar 2022-05-18 17:46:04 +06:00
parent b6eb4fe134
commit 803c5fd664
2 changed files with 17 additions and 2 deletions

View File

@ -18,7 +18,22 @@ data class StopState(override val context: ChatId) : BotState
suspend fun main(args: Array<String>) {
val botToken = args.first()
telegramBotWithBehaviourAndFSMAndStartLongPolling<BotState>(botToken, CoroutineScope(Dispatchers.IO)) {
telegramBotWithBehaviourAndFSMAndStartLongPolling<BotState>(
botToken,
CoroutineScope(Dispatchers.IO),
onStateHandlingErrorHandler = { state, e ->
when (state) {
is ExpectContentOrStopState -> {
println("Thrown error on ExpectContentOrStopState")
}
is StopState -> {
println("Thrown error on StopState")
}
}
e.printStackTrace()
state
}
) {
strictlyOn<ExpectContentOrStopState> {
sendMessage(
it.context,

View File

@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
kotlin_version=1.6.21
telegram_bot_api_version=1.1.1
telegram_bot_api_version=1.1.2
micro_utils_version=0.10.4
serialization_version=1.3.3
ktor_version=2.0.1