My intention is to develop a bot with pyTelegramBotAPI, in which the internal state 'state' allows or disallows access to certain commands.
The expected output in the fragment is the message only if the command is 'plan' and the 'state' is 0
My code:
import telebot
TOKEN = 'TOKEN'
tb = telebot.TeleBot(TOKEN)
state = 0
@tb.message_handler(commands=['plan'], func=lambda state: state == 0)
def planFunct(m):
idCon = m.chat.id
tb.send_message(idCon, 'El comando plan funciona.' + str(idCon))
tb.polling(none_stop=True)
The result of this fragment is no way out. And I am not able to recognize if the problem starts from a bad use of filters, scope of variables, or misuse of lambda function.
I appreciate the help, this is my first question in stack overflow.
Regards