mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-09-06 08:40:22 +00:00
add handling of errors in FSMBot and update up to tgbotapi 1.1.2
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user