Skip to content

Commit

Permalink
fix: added check for invalid token
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Nov 25, 2023
1 parent 52e1178 commit be7106d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
34 changes: 17 additions & 17 deletions src/main/kotlin/app/meetacy/telegram/bot/Main.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
}

0 comments on commit be7106d

Please sign in to comment.