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

Support ContinueHandling

This commit is contained in:
byehack
2022-10-02 03:27:06 +03:30
committed by GitHub
parent 82ad37fed8
commit 30aaf8d0f1
3 changed files with 24 additions and 22 deletions

View File

@@ -37,7 +37,10 @@ logger.addHandler(console_output_handler)
logger.setLevel(logging.ERROR)
from telebot import apihelper, util, types
from telebot.handler_backends import HandlerBackend, MemoryHandlerBackend, FileHandlerBackend, BaseMiddleware, CancelUpdate, SkipHandler, State
from telebot.handler_backends import (
HandlerBackend, MemoryHandlerBackend, FileHandlerBackend, BaseMiddleware,
CancelUpdate, SkipHandler, State, ContinueHandling
)
from telebot.custom_filters import SimpleCustomFilter, AdvancedCustomFilter
@@ -6111,13 +6114,14 @@ class TeleBot:
if not process_handler: continue
for i in inspect.signature(handler['function']).parameters:
params.append(i)
result = None
if len(params) == 1:
handler['function'](message)
result = handler['function'](message)
elif "data" in params:
if len(params) == 2:
handler['function'](message, data)
result = handler['function'](message, data)
elif len(params) == 3:
handler['function'](message, data=data, bot=self)
result = handler['function'](message, data=data, bot=self)
else:
logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function']))
return
@@ -6132,8 +6136,9 @@ class TeleBot:
if len(data_copy) > len(params) - 1: # remove the message parameter
logger.error("You are passing more parameters than the handler needs. Check your handler: {}".format(handler['function']))
return
handler["function"](message, **data_copy)
break
result = handler["function"](message, **data_copy)
if not isinstance(result, ContinueHandling):
break
except Exception as e:
handler_error = e
if self.exception_handler: