Moved handlers to telegram/commands package
This commit is contained in:
24
telegram/commands/__init__.py
Normal file
24
telegram/commands/__init__.py
Normal 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])
|
||||
Reference in New Issue
Block a user