#(Â©)Codexbotz

from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from bot import Bot
from config import ADMINS
from helper_func import encode, get_message_id

@Bot.on_message(filters.private & filters.user(ADMINS) & filters.command('batch'))
async def batch(client: Client, message: Message):
    while True:
        try:
            first_message = await client.ask(text = "<b>ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ ğ�šƒğ�™·ğ�™´ ğ�™µğ�™¸ğ�š�ğ�š‚ğ�šƒ ğ�™¼ğ�™´ğ�š‚ğ�š‚ğ�™°ğ�™¶ğ�™´ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�šƒğ�™·ğ�™´ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™» (ğ�š†ğ�™¸ğ�šƒğ�™· ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ ğ�š€ğ�™¾ğ�š„ğ�šƒğ�™´)....\n\nğ�™¾ğ�š�\n\nğ�š‚ğ�™´ğ�™½ğ�™³ ğ�šƒğ�™·ğ�™´ ğ�™¿ğ�™¾ğ�š‚ğ�šƒ ğ�™»ğ�™¸ğ�™½ğ�™º</b>", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
        except:
            return
        f_msg_id = await get_message_id(client, first_message)
        if f_msg_id:
            break
        else:
            await first_message.reply("<b>ğŸš« ğ�™´ğ�š�ğ�š�ğ�™¾ğ�š�\n\nğ�šƒğ�™·ğ�™¸ğ�š‚ ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ğ�™´ğ�™³ ğ�™¿ğ�™¾ğ�š‚ğ�šƒ ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™¼ğ�šˆ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™» ğ�™¾ğ�š� ğ�™»ğ�™¸ğ�™½ğ�™º ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�šƒğ�™°ğ�™ºğ�™´ğ�™½ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™»...</b>", quote = True)
            continue

    while True:
        try:
            second_message = await client.ask(text = "<b>ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ ğ�šƒğ�™·ğ�™´ ğ�™»ğ�™°ğ�š‚ğ�šƒ ğ�™¼ğ�™´ğ�š‚ğ�š‚ğ�™°ğ�™¶ğ�™´ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�šƒğ�™·ğ�™´ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™» (ğ�š†ğ�™¸ğ�šƒğ�™· ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ ğ�š€ğ�™¾ğ�š„ğ�šƒğ�™´)....\n\nğ�™¾ğ�š�\n\nğ�š‚ğ�™´ğ�™½ğ�™³ ğ�šƒğ�™·ğ�™´ ğ�™¿ğ�™¾ğ�š‚ğ�šƒ ğ�™»ğ�™¸ğ�™½ğ�™º</b>", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
        except:
            return
        s_msg_id = await get_message_id(client, second_message)
        if s_msg_id:
            break
        else:
            await second_message.reply("<b>ğŸš« ğ�™´ğ�š›ğ�š›ğ�š˜ğ�š›\n\nğ�šƒğ�™·ğ�™¸ğ�š‚ ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ğ�™´ğ�™³ ğ�™¿ğ�™¾ğ�š‚ğ�šƒ ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™¼ğ�šˆ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™» ğ�™¾ğ�š� ğ�™»ğ�™¸ğ�™½ğ�™º ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�šƒğ�™°ğ�™ºğ�™´ğ�™½ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™»...</b>", quote = True)
            continue


    string = f"get-{f_msg_id * abs(client.db_channel.id)}-{s_msg_id * abs(client.db_channel.id)}"
    base64_string = await encode(string)
    link = f"https://t.me/{client.username}?start={base64_string}"
    reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("ğ�š‚ğ�™·ğ�™°ğ�š�ğ�™´ ğ�š„ğ�š�ğ�™»", url=f'https://telegram.me/share/url?url={link}')]])
    await second_message.reply_text(f"<b>ğ�™·ğ�™´ğ�š�ğ�™´ ğ�™¸ğ�š‚ ğ�šˆğ�™¾ğ�š„ğ�š� ğ�™»ğ�™¸ğ�™½ğ�™º</b>\n\n{link}", quote=True, reply_markup=reply_markup)


@Bot.on_message(filters.private & filters.user(ADMINS) & filters.command('genlink'))
async def link_generator(client: Client, message: Message):
    while True:
        try:
            channel_message = await client.ask(text = "Forward Message from the DB Channel (with Quotes)..\nor Send the DB Channel Post link", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
        except:
            return
        msg_id = await get_message_id(client, channel_message)
        if msg_id:
            break
        else:
            await channel_message.reply("<b>ğŸš« ğ�™´ğ�š›ğ�š›ğ�š˜ğ�š›\n\nğ�šƒğ�™·ğ�™¸ğ�š‚ ğ�™µğ�™¾ğ�š�ğ�š†ğ�™°ğ�š�ğ�™³ğ�™´ğ�™³ ğ�™¿ğ�™¾ğ�š‚ğ�šƒ ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™¼ğ�šˆ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™» ğ�™¾ğ�š� ğ�™»ğ�™¸ğ�™½ğ�™º ğ�™¸ğ�š‚ ğ�™½ğ�™¾ğ�šƒ ğ�šƒğ�™°ğ�™ºğ�™´ğ�™½ ğ�™µğ�š�ğ�™¾ğ�™¼ ğ�™³ğ�™± ğ�™²ğ�™·ğ�™°ğ�™½ğ�™½ğ�™´ğ�™»...</b>", quote = True)
            continue

    base64_string = await encode(f"get-{msg_id * abs(client.db_channel.id)}")
    link = f"https://t.me/{client.username}?start={base64_string}"
    reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("ğ�š‚ğ�™·ğ�™°ğ�š�ğ�™´ ğ�š„ğ�š�ğ�™»", url=f'https://telegram.me/share/url?url={link}')]])
    await channel_message.reply_text(f"<b>ğ�™·ğ�™´ğ�š�ğ�™´ ğ�™¸ğ�š‚ ğ�šˆğ�™¾ğ�š„ğ�š� ğ�™»ğ�™¸ğ�™½ğ�™º</b>\n\n{link}", quote=True, reply_markup=reply_markup)
