From d8587419e126d438517f49561070ac857584f2f6 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sat, 4 Nov 2017 15:09:29 +0200 Subject: [PATCH] Fixed bug when message has next step handler and exec command handlers. --- telebot/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index c2ce45c..44dd27b 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1259,10 +1259,13 @@ class TeleBot: def _notify_command_handlers(self, handlers, new_messages): for message in new_messages: - for message_handler in handlers: - if self._test_message_handler(message_handler, message): - self._exec_task(message_handler['function'], message) - break + # if message has next step handler, dont exec command handlers + if (isinstance(message, types.CallbackQuery)) or \ + (isinstance(message, types.Message) and (message.chat.id not in self.message_subscribers_next_step)): + for message_handler in handlers: + if self._test_message_handler(message_handler, message): + self._exec_task(message_handler['function'], message) + break class AsyncTeleBot(TeleBot):