fix: continue registration if user submits valid number for age
This commit is contained in:
parent
55a5a3e5d6
commit
a31350c6fc
1 changed files with 11 additions and 4 deletions
|
@ -16,7 +16,7 @@ fun Router<*>.routing() {
|
|||
handle {
|
||||
val keyboard = inlineKeyboard {
|
||||
row {
|
||||
button(update.message!!.from!!.firstName, "username")
|
||||
button(message.from!!.firstName, "username")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,16 @@ fun Router<*>.routing() {
|
|||
text {
|
||||
handle {
|
||||
val age = message.text!!
|
||||
data.set("age", age)
|
||||
setState(StartStates.WaitingCity)
|
||||
message.answer("Well, in which city do you live?")
|
||||
|
||||
try {
|
||||
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!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue