From 86c9ba3107dbab3b9203daf180a5df651d0c64a9 Mon Sep 17 00:00:00 2001 From: sdmway Date: Sat, 11 May 2024 11:41:45 -0600 Subject: [PATCH] misc: removed routers example --- examples/echo_bot.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/echo_bot.py b/examples/echo_bot.py index 101588c2..6a720ddb 100644 --- a/examples/echo_bot.py +++ b/examples/echo_bot.py @@ -3,7 +3,7 @@ import logging import sys from os import getenv -from aiogram import Bot, Dispatcher, Router, html +from aiogram import Bot, Dispatcher, html from aiogram.client.default import DefaultBotProperties from aiogram.enums import ParseMode from aiogram.filters import CommandStart @@ -14,10 +14,10 @@ TOKEN = getenv("BOT_TOKEN") # All handlers should be attached to the Router (or Dispatcher) -echo_router = Router() +dp = Dispatcher() -@echo_router.message(CommandStart()) +@dp.message(CommandStart()) async def command_start_handler(message: Message) -> None: """ This handler receives messages with `/start` command @@ -30,7 +30,7 @@ async def command_start_handler(message: Message) -> None: await message.answer(f"Hello, {html.bold(message.from_user.full_name)}!") -@echo_router.message() +@dp.message() async def echo_handler(message: Message) -> None: """ Handler will forward receive a message back to the sender @@ -49,10 +49,6 @@ async def main() -> None: # Initialize Bot instance with default bot properties which will be passed to all API calls bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) - dp = Dispatcher() - - dp.include_router(echo_router) - # And the run events dispatching await dp.start_polling(bot)