diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e713004..fbb20a5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ ssh = "2.10.1" shadow = "7.0.0" wdater = "0.0.4" -meetacySdk = "0.0.60-buildae91a02" +meetacySdk = "0.0.60-buildf702b69" meetacyDi = "0.0.25" [libraries] diff --git a/src/main/kotlin/app/meetacy/telegram/bot/Main.kt b/src/main/kotlin/app/meetacy/telegram/bot/Main.kt index 988bb02..7af729a 100644 --- a/src/main/kotlin/app/meetacy/telegram/bot/Main.kt +++ b/src/main/kotlin/app/meetacy/telegram/bot/Main.kt @@ -1,6 +1,7 @@ package app.meetacy.telegram.bot import app.meetacy.sdk.MeetacyApi +import app.meetacy.sdk.exception.MeetacyInternalException import app.meetacy.sdk.production import app.meetacy.sdk.types.auth.telegram.SecretTelegramBotKey import app.meetacy.sdk.types.auth.telegram.TemporalTelegramHash @@ -74,12 +75,7 @@ suspend fun main(): Unit = coroutineScope { val (_, temporalHash) = commandParts - if (temporalHash.length != secretBotKeySize) { - sendStartMessage() - return@onEach - } - - scope.launch { + try { meetacy.auth.telegram.finish( temporalHash = TemporalTelegramHash(temporalHash), secretBotKey = secretBotKey, @@ -88,18 +84,22 @@ suspend fun main(): Unit = coroutineScope { firstName = message.from.firstName, lastName = message.from.lastName ) + bot.sendMessage( + chat = message.chat, + text = "You have successfully authorized using your Telegram account, you can now return to the app. To follow up with our news, subscribe to our channel ⬇\uFE0F⬇\uFE0F⬇\uFE0F", + replyMarkup = inlineKeyboard { + +URLInlineKeyboardButton( + text = "@meetacy", + url = "https://t.me/meetacy" + ) + } + ) + } catch (error: MeetacyInternalException) { + bot.sendMessage( + chat = message.chat, + text = "Sorry, for some reason we couldn't authorize you. Try again later..." + ) } - - bot.sendMessage( - chat = message.chat, - text = "You have successfully authorized using your Telegram account, you can now return to the app. To follow up with our news, subscribe to our channel ⬇\uFE0F⬇\uFE0F⬇\uFE0F", - replyMarkup = inlineKeyboard { - +URLInlineKeyboardButton( - text = "@meetacy", - url = "https://t.me/meetacy" - ) - } - ) }.launchIn(scope) } }