import asyncio from pyrogram import filters, Client from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram.errors import FloodWait from helper.helper_func import encode #===============================================================# @Client.on_message(filters.private & ~filters.command(["start", "help", "cc", "settings", "stats", "users", "broadcast", "pbroadcast", "batch", "nbatch", "genlink", "bulk", "movie", "series", "done", "cancel", "db", "adddb", "removedb", "add_db_channel", "rm_db_channel", "set_primary_db", "toggle_db_status", "ban", "unban", "addpremium", "delpremium", "premiumusers", "img", "tgt", "telegraph"]) & (filters.document | filters.video | filters.audio | filters.photo)) async def channel_post(client: Client, message: Message): if message.from_user.id not in client.admins: return # Check if user is in an active ask state (custom guard to prevent double-post) if hasattr(client, "active_askers") and message.from_user.id in client.active_askers: return reply_text = await message.reply_text("Please Wait...!", quote = True) try: post_message = await message.copy(chat_id = client.db, disable_notification=True) except FloodWait as e: await asyncio.sleep(e.x) post_message = await message.copy(chat_id = client.db, disable_notification=True) except Exception as e: print(e) await reply_text.edit_text("Something went Wrong..!") return converted_id = post_message.id * abs(client.db) string = f"get-{converted_id}" base64_string = await encode(string) link = f"https://t.me/{client.username}?start={base64_string}" reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]]) await reply_text.edit(f"Here is your link\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True) if not client.disable_btn: await post_message.edit_reply_markup(reply_markup) #===============================================================# @Client.on_message(filters.channel & filters.incoming) async def new_post(client: Client, message: Message): if message.chat.id != client.db: return if client.disable_btn: return converted_id = message.id * abs(client.db) string = f"get-{converted_id}" base64_string = await encode(string) link = f"https://t.me/{client.username}?start={base64_string}" reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]]) try: await message.edit_reply_markup(reply_markup) except Exception as e: print(e) pass