mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
States Update
This commit is contained in:
@ -364,12 +364,13 @@ class AsyncTeleBot:
|
||||
handler_error = None
|
||||
data = {}
|
||||
process_handler = True
|
||||
middleware_result = await middleware.pre_process(message, data)
|
||||
if isinstance(middleware_result, SkipHandler):
|
||||
await middleware.post_process(message, data, handler_error)
|
||||
process_handler = False
|
||||
if isinstance(middleware_result, CancelUpdate):
|
||||
return
|
||||
if middleware:
|
||||
middleware_result = await middleware.pre_process(message, data)
|
||||
if isinstance(middleware_result, SkipHandler):
|
||||
await middleware.post_process(message, data, handler_error)
|
||||
process_handler = False
|
||||
if isinstance(middleware_result, CancelUpdate):
|
||||
return
|
||||
for handler in handlers:
|
||||
if not process_handler:
|
||||
break
|
||||
@ -2481,8 +2482,8 @@ class AsyncTeleBot:
|
||||
"""
|
||||
return await asyncio_helper.delete_chat_photo(self.token, chat_id)
|
||||
|
||||
async def get_my_commands(self, scope: Optional[types.BotCommandScope]=None,
|
||||
language_code: Optional[str]=None) -> List[types.BotCommand]:
|
||||
async def get_my_commands(self, scope: Optional[types.BotCommandScope],
|
||||
language_code: Optional[str]) -> List[types.BotCommand]:
|
||||
"""
|
||||
Use this method to get the current list of the bot's commands.
|
||||
Returns List of BotCommand on success.
|
||||
|
@ -17,3 +17,19 @@ class BaseMiddleware:
|
||||
async def post_process(self, message, data, exception):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class State:
|
||||
def __init__(self) -> None:
|
||||
self.name = None
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
|
||||
class StatesGroup:
|
||||
def __init_subclass__(cls) -> None:
|
||||
# print all variables of a subclass
|
||||
for name, value in cls.__dict__.items():
|
||||
if not name.startswith('__') and not callable(value) and isinstance(value, State):
|
||||
# change value of that variable
|
||||
value.name = ':'.join((cls.__name__, name))
|
||||
|
||||
|
@ -148,4 +148,20 @@ class RedisHandlerBackend(HandlerBackend):
|
||||
self.clear_handlers(handler_group_id)
|
||||
return handlers
|
||||
|
||||
|
||||
class State:
|
||||
def __init__(self) -> None:
|
||||
self.name = None
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
|
||||
class StatesGroup:
|
||||
def __init_subclass__(cls) -> None:
|
||||
# print all variables of a subclass
|
||||
for name, value in cls.__dict__.items():
|
||||
if not name.startswith('__') and not callable(value) and isinstance(value, State):
|
||||
# change value of that variable
|
||||
value.name = ':'.join((cls.__name__, name))
|
||||
|
||||
|
Reference in New Issue
Block a user