Spaces:
Runtime error
Runtime error
| 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 | |
| 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." | |
| ) | |
| 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" | |
| ) | |
| 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 β ") | |
| 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}`") | |
| 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}") |