-
Notifications
You must be signed in to change notification settings - Fork 1
Handlers
Maksym Zavalniuk edited this page Sep 7, 2023
·
1 revision
- Create a file in the
handlers
folder. - Import the dp from the loader.py and create your own router:
router = Router()
dp.include_router(router)
@router.message(CommandStart())
async def command_start_handler(message: Message) -> None:
await message.answer(f"Hello, {hbold(message.from_user.full_name)}!")
@router.message()
async def echo_handler(message: Message, config: Settings) -> None:
try:
print(config)
await message.send_copy(chat_id=message.chat.id)
except TypeError:
await message.answer("Nice try!")
- Add import in the
handlers/__init__.py
file:
from . import admin, echo # noqa