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:
parent
ea1efad1ea
commit
22beead3b5
@ -2971,13 +2971,13 @@ class TeleBot:
|
|||||||
|
|
||||||
def setup_middleware(self, middleware: BaseMiddleware):
|
def setup_middleware(self, middleware: BaseMiddleware):
|
||||||
"""
|
"""
|
||||||
Register middleware
|
Registers class-based middleware.
|
||||||
|
|
||||||
:param middleware: Subclass of `telebot.handler_backends.BaseMiddleware`
|
:param middleware: Subclass of `telebot.handler_backends.BaseMiddleware`
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if not self.use_class_middlewares:
|
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
|
return
|
||||||
self.middlewares.append(middleware)
|
self.middlewares.append(middleware)
|
||||||
|
|
||||||
@ -3130,7 +3130,7 @@ class TeleBot:
|
|||||||
|
|
||||||
def middleware_handler(self, update_types=None):
|
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
|
This decorator can be used to decorate functions that must be handled as middlewares before entering any other
|
||||||
message handlers
|
message handlers
|
||||||
@ -3187,10 +3187,9 @@ class TeleBot:
|
|||||||
# function register_middleware_handler
|
# function register_middleware_handler
|
||||||
def register_middleware_handler(self, callback, update_types=None):
|
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
|
This function will register your decorator function. Function-based middlewares are executed before handlers.
|
||||||
message handlers
|
|
||||||
But, be careful and check type of the update inside the handler if more than one update_type is given
|
But, be careful and check type of the update inside the handler if more than one update_type is given
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
@ -4099,6 +4098,7 @@ class TeleBot:
|
|||||||
if self.exception_handler:
|
if self.exception_handler:
|
||||||
self.exception_handler.handle(e)
|
self.exception_handler.handle(e)
|
||||||
else: logging.error(str(e))
|
else: logging.error(str(e))
|
||||||
|
|
||||||
|
|
||||||
if middlewares:
|
if middlewares:
|
||||||
for middleware in middlewares:
|
for middleware in middlewares:
|
||||||
|
Loading…
Reference in New Issue
Block a user