BasicHfBot / bot /handlers.py
understanding's picture
Create handlers.py
0952241 verified
# 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}")