H
H
hpmalo2018-03-16 20:28:59
Python
hpmalo, 2018-03-16 20:28:59

How to make the bot react only to text?

if m.text == str(m.text):
        bot.send_message(m.chat.id, 'Теперь введи номер телефона')

    else:
        trir=bot.send_message(m.chat.id, 'Я тебя не понимаю')
        bot.register_next_step_handler(trir, fio)

I want to make it so that it reacts only to text, without numbers and everything else

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
javedimka, 2018-03-16
@hpmalo

Strings have a .isalpha() method that returns True if all characters in the string are alphabetic characters and there is at least one character in the string.

''.isalpha()  # False
'  '.isalpha()  # False
'[email protected]#'.isalpha()  # False
'abc'.isalpha()  # True
'123'.isalpha()  # False
'abc123'.isalpha()  # False
'абв'.isalpha()  # True
'абв123'.isalpha()  # False

I advise you to follow the link and look at other equally wonderful string methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question