Answer the question
In order to leave comments, you need to log in
Telebot module, timeout handler and binding to the user who started the dialogue with the bot?
Greetings to all, I am making a bot in python, with the telebot module, the question arose:
1. How to make the handler timeout, for example, the first command /k is given to the bot, the bot is waiting for input from the user to go to the next get_info ... function, I would like to enter waiting timeout in the region of 5 minutes, and then the handler would be reset, is it possible to do this?
2. How to bind to the user who entered the command. Now any user in the group can intercept the dialogue with the bot, so to speak... for example, I write the /k command, and the bot should only go further from me to perform the next function, I suspect that you need to bind to the uid = message.from_user.id parameter, but maybe there is another way?
@bot.message_handler(commands=['k'])
def start(message):
chat_id = message.chat.id
sent = bot.send_message(message.chat.id, 'Введите команду в формате /P21T0110 /Л11705054')
bot.register_next_step_handler(sent, get_info)
#INFO GET
def get_info(message):
#uid = message.from_user.id
text = message.text
bot.send_message(message.chat.id, 'Вы ввели команду : {0:}'.format(text))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question