Moved handlers to telegram/commands package

This commit is contained in:
Alexey Sokolov
2022-08-12 02:00:59 +03:00
parent d1425aaa8e
commit 043584c730
4 changed files with 31 additions and 13 deletions

View File

@@ -0,0 +1,24 @@
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, commands=[command])