Python Forum

Full Version: Question about telegram bot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, im writing a telegram bot and i got a problem:
In the story there is a moment where user need to choose one of two options for further development of the plot and i need that the algorithm will not continue until the user selects one of the options. Ive tried to do this by cycle, but it didnt worked. It doesnt react to any commands. Aking for a help.

user_markup = telebot.types.ReplyKeyboardMarkup(True, True)
        user_markup.row('? Вызвать полицию')
        user_markup.row('? Подслушать их разговор')
        bot.send_message(message.from_user.id, 'Выбор за вами! ⬇', reply_markup=user_markup)
This part creates 2 buttons

i = 0
        while i < 1:
            if message.text == '? Вызвать полицию' or message.text == '? Подслушать их разговор':
                i = i + 2
            else:
                print(i)
Cycle that doesnt work. You can see that when none of the conditions is met, then the value 0 is sent to us, so the program sends an infinite number 0.

        if message.text == '? Вызвать полицию':
            photo = open('C:/Users/Роман/Desktop/TGBot/photo/a20.png', 'rb')
            bot.send_photo(message.chat.id, photo)
            time.sleep(1)
            remove_markup = telebot.types.ReplyKeyboardRemove()
            bot.send_message(message.from_user.id, 'Клэр: Есть только один способ решения этой проблемы.', reply_markup=remove_markup)
            time.sleep(3)
            user_markup = telebot.types.ReplyKeyboardMarkup(True, True)
            user_markup.row('? На главную')
            bot.send_message(message.from_user.id, 'ПРОДОЛЖЕНИЕ В РАЗРАБОТКЕ', reply_markup=user_markup)
        elif message.text == '? Подслушать их разговор':
            remove_markup = telebot.types.ReplyKeyboardRemove()
            bot.send_message(message.from_user.id, 'СЮЖЕТНАЯ ВЕТКА В РАЗРАБОТКЕ', reply_markup=remove_markup)
            user_markup = telebot.types.ReplyKeyboardMarkup(True, True)
            user_markup.row('? На главную')
            bot.send_message(message.from_user.id, 'Главная', reply_markup=user_markup)
if-else that should happen after users choice