S
S
smoosh2020-08-27 15:14:56
Python
smoosh, 2020-08-27 15:14:56

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, 'Не понял, ты написал что-то не то.')


Not working - Meliodas and Gloxinia

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
smoosh, 2020-08-27
@smoosh

If anything, everything is fine with the line indentation.

T
Timur Pokrovsky, 2020-08-27
@Makaroshka007

think about how it should messagebemessage.text.lower() == 'Мелиодас'

S
Sergey Tikhonov, 2020-09-06
@tumbler

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 question

Ask a Question

731 491 924 answers to any question