S
S
stry1tex2021-06-08 20:47:56
Python
stry1tex, 2021-06-08 20:47:56

How to set text value to if message text?

Hello everyone, I want to implement the District Selection in the bot. i.e. the bot asks the person "What area are you in"
I.e. what to write in if message.text == ' what to write here ' so that only text messages are read, and if, for example, numbers, then the bot would answer such an area does not exist

if message.text == ' what to write here to accept any text, not just one word ':
bot.send_message(call.message.chat.id, 'Okay, thanks for the answer!')
else:
bot. send_message(call.message.chat.id, 'This city doesn't exist')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-06-08
@stry1tex

if not message.text.isdigit():
    bot.send_message(call.message.chat.id, 'Хорошо, спасибо за ответ!')
else:
    bot.send_message(call.message.chat.id, 'Такого города не существет')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question