from pyrogram import Client, filters from pyrogram.types import ( InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, KeyboardButton ) API_ID = 32346503 API_HASH = "391c63b5936e4e717fc7fa19221651de" BOT_TOKEN = "8966602774:AAFDK_woLHYGpSPxKimun5WUlCwGwpTFFZM" app = Client("shakti_bot", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN) forward_button = ReplyKeyboardMarkup( [[KeyboardButton("šŸ“Ø Forward Message")]], resize_keyboard=True ) @app.on_message(filters.command("start")) async def start(client, message): user_id = message.from_user.id text = f"""Hi Welcome To @User1nfo_bot šŸ‘‹ šŸ“š Help : /help šŸ”” Channel : @iesrl Your ID : {user_id}""" buttons = InlineKeyboardMarkup([ [InlineKeyboardButton(f"šŸ“‹ Copy {user_id}", callback_data=f"copy_{user_id}")], [InlineKeyboardButton("šŸš€ Share ID", switch_inline_query=str(user_id))] ]) await message.reply_text(text, reply_markup=buttons) await message.reply_text("Tap below button to forward any message:", reply_markup=forward_button) @app.on_message(filters.command("help")) async def help_cmd(client, message): await message.reply_text( """šŸ“š HOW TO USE 1ļøāƒ£ Tap "Forward Message" button 2ļøāƒ£ Forward any message from any user/chat 3ļøāƒ£ Bot will show original sender's ID šŸ”ø Channel : @iesrl šŸ”ø Developer : @dmForbans""" ) @app.on_message(filters.command("info") & filters.group) async def info_cmd(client, message): # Case 1: with username if len(message.text.split()) > 1: username = message.text.split(" ", 1)[1] if username.startswith("@"): username = username[1:] try: user = await client.get_users(username) user_link = f"https://t.me/{user.username}" if user.username else f"tg://user?id={user.id}" text = f"""šŸ‘¤ User Info ID: {user.id} First Name: {user.first_name or '.'} Last Name: {user.last_name or ''} Username: @{user.username or 'None'} šŸ”— User Link: [link]({user_link})""" await message.reply_text(text, disable_web_page_preview=False) # No parse_mode return except Exception as e: await message.reply_text(f"āŒ User not found. Error: {str(e)}") return # Case 2: own info user = message.from_user user_link = f"https://t.me/{user.username}" if user.username else f"tg://user?id={user.id}" text = f"""šŸ‘¤ š™š™Øš™šš™§ š™„š™£š™›š™¤ š™„š˜æ: {user.id} š™š™žš™§š™Øš™© š™‰š™–š™¢š™š: {user.first_name or '.'} š™‡š™–š™Øš™© š™‰š™–š™¢š™š: {user.last_name or ''} š™š™Øš™šš™§š™£š™–š™¢š™š: @{user.username or 'None'} šŸ”— User Link: [link]({user_link})""" await message.reply_text(text, disable_web_page_preview=False) # Forward handling (same as before) @app.on_message(filters.text & filters.regex("šŸ“Ø Forward Message")) async def forward_instruction(client, message): await message.reply_text( "šŸ”„ Now forward any message to me\n\n" "Go to any chat → Press & hold a message → Forward → Select me" ) @app.on_message(filters.forwarded) async def get_user_id(client, message): try: if message.forward_from: user = message.forward_from text = f"""šŸ”ø Forward detected! User š™„š˜æ: {user.id} š™‰š™–š™¢š™š: {user.first_name or '.'} {user.last_name or ''} š™š™Øš™šš™§š™£š™–š™¢š™š: @{user.username if user.username else 'None'}""" buttons = InlineKeyboardMarkup([ [InlineKeyboardButton(f"šŸ“‹ Copy {user.id}", callback_data=f"copy_{user.id}")], [InlineKeyboardButton("šŸš€ Share ID", switch_inline_query=str(user.id))] ]) await message.reply_text(text, reply_markup=buttons) elif message.forward_from_chat: chat = message.forward_from_chat text = f"""šŸ”ø Forward detected! šŸ“¢ Chat/Channel šŸ†” ID: {chat.id} šŸ“ Title: {chat.title} šŸ”— Username: @{chat.username if chat.username else 'None'}""" buttons = InlineKeyboardMarkup([ [InlineKeyboardButton(f"šŸ“‹ Copy {chat.id}", callback_data=f"copy_{chat.id}")], [InlineKeyboardButton("šŸš€ Share ID", switch_inline_query=str(chat.id))] ]) await message.reply_text(text, reply_markup=buttons) except Exception as e: await message.reply_text(f"āŒ Error: {str(e)}") @app.on_callback_query() async def handle_callback(client, callback_query): if callback_query.data.startswith("copy_"): user_id = callback_query.data.replace("copy_", "") await callback_query.answer(f"Copied: {user_id}", show_alert=True) await callback_query.message.edit_text( callback_query.message.text + f"\n\nāœ… Copied: {user_id}" ) if __name__ == "__main__": print("āœ… Bot Started Successfully!") app.run()