mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 02:52:12 +00:00
* misc: code consistency and bot instance creation * Changelog for aiogram#1482 * misc: consistency of comments and dispatcher instance creation * misc: removed routers example * Update CHANGES/1482.misc.rst --------- Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
18 lines
785 B
Python
18 lines
785 B
Python
from aiogram import Router
|
|
from aiogram.filters import CommandStart
|
|
from aiogram.types import Message
|
|
|
|
start_router = Router()
|
|
|
|
|
|
@start_router.message(CommandStart())
|
|
async def command_start_handler(message: Message) -> None:
|
|
"""
|
|
This handler receives messages with `/start` command
|
|
"""
|
|
# Most event objects have aliases for API methods that can be called in events' context
|
|
# For example if you want to answer to incoming message you can use `message.answer(...)` alias
|
|
# and the target chat will be passed to :ref:`aiogram.methods.send_message.SendMessage`
|
|
# method automatically or call API method directly via
|
|
# Bot instance: `bot.send_message(chat_id=message.chat.id, ...)`
|
|
await message.answer(f"Hello, <b>{message.from_user.full_name}!</b>")
|