27 lines
574 B
Python
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])
|