Files
ltlnotifyer/telegram/commands/__init__.py
2022-08-23 00:42:30 +03:00

27 lines
574 B
Python

from dataclasses import dataclass
import typing
from aiogram import Dispatcher
from .test import telegram_test
@dataclass
class Handler:
"""
Dataclass of handlers with help string.
"""
function: typing.Callable
help_string: str
handlers: dict[str, Handler] = {
'test': Handler(telegram_test, 'Отвечает "passed"')
}
def register_handlers(dispatcher: Dispatcher):
for command, handler in handlers.items():
dispatcher.register_message_handler(handler.function,
commands=[command])