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

Merge pull request #1742 from byehack/ContinueHandling

Support ContinueHandling
This commit is contained in:
Badiboy
2022-10-11 19:03:44 +03:00
committed by GitHub
6 changed files with 185 additions and 89 deletions

View File

@@ -14,7 +14,7 @@ import telebot.types
# storages
from telebot.asyncio_storage import StateMemoryStorage, StatePickleStorage, StateStorageBase
from telebot.asyncio_handler_backends import BaseMiddleware, CancelUpdate, SkipHandler, State
from telebot.asyncio_handler_backends import BaseMiddleware, CancelUpdate, SkipHandler, State, ContinueHandling
from inspect import signature
@@ -497,16 +497,14 @@ class AsyncTeleBot:
if not process_update: continue
for i in signature(handler['function']).parameters:
params.append(i)
result = None
if len(params) == 1:
await handler['function'](message)
break
result = await handler['function'](message)
elif "data" in params:
if len(params) == 2:
await handler['function'](message, data)
break
result = await handler['function'](message, data)
elif len(params) == 3:
await handler['function'](message, data=data, bot=self)
break
result = await 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
@@ -521,7 +519,8 @@ class AsyncTeleBot:
if len(data_copy) > len(params) - 1: # remove the message parameter
logger.error("You are passing more data than the handler needs. Check your handler: {}".format(handler['function']))
return
await handler["function"](message, **data_copy)
result = await handler["function"](message, **data_copy)
if not isinstance(result, ContinueHandling):
break
except Exception as e:
if self.exception_handler: