refactor(tgbot): share numeric keypad transitions (#6211)

Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
This commit is contained in:
n0ctal
2026-08-13 15:41:47 +05:00
committed by GitHub
parent 4a5f6771b3
commit 238e4bb314
3 changed files with 62 additions and 60 deletions
@@ -0,0 +1,18 @@
package tgbot
// updateNumericInput applies one key from the shared inline number pad.
// Key -2 clears the value, -1 removes the last decimal digit, and 0..9 append
// a digit. Callers retain their own validation and keyboard labels.
func updateNumericInput(value, key int) int {
switch key {
case -2:
return 0
case -1:
if value > 0 {
return value / 10
}
return value
default:
return value*10 + key
}
}