1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Update __init__.py

This commit is contained in:
_run 2022-07-16 20:09:52 +05:00
parent ea1efad1ea
commit 22beead3b5

View File

@ -2971,13 +2971,13 @@ class TeleBot:
def setup_middleware(self, middleware: BaseMiddleware):
"""
Register middleware
Registers class-based middleware.
:param middleware: Subclass of `telebot.handler_backends.BaseMiddleware`
:return: None
"""
if not self.use_class_middlewares:
logger.warning('Middleware is not enabled. Pass use_class_middlewares=True to enable it.')
logger.warning('Class-based middlewares are not enabled. Pass use_class_middlewares=True to enable it.')
return
self.middlewares.append(middleware)
@ -3130,7 +3130,7 @@ class TeleBot:
def middleware_handler(self, update_types=None):
"""
Middleware handler decorator.
Function-based middleware handler decorator.
This decorator can be used to decorate functions that must be handled as middlewares before entering any other
message handlers
@ -3187,10 +3187,9 @@ class TeleBot:
# function register_middleware_handler
def register_middleware_handler(self, callback, update_types=None):
"""
Middleware handler decorator.
Adds function-based middleware handler.
This function will create a decorator that can be used to decorate functions that must be handled as middlewares before entering any other
message handlers
This function will register your decorator function. Function-based middlewares are executed before handlers.
But, be careful and check type of the update inside the handler if more than one update_type is given
Example:
@ -4100,6 +4099,7 @@ class TeleBot:
self.exception_handler.handle(e)
else: logging.error(str(e))
if middlewares:
for middleware in middlewares:
middleware.post_process(message, data, handler_error)