File size: 1,069 Bytes
0952241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# PATH: bot/handlers.py
from hydrogram import Client, filters
from hydrogram.types import Message
from bot.config import Telegram

def setup_handlers(app: Client) -> None:
    @app.on_message(filters.command(["start"]))
    async def start_handler(_: Client, m: Message):
        await m.reply_text(
            "✅ Online.\n"
            "Commands:\n"
            "/ping\n"
            "/me\n"
        )

    @app.on_message(filters.command(["ping"]))
    async def ping_handler(_: Client, m: Message):
        await m.reply_text("🏓 Pong!")

    @app.on_message(filters.command(["me"]))
    async def me_handler(_: Client, m: Message):
        uid = m.from_user.id if m.from_user else None
        await m.reply_text(f"👤 Your ID: `{uid}`", quote=True)

    @app.on_message(filters.private & filters.text & ~filters.command(["start", "ping", "me"]))
    async def echo_handler(_: Client, m: Message):
        # Normal simple reply bot
        txt = (m.text or "").strip()
        if not txt:
            return
        await m.reply_text(f"🗣 You said: {txt}")