From 803c5fd664c16b4118e650d39a26e28ca7c0d4ef Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 18 May 2022 17:46:04 +0600 Subject: [PATCH 1/2] add handling of errors in FSMBot and update up to tgbotapi 1.1.2 --- FSMBot/src/main/kotlin/SimpleFSMBot.kt | 17 ++++++++++++++++- gradle.properties | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/FSMBot/src/main/kotlin/SimpleFSMBot.kt b/FSMBot/src/main/kotlin/SimpleFSMBot.kt index 36dd2a0..24c8fd6 100644 --- a/FSMBot/src/main/kotlin/SimpleFSMBot.kt +++ b/FSMBot/src/main/kotlin/SimpleFSMBot.kt @@ -18,7 +18,22 @@ data class StopState(override val context: ChatId) : BotState suspend fun main(args: Array) { val botToken = args.first() - telegramBotWithBehaviourAndFSMAndStartLongPolling(botToken, CoroutineScope(Dispatchers.IO)) { + telegramBotWithBehaviourAndFSMAndStartLongPolling( + 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 { sendMessage( it.context, diff --git a/gradle.properties b/gradle.properties index 41e2953..e5be33b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 From 389d96f323d6bc461d5e07139bc69870cef489f0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 18 May 2022 17:46:50 +0600 Subject: [PATCH 2/2] fix of checkWebAppData method call --- WebApp/src/jvmMain/kotlin/WebAppServer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index b6766c3..ba39403 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -68,7 +68,7 @@ suspend fun main(vararg args: String) { val requestBody = call.receiveText() val webAppCheckData = Json { }.decodeFromString(WebAppDataWrapper.serializer(), requestBody) - val isSafe = telegramBotAPIUrlsKeeper.checkWebAppLink(webAppCheckData.data, webAppCheckData.hash) + val isSafe = telegramBotAPIUrlsKeeper.checkWebAppData(webAppCheckData.data, webAppCheckData.hash) call.respond(HttpStatusCode.OK, isSafe.toString()) }