from hydrogram import filters from hydrogram.types import Message from bot import TelegramBot from bot.config import Telegram def is_allowed(uid: int) -> bool: if Telegram.OWNER_ID and uid == Telegram.OWNER_ID: return True return uid in Telegram.ALLOWED_USER_IDS @TelegramBot.on_message(filters.command("start")) async def start_handler(_, m: Message): uid = m.from_user.id if m.from_user else 0 if not is_allowed(uid): return await m.reply_text("❌ Not allowed. Contact owner.") await m.reply_text( "✅ Bot live.\n" "Commands:\n" "/ping\n" "/id\n" "/help\n\n" "Ab normal msg bhejo, main reply dunga." ) @TelegramBot.on_message(filters.command("help")) async def help_handler(_, m: Message): uid = m.from_user.id if m.from_user else 0 if not is_allowed(uid): return await m.reply_text("❌ Not allowed.") await m.reply_text( "✅ Help\n" "/ping -> pong\n" "/id -> your telegram id\n" "Send any text -> echo + small talk reply" ) @TelegramBot.on_message(filters.command("ping")) async def ping_handler(_, m: Message): uid = m.from_user.id if m.from_user else 0 if not is_allowed(uid): return await m.reply_text("❌ Not allowed.") await m.reply_text("pong ✅") @TelegramBot.on_message(filters.command("id")) async def id_handler(_, m: Message): uid = m.from_user.id if m.from_user else 0 await m.reply_text(f"Your ID: `{uid}`") @TelegramBot.on_message(filters.text & ~filters.command(["start","help","ping","id"])) async def talk_handler(_, m: Message): uid = m.from_user.id if m.from_user else 0 if not is_allowed(uid): return await m.reply_text("❌ Not allowed.") text = (m.text or "").strip() if not text: return # ultra-simple “talking” logic (safe, fast) low = text.lower() if any(x in low for x in ["hi", "hello", "hey"]): return await m.reply_text("Haan bol 😄") if "kaisa" in low or "kaisi" in low: return await m.reply_text("Mast. Tu bata 😄") if "bye" in low: return await m.reply_text("Bye 👋") # default echo-style reply await m.reply_text(f"🗣️ You said: {text}")