J
J
JewrySoft2020-05-11 23:52:37
Python
JewrySoft, 2020-05-11 23:52:37

How to make such a check in the bot?

I'm writing a bot, and when he clicks on a button, he needs to enter a number and a number from 1 to 5.
Here's how I did it:

def get_number(message):
    try:
        if len(message.text) == 13:
            handle = message.text
            number = handle.split(' ')[0]
            ret = handle.split(' ')[1]
            print(f'{number} + {ret}')
            if int(ret) < int('5'): # тут идет проверка на число от 1 до 5
                bot.send_message(message.chat.id, '<b>✉️началось</b>', parse_mode='HTML')
        if len(message.text) == 14:
            handle = message.text
            number = handle.split(' ')[0]
            ret = handle.split(' ')[1]
            print(f'{number} + {ret}')
            if int(ret) < int('5'):
                bot.send_message(message.chat.id, '<b>✉️началось</b>', parse_mode='HTML')
    except:
        bot.send_message(message.chat.id, '<b>Произошла ошибка!</b>', parse_mode='HTML')

@bot.message_handler(content_types=["text"])
def message_handler(message):
    if message.text == '✉️Начать':
        message = bot.send_message(message.chat.id, '✔️Введите номер в международном формате (без +), а также число от 1 до 5. пример 79999999999 5')
        bot.register_next_step_handler(message, get_number);

    else:
        bot.send_message(message.chat.id, '<b>wtf</b>', parse_mode='HTML')

bot.infinity_polling(True)


But when I enter the text after the message Start, I enter 79999999999 5, but in the end, nothing is written, either in the console or in the TG. help me please

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question