Class Router⚓︎
Here is the reference information for the Router class, including all its parameters, attributes, and methods.
You can import the Router class directly from the trueconf package:
trueconf.Router ⚓︎
Event router for handling incoming events in a structured and extensible way.
A Router allows you to register event handlers with specific filters, such as message types, chat events, or custom logic.
You can also include nested routers using include_router() to build modular and reusable event structures.
Handlers can be registered for:
- Messages (
@<router>.message(...)) - Chat creation events (
@<router>.created_personal_chat(),@<router>.created_group_chat(),@<router>.created_channel()) - Participant events (
@<router>.added_chat_participant(),@<router>.removed_chat_participant()) - Message lifecycle events (
@<router>.edited_message(),@<router>.removed_message()) - File upload events (
@<router>.uploading_progress()) - Removed chats (
@<router>.removed_chat())
Example:
router = Router()
@router.message(F.text == "hello")
async def handle_hello(msg: Message):
await msg.answer("Hi there!")
If you have multiple routers, use .include_router() to add them to a parent router.
added_chat_participant ⚓︎
Register a handler when a participant is added to a chat.
created_group_chat ⚓︎
Register a handler for group chat creation events.
created_personal_chat ⚓︎
Register a handler for personal chat creation events.
event ⚓︎
removed_chat_participant ⚓︎
Register a handler when a participant is removed from a chat.
uploading_progress ⚓︎
Register a handler for file uploading progress events.