1
0

numeric_input.go 355 B

1234567891011121314151617
  1. package tgbot
  2. // updateNumericInput applies one number-pad key: -2 clears, -1 backspaces, and 0..9 append.
  3. // Callers retain their own validation and keyboard labels.
  4. func updateNumericInput(value, key int) int {
  5. switch key {
  6. case -2:
  7. return 0
  8. case -1:
  9. if value > 0 {
  10. return value / 10
  11. }
  12. return value
  13. default:
  14. return value*10 + key
  15. }
  16. }