fix: continue registration if user submits valid number for age

This commit is contained in:
Yuri Torlopov 2024-06-19 16:54:53 +03:00
parent 55a5a3e5d6
commit a31350c6fc

View file

@ -16,7 +16,7 @@ fun Router<*>.routing() {
handle { handle {
val keyboard = inlineKeyboard { val keyboard = inlineKeyboard {
row { row {
button(update.message!!.from!!.firstName, "username") button(message.from!!.firstName, "username")
} }
} }
@ -52,9 +52,16 @@ fun Router<*>.routing() {
text { text {
handle { handle {
val age = message.text!! val age = message.text!!
data.set("age", age)
setState(StartStates.WaitingCity) try {
message.answer("Well, in which city do you live?") age.toInt()
data.set("age", age)
setState(StartStates.WaitingCity)
message.answer("Well, in which city do you live?")
} catch (e: NumberFormatException) {
message.answer("Wrong input! Age must be a valid number!")
}
} }
} }
} }