improve code quality

This commit is contained in:
byehack 2022-10-02 12:05:20 +03:30 committed by GitHub
parent 30aaf8d0f1
commit 4798c26188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 70 deletions

View File

@ -6080,11 +6080,13 @@ class TeleBot:
for handler in handlers:
if self._test_message_handler(handler, message):
if handler.get('pass_bot', False):
handler['function'](message, bot = self)
result = handler['function'](message, bot=self)
else:
handler['function'](message)
result = handler['function'](message)
if not isinstance(result, ContinueHandling):
break
else:
return
data = {}
params =[]
handler_error = None
@ -6107,7 +6109,7 @@ class TeleBot:
elif isinstance(result, SkipHandler):
skip_handlers = True
if handlers and not(skip_handlers):
if handlers and not skip_handlers:
try:
for handler in handlers:
process_handler = self._test_message_handler(handler, message)

View File

@ -249,6 +249,8 @@ class SkipHandler:
Update will go to post_process,
but will skip execution of handler.
"""
def __init__(self) -> None:
pass
class CancelUpdate:
@ -259,6 +261,9 @@ class CancelUpdate:
Update will skip handler and execution
of post_process in middlewares.
"""
def __init__(self) -> None:
pass
class ContinueHandling:
"""
@ -266,3 +271,6 @@ class ContinueHandling:
Just return instance of this class
in handlers to continue process.
"""
def __init__(self) -> None:
pass