I want to have a flag that will change the answer of my bot. Here is my code:
import config
import telebot
bot = telebot.TeleBot(config.token)
pills_adding_state = False
@bot.message_handler(commands=['start'])
def handle_start_message(message):
bot.send_message(message.chat.id, "Hi. I will help you remember all the medicine you need to take. Type add to add a medicine to your list")
@bot.message_handler(content_types = ["text"])
def handle_list_of_pills_message(message):
if message.text == "/add":
pills_adding_state = True
bot.send_message(message.chat.id,"Type the medicine name")
elif pills_adding_state ==True:
bot.send_message(message.chat.id,"medicine {} added".format(message.text))
if __name__ == '__main__':
bot.polling(none_stop=True)
I edited my code snippet a bit to make it a bit clearer. The goal is: user types "/add" and then they can type the name of the medicine as soon as the flag pills_adding_state is now true. But the code doesn't work as intended.
Unfortunately, changing the variable "pills_adding_state" doesn't affect the behavior of my bot. What do I do wrong? Thank you.