22 lines
694 B
Python
22 lines
694 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from pyrogram import filters
|
|
from pyrogram.handlers import MessageHandler
|
|
|
|
from app.commands import CommandDispatcher
|
|
|
|
if TYPE_CHECKING:
|
|
from app.manager import AccountManager, AccountState
|
|
from pyrogram import Client
|
|
|
|
|
|
def register_common_handlers(client: "Client", manager: "AccountManager", account: "AccountState") -> None:
|
|
dispatcher = CommandDispatcher(manager.command_registry)
|
|
|
|
async def command_handler(client_: "Client", message) -> None:
|
|
await dispatcher.dispatch(client_, message, manager, account)
|
|
|
|
client.add_handler(MessageHandler(command_handler, filters.text | filters.caption))
|