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

States Update

This commit is contained in:
_run
2022-01-24 21:24:56 +04:00
parent 124b07ee44
commit 8045ad56ea
5 changed files with 101 additions and 38 deletions

View File

@@ -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))