From ab2dca8d03abb2f6f5901a99c00dccc38935191e Mon Sep 17 00:00:00 2001 From: _run Date: Sat, 22 Jun 2024 18:01:36 +0500 Subject: [PATCH] Add pass_bot to register_business_message (#2316) * Fix pass_bot in business message handler register --- telebot/__init__.py | 7 ++++++- telebot/async_telebot.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 4100e26a0..d2bcdc307 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -8336,6 +8336,7 @@ def register_business_message_handler(self, regexp: Optional[str]=None, func: Optional[Callable]=None, content_types: Optional[List[str]]=None, + pass_bot: Optional[bool]=False, **kwargs): """ Registers business connection handler. @@ -8355,11 +8356,15 @@ def register_business_message_handler(self, :param content_types: Supported message content types. Must be a list. Defaults to ['text']. :type content_types: :obj:`list` of :obj:`str` + :param pass_bot: True, if bot instance should be passed to handler + :type pass_bot: :obj:`bool` + :param kwargs: Optional keyword arguments(custom filters) :return: None """ - handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, **kwargs) + handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, + pass_bot=pass_bot, **kwargs) self.add_business_message_handler(handler_dict) diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 2a338722a..224856416 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -2355,6 +2355,7 @@ def register_business_message_handler(self, regexp: Optional[str]=None, func: Optional[Callable]=None, content_types: Optional[List[str]]=None, + pass_bot: Optional[bool]=False, **kwargs): """ Registers business connection handler. @@ -2374,11 +2375,15 @@ def register_business_message_handler(self, :param content_types: Supported message content types. Must be a list. Defaults to ['text']. :type content_types: :obj:`list` of :obj:`str` + :param pass_bot: True, if bot instance should be passed to handler + :type pass_bot: :obj:`bool` + :param kwargs: Optional keyword arguments(custom filters) :return: None """ - handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, **kwargs) + handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, + pass_bot=pass_bot,**kwargs) self.add_business_message_handler(handler_dict)