From 15d287919d62b25bbe41ca00ef8ac20075636006 Mon Sep 17 00:00:00 2001 From: mostafaqanbaryan <30743448+mostafaqanbaryan@users.noreply.github.com> Date: Mon, 21 Aug 2017 14:40:47 +0430 Subject: [PATCH] Update __init__.py Add clear_step_handler() for resetting bot --- telebot/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telebot/__init__.py b/telebot/__init__.py index 671f103..c08df68 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -998,6 +998,15 @@ class TeleBot: self.pre_message_subscribers_next_step[chat_id].append(callback) else: self.pre_message_subscribers_next_step[chat_id] = [callback] + + def clear_step_handler(self, message): + """ + Clears all callback functions registered by register_next_step_handler(). + + :param message: The message for which we want to handle new message after that in same chat. + """ + chat_id = message.chat.id + self.pre_message_subscribers_next_step[chat_id] = [] def _notify_message_next_handler(self, new_messages): for message in new_messages: