| 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): |
| |
| 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) |
| return |
| except Exception as e: |
| await message.reply_text(f"β User not found. Error: {str(e)}") |
| return |
|
|
| |
| 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) |
|
|
| |
| @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() |