ukinti/garnet

Todos

Opened this issue · 0 comments

uwinx commented

todo!

  1. Optimize Filter instances as they're something that gets created a lot in code. Possibly make filters immutable.
class Filter(NamedTuple): pass
or, simpler:
Filter = dataclass(frozen=True)(Filter)

States are just a type of filters.

  1. Smartish code pattern generation based on given states group definition.

no examples.

  1. Nicer way to connect existing handlers to interoperate in the cases like:
# mod1.py
baker: QueryBaker = ...

handler(...): mod2.baker.get_checked(...)

# mod2.py
baker: QueryBaker = ...

handler(...): mod1.baker.get_checked(...)
  1. Introduce gettext and I18N data to users.

  2. [long-term] make garnet a frontend to any telethon-like library and not just telethon.

  3. Filter pipelines and stacks:

from garnet.filters import Pipeline, Stack

pp = Pipeline(user_exists, in_entry_state, is_allowed_cmd)

@router.message(pp.pop(1))   # will compose Stack().include (user_exists, is_allowed_cmd)
async def _(_): ...


stack = Stack(user_exists, in_entry_state, is_allowed_cmd)

@router.message(stack.include(0, 1))  # will drop is_allowed_cmd
async def _(_): ...