Answer the question
In order to leave comments, you need to log in
Why is the imported phrase not working in the pyTelegramBotAPI bot?
Problem: When I write a condition for a function it is not used.
The code:
def send_text(message):
if message.text.lower() == '/menu':
bot.send_message(message.chat.id, 'Что тебе нужно? \n1. Способности персонажей \n2. Топ профилей игроков \n3. Правила игры')
elif message.text.lower() in ['Топ профилей' , '/profile', '2']:
bot.send_message(message.chat.id, 'Топ профилей еще нет.\n\nТоп профилей обновляется каждую неделю')
elif message.text.lower() in ['1', 'Способности Персонажей', '/stats']:
bot.send_message(message.chat.id, 'Напишите имя персонажа')
elif message.text.lower() in ['3', 'Правила игры', '/rules']:
bot.send_message(message.chat.id, 'Правила:')
elif message.text.lower() == 'Мелиодас':
bot.send_message(message.chat.id, p.Meliodas)
elif message.text.lower() in ['Глоксиния']:
bot.send_message(message.chat.id, p.Gloksinia)
else:
bot.send_message(message.chat.id, 'Не понял, ты написал что-то не то.')
Answer the question
In order to leave comments, you need to log in
think about how it should message
bemessage.text.lower() == 'Мелиодас'
You convert all message options to lower case, and then compare the resulting value, which contains only small letters, with the text, which contains capital letters. Rewrite the constants in lowercase and everything will work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question