import re
import asyncio

from html import escape
from traceback import format_exc
from pyrogram.enums import ChatMemberStatus, MessageOriginType
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram.errors import ChatAdminRequired, ChannelPrivate

import app

from app.config import ADMINS
from app.handlers.buttons import Buttons


class MessageHandler:
    async def message_handler(self: "app.App", _, message: Message):
        user_id = message.from_user.id
        
        if self.setting.off and user_id not in ADMINS:
            return await message.reply(
                text="⭕️ ربات در حال حاضر خاموش است.",
                quote=True
            )
        
        elif await self.database.get_block(user_id):
            return await message.reply(
                text="🚫 شما از گسترده مسدود شده اید.",
                quote=True
            )
        
        get_user = await self.database.get_user(user_id=user_id)
        
        if not get_user:
            await self.database.add_user(user_id=user_id, start_date=self.timestamp, last_use=self.timestamp)
            get_user = await self.database.get_user(user_id=user_id)
        else:
            await self.database.update_user(get_user, last_use=self.timestamp)
        
        registered = True
        if not get_user.verify and not await self.is_admin(user_id):
            registered = False
            
            if message.text not in ["🧑🏻‍💻 پشتیبانی", "🐋 ثبت نام"] and (not get_user.step or get_user.step not in ["contact_us", "register"]):
                return await message.reply(
                    text=self.setting.register,
                    reply_markup=Buttons.register,
                    quote=True
                )
            
            if get_user.step and get_user.step not in ["contact_us", "register"]:
                await self.database.update_user(get_user, step=None)
                
        if not get_user.step:
            if message.text == "🧑🏻‍💻 پشتیبانی":
                await self.database.update_user(get_user, step="contact_us")
                await message.reply(
                    text='🧑🏻‍💻 پیام <b>پشتیبانی</b> خود را <b>ارسال</b> کنید تا ما در اسرع وقت به شما <b>پاسخ</b> دهیم.',
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif not registered and message.text == "🐋 ثبت نام":
                if get_user.verify:
                    return await message.reply(
                        text="✅ شما قبلاً ثبت نام کرده‌اید!\n\n"
                             "🔹 از امکانات ربات استفاده کنید.",
                        quote=True
                    )
                
                if await self.database.get_register(user_id=user_id):
                    return await message.reply(
                        text="⏳ درخواست ثبت نام شما در حال بررسی است.\n\n"
                             "📌 لطفاً صبور باشید تا ادمین درخواست شما را تایید کند.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step="register")
                await message.reply(
                    text="🐋 **ثبت نام در گسترده ویو**\n\n"
                         "━━━━━━━━━━━━━━━━━━━━━━\n\n"
                         "🔹 برای ثبت نام، ابتدا **حیطه کانال** خود را انتخاب کنید:\n\n"
                         "➿ **چنل وطنی** - کانال‌های فارسی زبان\n"
                         "➿ **چنل اونلی فنز** - کانال‌های ویژه\n"
                         "➿ **چنل اخلاقی** - کانال‌های اخلاقی\n"
                         "➿ **چنل زیرنویس** - کانال‌های زیرنویس فیلم\n\n"
                         "━━━━━━━━━━━━━━━━━━━━━━\n"
                         "🤖 پس از انتخاب، لینک کانال خود را ارسال کنید.",
                    reply_markup=Buttons.add_channel_type,
                    quote=True
                )
            
            elif message.text == "🔖 مدیریت کانال ها":
                await self.database.update_user(get_user, step="channels")
                await message.reply(
                    text='🔖 بخش مورد نظر خود را انتخاب کنید.',
                    reply_markup=Buttons.channels,
                    quote=True
                )
                
            elif message.text == "💲 امور مالی":
                await self.database.update_user(get_user, step="financial")
                await message.reply(
                    text='💲 بخش مورد نظر خود را انتخاب کنید.',
                    reply_markup=Buttons.financial,
                    quote=True
                )
                
            elif message.text == "👤 حساب کاربری":
                if not get_user.bank:
                    bank = "❌ ثبت نشده"
                else:
                    bank_structure = get_user.bank.splitlines()
                    bank = f"\n   │ 🏦 شبا: `{bank_structure[0]}`\n   │ 💳 کارت: `{bank_structure[1]}`\n   │ 👤 بنام: {bank_structure[2]}"
                
                if not get_user.wallet_trc20:
                    wallet_trc20 = "❌ ثبت نشده"
                else:
                    wallet_trc20 = f"`{get_user.wallet_trc20}`"
                
                if not get_user.wallet_ton:
                    wallet_ton = "❌ ثبت نشده"
                else:
                    wallet_ton = f"`{get_user.wallet_ton}`"
                
                not_done = 0
                total_seens = 0
                active_banners = 0
                
                async for seen in self.database.get_seens(user_id=user_id, status=0):
                    get_banner = await self.database.get_banner(tag=seen.banner_tag)
                    if not get_banner:
                        continue
                    not_done += round(((seen.all_count + seen.count) / 1000) * get_banner.s1000)
                    active_banners += 1
                    total_seens += seen.all_count + seen.count
                
                total_withdraw = await self.database.get_withdraw_histories_count(user_id=user_id)
                total_banners = await self.database.get_seens_count(user_id=user_id)
                total_all_seens = await self.database.get_all_seens_count(user_id=user_id)
                
                user_rank = await self.database.get_rank(None, user_id) or "—"
                
                last_withdraw_date = "—"
                async for withdraw in self.database.get_withdraw_histories(user_id=user_id):
                    last_withdraw_date = self.jalali_date(withdraw.date)
                    break
                
                last_active = self.jalali_date(get_user.last_use) if get_user.last_use else "—"
                
                if get_user.verify:
                    status_icon = "✅"
                    status_text = "تایید شده"
                else:
                    status_icon = "⏳"
                    status_text = "در انتظار تایید"
                
                channels_count = await self.database.get_channels_count(user_id=user_id, verify=True)
                pending_banners = await self.database.get_channel_requests_count(user_id=user_id)
                
                trx_balance = 0.0
                if hasattr(self, 'tron_price') and self.tron_price > 0:
                    trx_balance = round(get_user.current_balance / self.tron_price, 2)

                profile_keyboard = InlineKeyboardMarkup([
                    [
                        InlineKeyboardButton("🔄 بروزرسانی مشخصات", callback_data="profile_refresh")
                    ],
                    [
                        InlineKeyboardButton("💳 ثبت/ویرایش کارت", callback_data="edit_bank_card"),
                        InlineKeyboardButton("🌐 ثبت ولت TRC20 / TON", callback_data="edit_crypto_wallets")
                    ],
                    [
                        InlineKeyboardButton("📢 کانال‌های من", callback_data="my_channels"),
                        InlineKeyboardButton("🧾 تاریخچه تسویه‌ها", callback_data="payout_history")
                    ],
                    [
                        InlineKeyboardButton("🧑‍💻 ارتباط با پشتیبانی", callback_data="contact_support"),
                        InlineKeyboardButton("💎 تعرفه و قیمت هر سین", callback_data="view_rates")
                    ],
                    [
                        InlineKeyboardButton("🔙 بازگشت به منوی اصلی", callback_data="back_to_menu")
                    ]
                ])
                
                text = f"""
✨ <b>پروفایل کاربری شما در گسترده ویو</b> ✨

🆔 شناسه کاربر: <code>{user_id}</code>
🚦 وضعیت حساب: <b>{status_icon} {status_text}</b>
🏅 رتبه شما در گسترده: <b>#{user_rank}</b>
📅 تاریخ عضویت: <code>{self.jalali_date(get_user.start_date)}</code>
⏱ آخرین فعالیت: <code>{last_active}</code>
📅 آخرین برداشت: <code>{last_withdraw_date}</code>

💎 <b>وضعیت کیف پول مالی:</b>
 🟢 موجودی قابل برداشت: <b>{get_user.current_balance:,} تومان</b>
 🪙 معادل ترون: <code>{trx_balance:,} TRX</code>
 ⏳ درآمد در انتظار واریز: <b>{not_done:,} تومان</b>
 💸 کل مبالغ تسویه شده: <b>{get_user.all_balance - get_user.current_balance:,} تومان</b>

📊 <b>خلاصه عملکرد گسترده:</b>
 📢 تعداد کانال‌های فعال: <b>{channels_count} کانال</b>
 🎗 بنرهای در حال بازدیـد: <b>{active_banners} بنر</b>
 📈 مجموع کل سین‌های شما: <b>{total_all_seens:,} ویو</b>
 💰 میانگین درآمد روزانه شما: <b>{round((get_user.all_balance / ((self.timestamp - get_user.start_date) / 86400)) if (self.timestamp - get_user.start_date) > 0 else 0):,} تومان</b>

🔐 <b>حساب‌های مالی ثبت شده:</b>
 🌐 ولت TRC20: {wallet_trc20}
 💎 ولت TON: {wallet_ton}
 💳 حساب بانکی: {bank}

🤖 <i>@{self.client.me.username} • پلتفرم هوشمند مدیریت گسترده</i>
"""
                
                await message.reply(
                    text=text,
                    reply_markup=profile_keyboard,
                    disable_web_page_preview=True,
                    quote=True
                )
            
            elif message.text == "📊 نفرات برتر":
                rank = 0
                text = ""
                
                async for user_id, total_count in self.database.get_ranks():
                    rank += 1

                    if rank >= 10:
                        break
                    
                    try:
                        get_users = await self.client.get_users(user_id)
                        full_name = get_users.full_name
                    except:
                        full_name = user_id

                    text += f"""📈 رتبه: <b>{rank}</b>
👤 نام کاربر: <b>{full_name}</b>
➰ سین: <b>{total_count or 0:,}</b>\n\n"""
                
                await message.reply(
                    text=f'📊 ده نفر برتر گسترده به شرح زیر می باشد:\n\n{text}🤖 <b>@{self.client.me.username}</b>',
                    quote=True
                )
            
            elif message.text == "💡 بنر های فعال":
                if not await self.database.get_banners_count(status=0):
                    return await message.reply(
                        text="💡 درحال حاضر هیچ بنر فعالی موجود نمی باشد.",
                        quote=True
                    )
                    
                buttons = []
            
                async for banner in self.database.get_banners(status=0):
                    buttons.append(
                        [
                            InlineKeyboardButton(banner.banner_name, callback_data=f"banner|{banner.tag}|normal")
                        ]
                    )
            
                markup = InlineKeyboardMarkup(buttons)
            
                await message.reply(
                    text="💡 بنر های فعال به شرح زیر می باشد، برای دریافت یا مشاهده ی جزئیات روی آنها ضربه بزنید.",
                    reply_markup=markup,
                    quote=True
                )
                
            elif message.text == "🎗 بنر های من":
                if not await self.database.get_seens_count(user_id=user_id, status=0):
                    return await message.reply(
                        text="🎗 درحال حاضر شما هیچ بنر فعالی ندارید.",
                        quote=True
                    )
                    
                buttons = []
            
                async for seen in self.database.get_group_seens(user_id=user_id, status=0):
                    get_banner = await self.database.get_banner(tag=seen.banner_tag)
                    banner_name = get_banner.banner_name if get_banner else "بنر"

                    buttons.append(
                        [
                            InlineKeyboardButton(banner_name, callback_data=f"my_banner|{seen.tag}|normal")
                        ]
                    )
            
                markup = InlineKeyboardMarkup(buttons)
            
                await message.reply(
                    text="🎗 بنر های فعال شما به شرح زیر می باشد، جهت مشاهده ی هرکدام روی آن ضربه بزنید.",
                    reply_markup=markup,
                    quote=True
                )
                
            elif message.text.lower() == "/admin" and await self.is_admin(user_id):
                await self.database.update_user(get_user, step="admin")
                
                try:
                    admin_rights_val = await self.admin_rights(user_id)
                except Exception:
                    admin_rights_val = "all"
                
                await message.reply(
                    text="☁️ به پنل مدیریت خوش آمدید.",
                    reply_markup=Buttons.admin(user_id, admin_rights_val),
                    quote=True
                )
                return
    
            elif message.reply_to_message and message.reply_to_message.reply_markup and await self.is_admin(user_id, "support") and hasattr(message.reply_to_message.reply_markup, 'inline_keyboard'):
                get_arguments = message.reply_to_message.reply_markup.inline_keyboard[0][0].callback_data.split("|")
                
                if get_arguments[0] != "support":
                    return
            
                user_reply_id = int(get_arguments[1])
                
                try:
                    await self.client.send_message(
                        chat_id=user_reply_id,
                        text=f"🧑🏻‍💻 پشتیبانی:\n<b>{escape(message.text)}</b>"
                    )
                    await message.reply(
                        text="❕ پیام شما به کاربر ارسال شد.",
                        quote=True
                    )
                except:
                    await message.reply(
                        text="❕ پیام نتوانست به کاربر ارسال شود.",
                        quote=True
                    )
                    return
        else:
            get_arguments = get_user.step.split("|")
            
            if message.text == "🔙 بازگشت":
                if get_arguments[0] in ["send_all", "admins", "add_admin", "delete_admin", "starttext", "user_info", "banner_channel", "add_banner", "delete_banner", "admin_add_balance", "admin_message", "done_banner", "blocks", "add_block", "delete_block", "show_banner", "screenshot", "extract_users", "fire_users", "gifts"] and await self.is_admin(user_id):
                    await self.database.update_user(get_user, step="admin")
                    await message.reply(
                        text="☁️ به پنل مدیریت خوش آمدید.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                    
                elif get_arguments[0] == "add_reshot" and await self.is_admin(user_id, "banner"):
                    get_banner = await self.database.get_banner(tag=get_arguments[1], status=0)
                    
                    if not get_banner:
                        await self.database.update_user(get_user, step="admin")
                        return await message.reply(
                            text="📸 <b>بنر</b> برای <b>ریشات</b> وجود ندارد.",
                            reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                            quote=True
                        )
                        
                    buttons = []
                
                    async for schedule in self.database.get_schedules(banner_tag=get_banner.tag, status=0):
                        buttons.append(
                            [
                                InlineKeyboardButton(self.schedule_text(schedule.date, schedule.stype, True), callback_data=f"schedule|{schedule.tag}|normal")
                            ]
                        )
                
                    buttons.append(
                        [
                            InlineKeyboardButton("➕ اضافه کردن", callback_data=f"reshot|{get_banner.tag}|add")
                        ]
                    )
                
                    buttons.append(
                        [
                            InlineKeyboardButton("🔙 بازگشت", callback_data="reshots|normal")
                        ]
                    )

                    markup = InlineKeyboardMarkup(buttons)

                    await message.reply(
                        text=f"📸 <b>زمان ریشات</b> خود را برای بنر <b>{get_banner.banner_name}</b> انتخاب کنید یا <b>زمان جدیدی</b> اضافه کنید.",
                        reply_markup=markup,
                        quote=True
                    )

                elif get_arguments[0] == "edit_banner" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="show_banner")
                    await message.reply(
                        text="☁️ تگ بنر را برای پیگیری وارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif get_arguments[0] == "edit_banner_value" and await self.is_admin(user_id, "banner"):
                    get_banner = await self.database.get_banner(tag=get_arguments[1])
                    
                    if not get_banner:
                        await self.database.update_user(get_user, step="admin")
                        return await message.reply(
                            text="☁️ بنر اشتباه می باشد.",
                            reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                            quote=True
                        )
                        
                    elif get_banner.status != 0:
                        await self.database.update_user(get_user, step="admin")
                        return await message.reply(
                            text="☁️ این بنر حسابرسی شده است.",
                            reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                            quote=True
                        )
                        
                    if get_banner.banner_limit == 0:
                        banner_limit = "نامحدود"
                    else:
                        banner_limit = f"{get_banner.banner_limit:,}"
                    
                    get_seens = await self.database.get_all_seens_count(banner_tag=get_banner.tag)
                    
                    if get_banner.banner_end == 1:
                        banner_count = f"➿ ظرفیت: <b>{get_banner.count:,}</b>"
                        banner_left = f"<b>{get_banner.count - get_seens:,}</b>"
                    else:
                        banner_count = f"🕐 زمان: <b>{get_banner.count:,} روز</b>"
                        banner_left = f"<b>{(get_banner.count - (self.timestamp - get_banner.date) // 86400):,} روز</b>"
                    
                    if get_banner.banner_limit == 0 or await self.database.get_seens_count(banner_tag=get_banner.tag) < get_banner.banner_limit:
                        status = "✅"
                    else:
                        status = "❌"
                            
                    await self.database.update_user(get_user, step=f"edit_banner|{get_banner.tag}")
                    await message.reply(
                        text=f"""💡 مشخصات بنر به شرح زیر می باشد:

🕯 نام: <b>{escape(get_banner.banner_name)}</b>

🌀 محدودیت بنر: <b>{banner_limit}</b>
🔖 نوع کانال: <b>{' - '.join(list(map(lambda x: self.channel_type(x), self.decode(get_banner.channel_type))))}</b>

{banner_count}
✔️ سین کل: <b>{get_seens:,}</b>
〰️ باقی مانده: {banner_left}

💵 نرخ 1000 سین: <b>{get_banner.s1000:,} تومان</b>
💰 درآمد کل: <b>{round((get_seens / 1000) * get_banner.s1000):,} تومان</b>

⚜️ قابل دریافت: {status}
📆 تاریخ ساخت: <b>{self.jalali_date(get_banner.date)}</b>

〽️ توضیحات: <b>{get_banner.description}</b>""",
                        reply_markup=Buttons.edit_banner,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_name" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="add_banner")
                    await message.reply(
                        text="☁️ بنر خود را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_limit" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_name|{message.id}")
                    await message.reply(
                        text="☁️ نام بنر را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_end" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_limit|{get_arguments[1]}|{get_arguments[2]}")
                    await message.reply(
                        text="☁️ محدودیت بنر را ارسال کنید، در صورتی که میخواهید بدون محدودیت باشد عدد 0 را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_count" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_end|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}")
                    await message.reply(
                        text="☁️ پایان بنر را انتخاب کنید.",
                        reply_markup=Buttons.banner_end,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_1000" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_count|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}")
                    await message.reply(
                        text="☁️ ظرفیت بنر را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_channel_type" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_1000|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}")
                    await message.reply(
                        text="☁️ نرخ هر 1000 سین را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )

                elif get_arguments[0] == "banner_group_stats" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_channel_type|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|[]")
                    await message.reply(
                        text="☁️ نوع مجاز کانال را ارسال کنید.\n➿ کانال های مجاز: ()",
                        reply_markup=Buttons.channel_type,
                        quote=True
                    )
                    
                elif get_arguments[0] == "banner_description" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_group_stats|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}|{self.encode(channel_types)}")
                    await message.reply(
                        text="☁️ گروه آمار خود را به صورت آیدی عددی ارسال کنید و اگر به آن دسترسی ندارید یک پیام از گروه فوروارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )

                elif get_arguments[0] == "banner_confirm" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step=f"banner_description|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}")
                    await message.reply(
                        text="☁️ توضیحات بنر خود را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif get_arguments[0] in ["edit_card", "edit_wallet", "transfer", "transfer_count", "withdraw_type"]:
                    await self.database.update_user(get_user, step="financial")
                    await message.reply(
                        text='💲 بخش مورد نظر خود را انتخاب کنید.',
                        reply_markup=Buttons.financial,
                        quote=True
                    )
                    
                elif get_arguments[0] == "withdraw":
                    await self.database.update_user(get_user, step="withdraw_type")
                    await message.reply(
                        text='💳 روش برداشت خود را انتخاب کنید.',
                        reply_markup=Buttons.withdraw_type,
                        quote=True
                    )
                    
                elif get_arguments[0] == "add_channel":
                    await self.database.update_user(get_user, step="add_channel_type")
                    await message.reply(
                        text="➕ نوع کانال خود را انتخاب کنید.",
                        reply_markup=Buttons.add_channel_type,
                        quote=True
                    )
                    
                elif get_arguments[0] == "add_channel_type":
                    await self.database.update_user(get_user, step="channels")
                    await message.reply(
                        text='🔖 بخش مورد نظر خود را انتخاب کنید.',
                        reply_markup=Buttons.channels,
                        quote=True
                    )

                else:
                    home_button = Buttons.home if registered else Buttons.register
                    
                    await self.database.update_user(get_user, step=None)
                    await message.reply(
                        text="🔙 شما به صفحه ی اصلی بازگشتید.",
                        reply_markup=home_button,
                        quote=True
                    )
                        
            elif get_arguments[0] == "contact_us":
                markup = InlineKeyboardMarkup(
                    [
                        [
                            InlineKeyboardButton("ریپلی بزنید", callback_data=f"support|{user_id}")
                        ]
                    ]
                )
                
                username = f" - <b>@{message.from_user.username}</b>" if message.from_user.username else ""
                    
                admins = ADMINS.copy()
                
                async for admin in self.database.get_admins():
                    rights = self.decode(admin.rights)
                    
                    if "support" in rights:
                        admins.append(admin.user_id)
                    
                for admin in admins:
                    await self.client.send_message(
                        chat_id=admin,
                        text=f"🧑🏻‍💻 پیام پشتیبانی\n\n🦢 کاربر: <code>{user_id}</code> - <b>{message.from_user.mention}</b>{username}\n💌 پیام:\n<b>{message.text}</b>",
                        reply_markup=markup
                    )
                    
                home_button = Buttons.home if registered else Buttons.register
                    
                await self.database.update_user(get_user, step=None)
                await message.reply(
                    text='🧑🏻‍💻 پیام شما با موفقیت برای ما ارسال شد، منتظر جواب آن باشید.',
                    reply_markup=home_button,
                    quote=True
                )

            elif get_arguments[0] == "register":
                if message.text not in ["➿ همه", "➿ چنل وطنی", "➿ چنل اونلی فنز", "➿ چنل اخلاقی", "➿ چنل زیرنویس"]:
                    return await message.reply(
                        text='❌ **نوع کانال نامعتبر!**\n\n'
                             '🔹 لطفاً یکی از گزینه‌های زیر را انتخاب کنید:\n'
                             '➿ چنل وطنی\n'
                             '➿ چنل اونلی فنز\n'
                             '➿ چنل اخلاقی\n'
                             '➿ چنل زیرنویس',
                        quote=True
                    )

                markup = InlineKeyboardMarkup(
                    [
                        [
                            InlineKeyboardButton("✅ تایید ثبت نام", callback_data=f"register|confirm|{user_id}"),
                            InlineKeyboardButton("❌ رد ثبت نام", callback_data=f"register|cancel|{user_id}")
                        ],
                        [
                            InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{user_id}")
                        ]
                    ]
                )
                
                await self.database.add_register(user_id=user_id)
                    
                username = f" - <b>@{message.from_user.username}</b>" if message.from_user.username else ""
                    
                admins = ADMINS.copy()
                
                async for admin in self.database.get_admins():
                    rights = self.decode(admin.rights)
                    
                    if "users" in rights:
                        admins.append(admin.user_id)

                # پیام خفن برای ادمین
                for admin in admins:
                    try:
                        await self.client.send_message(
                            chat_id=admin,
                            text=f"🐋 **درخواست ثبت نام جدید**\n"
                                 "━━━━━━━━━━━━━━━━━━━━━━\n\n"
                                 f"👤 **کاربر:** <code>{user_id}</code>\n"
                                 f"📛 **نام:** <b>{message.from_user.mention}</b>{username}\n"
                                 f"📌 **حیطه کانال:** <b>{message.text.replace('➿', '').strip()}</b>\n"
                                 f"📅 **تاریخ:** {self.jalali_date(self.timestamp)}\n\n"
                                 "━━━━━━━━━━━━━━━━━━━━━━\n"
                                 "🔹 برای تایید یا رد درخواست روی دکمه‌های زیر کلیک کنید:",
                            reply_markup=markup
                        )
                    except:
                        pass
                    
                await self.database.update_user(get_user, step=None)
                await message.reply(
                    text="✅ **درخواست ثبت نام شما ارسال شد!**\n\n"
                         "━━━━━━━━━━━━━━━━━━━━━━\n\n"
                         "📌 درخواست شما برای **ادمین** ارسال شد.\n"
                         "⏳ لطفاً منتظر **تایید** آن باشید.\n\n"
                         "🔹 پس از تایید، پیام تایید برای شما ارسال خواهد شد.\n\n"
                         "━━━━━━━━━━━━━━━━━━━━━━\n"
                         "🤖 در صورت نیاز با پشتیبانی تماس بگیرید.",
                    reply_markup=Buttons.register,
                    quote=True
                )

            elif get_arguments[0] == "edit_card":
                split_lines = message.text.splitlines()
                
                if len(split_lines) != 3:
                    return await message.reply(
                        text='🏦 ساختار ارسال شده اشتباه می باشد.',
                        quote=True
                    )
                    
                elif not split_lines[0].strip().upper().startswith("IR") or not split_lines[0].strip()[2:].isnumeric() or len(split_lines[0][2:]) != 24:
                    return await message.reply(
                        text='🏦 شماره شبا اشتباه می باشد.',
                        quote=True
                    )
                    
                elif not split_lines[1].strip().isnumeric() or len(split_lines[1].strip()) != 16:
                    return await message.reply(
                        text='🏦 شماره کارت اشتباه می باشد.',
                        quote=True
                    )
                        
                await self.database.update_user(get_user, bank=f"{split_lines[0].strip()}\n{split_lines[1].strip()}\n{split_lines[2].strip()}", step="financial")
                await message.reply(
                    text='🏦 مشخصات بانکی شما با موفقیت ثبت شد.',
                    reply_markup=Buttons.financial,
                    quote=True
                )
                
            elif get_arguments[0] == "edit_wallet":
                if get_arguments[1] == "trc20":
                    await self.database.update_user(get_user, wallet_trc20=message.text, step="financial")
                    await message.reply(
                        text='⚡️ مشخصات کیف پول TRC20 شما با موفقیت ثبت شد.',
                        reply_markup=Buttons.financial,
                        quote=True
                    )
                else:
                    await self.database.update_user(get_user, wallet_ton=message.text, step="financial")
                    await message.reply(
                        text='⚡️ مشخصات کیف پول TON شما با موفقیت ثبت شد.',
                        reply_markup=Buttons.financial,
                        quote=True
                    )
                    
            elif get_arguments[0] == "channels":
                if message.text == "🗄 لیست کانال ها":
                    if not await self.database.get_channels_count(user_id=user_id, verify=True):
                        return await message.reply(
                            text='🗄 شما در حال حاضر <b>کانالی</b> برای نمایش ندارید، از طریق دکمه ی <b>اضافه کردن کانال</b> اقدام به <b>اضافه کردن</b> آن کنید.',
                            quote=True
                        )
                        
                    buttons = []
                    number = 0

                    async for channel in self.database.get_channels(user_id=user_id, verify=True):
                        try:
                            get_chat = await self.client.get_chat(channel.chat_id)
                            title = get_chat.title
                        except:
                            number += 1
                            title = f"کانال {number}"
                            
                        buttons.append([
                            InlineKeyboardButton(self.channel_type(channel.channel_type), callback_data=f"channel|{channel.tag}"),
                            InlineKeyboardButton(title, callback_data=f"channel|{channel.tag}"),
                        ])
                    
                    markup = InlineKeyboardMarkup(buttons)

                    await message.reply(
                        text='🗄 لیست <b>کانال</b> های شما به شرح زیر می باشد، جهت <b>مدیریت</b> روی آن ضربه بزنید:',
                        reply_markup=markup,
                        quote=True
                    )

                elif message.text == "➕ اضافه کردن کانال":
                    await self.database.update_user(get_user, step="add_channel_type")
                    await message.reply(
                        text="➕ نوع کانال خود را انتخاب کنید.",
                        reply_markup=Buttons.add_channel_type,
                        quote=True
                    )

            elif get_arguments[0] == "financial":
                if message.text == "🏦 حساب بانکی":
                    await self.database.update_user(get_user, step="edit_card")
                    await message.reply(
                        text='🏦 مشخصات بانکی خود را در قالب شماره شبا، شماره کارت، نام صاحب حساب مانند نمونه ی زیر ارسال کنید.\n\nIR000000000000000000000000\n6104123456780000\nعلی حسینی',
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "⚡️ کیف پول TRC20":
                    await self.database.update_user(get_user, step="edit_wallet|trc20")
                    await message.reply(
                        text='⚡️ آدرس کیف پول تتر یا ترون TRC20 خود را ارسال کنید، دقت کنید که اشتباه وارد کردن آدرس منجر به از دست رفتن دارایی شما شود.',
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "⚡️ کیف پول TON":
                    await self.database.update_user(get_user, step="edit_wallet|ton")
                    await message.reply(
                        text='⚡️ آدرس کیف پول TON خود را ارسال کنید، دقت کنید که اشتباه وارد کردن آدرس منجر به از دست رفتن دارایی شما شود.',
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "📊 نفرات برتر":
                    rank = 0
                    text = ""
                    
                    async for user in self.database.get_balance_users():
                        rank += 1
                        
                        try:
                            get_users = await self.client.get_users(user.user_id)
                            full_name = get_users.full_name
                        except:
                            full_name = user.user_id

                        text += f"""📈 رتبه: <b>{rank}</b>
👤 نام کاربر: <b>{full_name}</b>
💵 موجودی: <b>{user.current_balance:,} تومان</b>\n\n"""
                    
                    await message.reply(
                        text=f'📊 ده نفر برتر دارای موجودی به شرح زیر می باشد:\n\n{text}🤖 <b>@{self.client.me.username}</b>',
                        quote=True
                    )
                    
                elif message.text == "💰 انتقال موجودی":
                    if get_withdraw := await self.database.get_withdraw(user_id=user_id):
                        return await message.reply(
                            text=f'💳 شما هم اکنون یک درخواست با مقدار <b>{get_withdraw.amount:,}</b> تومان ثبت کرده اید و تا زمان بررسی این درخواست نمی توانید موجودی خود را انتقال دهید.',
                            quote=True
                        )
                    
                    await self.database.update_user(get_user, step="transfer")
                    await message.reply(
                        text='💰 آیدی عددی کاربر مورد نظر را جهت انتقال موجود ارسال کنید.',
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "💳 برداشت":
                    if get_withdraw := await self.database.get_withdraw(user_id=user_id):
                        return await message.reply(
                            text=f'💳 شما هم اکنون یک درخواست با مقدار <b>{get_withdraw.amount:,}</b> تومان ثبت کرده اید.',
                            quote=True
                        )
                    
                    elif get_user.current_balance < 200000:
                        return await message.reply(
                            text='💳 موجودی شما برای برداشت باید حداقل <b>200,000</b> تومان باشد.',
                            quote=True
                        )
                        
                    await self.database.update_user(get_user, step="withdraw_type")
                    await message.reply(
                        text='💳 روش برداشت خود را انتخاب کنید.',
                        reply_markup=Buttons.withdraw_type,
                        quote=True
                    )
            
                elif message.text == "🗒 تاریخچه برداشت":
                    if not await self.database.get_withdraw_histories_count(user_id=user_id):
                        await message.reply(
                            text='🗒 شما تا به حال درخواست برداشت نداشته اید.',
                            quote=True
                        )
                    else:
                        text = ""
                        
                        async for withdraw_history in self.database.get_withdraw_histories(user_id=user_id):
                            text += f"• مبلغ <b>{withdraw_history.amount:,}</b> تومان در تاریخ <b>{self.jalali_date(withdraw_history.date)}</b>\n"
                        
                        await message.reply(
                            text=f'🗒 برداشت های شما به شرح زیر می باشد:\n\n{text}\n🤖 <b>@{self.client.me.username}</b>',
                            quote=True
                        )
            
            elif get_arguments[0] == "add_channel_type":
                if message.text == "➿ چنل وطنی":
                    channel_type = 2
                elif message.text == "➿ چنل اونلی فنز":
                    channel_type = 3
                elif message.text == "➿ چنل اخلاقی":
                    channel_type = 4
                elif message.text == "➿ چنل زیرنویس":
                    channel_type = 5
                else:
                    return await message.reply(
                        text='➕ <b>نوع کانال</b> انتخاب شده <b>اشتباه</b> می باشد.',
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"add_channel|{channel_type}")
                await message.reply(
                    text="➕ لینک <b>کانال</b> خود را مانند هر یک از نمونه های زیر <b>ارسال</b> کنید یا یک پیام از <b>کانال</b> خود را <b>فوروارد</b> کنید.\n\n<b>✱ @username\n✱ https://t.me/username\n123456\n✱ -100123456</b>",
                    reply_markup=Buttons.back,
                    quote=True
                )

            elif get_arguments[0] == "add_channel":
                if re.match(r"[@][a-zA-Z0-9_]+|^https://t\.me/[a-zA-Z0-9_-]+", message.text):
                    username = message.text.replace("https://t.me/", "@")

                    try:
                        get_chat = await self.client.get_chat(username)
                        chat_id = get_chat.id
                    except:
                        return await message.reply(
                            text='➕ <b>ربات</b> داخل کانال <b>ادمین</b> نمی باشد.',
                            quote=True
                        )
                    
                elif cid_match := re.match(r"(?:-100)?([0-9]+)", message.text):
                    chat_id = int(f"-100{cid_match.group(1)}")
                    
                elif message.forward_origin and message.forward_origin.type == MessageOriginType.CHANNEL:
                    chat_id = message.forward_origin.chat.id

                else:
                    return await message.reply(
                        text='➕ <b>کانال</b> ارسال شده طبق <b>فرمت</b> های <b>تعریف</b> شده نمی باشد.',
                        quote=True
                    )
                
                if not await self.bot_admin(chat_id):
                    return await message.reply(
                        text='➕ <b>ربات</b> داخل کانال <b>ادمین</b> نمی باشد.',
                        quote=True
                    )
                
                get_channel = await self.database.get_channel(chat_id=chat_id)

                if get_channel:
                    if not get_channel.verify and get_channel.user_id == user_id:
                        return await message.reply(
                            text='➕ این <b>کانال</b> در دست <b>تایید</b> است.',
                            quote=True
                        )

                    else:
                        return await message.reply(
                            text='➕ این <b>کانال</b> از قبل <b>ارسال</b> شده است.',
                            quote=True
                        )
                    
                tag = self.string_generator()
                markup = InlineKeyboardMarkup(
                    [
                        [
                            InlineKeyboardButton("لغو 🔴", callback_data=f"add_channel|cancel|{tag}"),
                            InlineKeyboardButton("🟢 تایید", callback_data=f"add_channel|confirm|{tag}")
                        ],
                        [
                            InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{tag}")
                        ]
                    ]
                )
                    
                try:
                    get_chat = await self.client.get_chat(chat_id)
                    title = get_chat.title
                    link = await self.client.export_chat_invite_link(chat_id)
                except:
                    title = "-"
                    link = "-"

                username = f" - <b>@{message.from_user.username}</b>" if message.from_user.username else ""
                
                admins = ADMINS.copy()
                async for admin in self.database.get_admins():
                    rights = self.decode(admin.rights)
                    
                    if "channels" in rights:
                        admins.append(admin.user_id)

                for admin in admins:
                    try:
                        await self.client.send_message(
                            chat_id=admin,
                            text=f"🐋 ثبت کانال\n\n🦢 کاربر: <code>{user_id}</code> - <b>{message.from_user.mention}</b>{username}\n♻️ کانال:\n\n💡 آیدی کانال: <code>{chat_id}</code>\n🧾 نام کانال: <b>{escape(title)}</b>\n🔗 لینک کانال: {link}\n🔖 نوع کانال: <b>{self.channel_type(get_arguments[1])}</b>",
                            reply_markup=markup
                        )
                    except Exception as e:
                        print(e)
                        pass

                await self.database.add_channel(user_id=user_id, chat_id=chat_id, channel_type=int(get_arguments[1]), tag=tag)
                await message.reply(
                    text='➕ کانال شما با <b>موفقیت</b> اضافه شد و پس از <b>تایید</b> شدن توسط <b>مدیر،</b> در <b>لیست کانال</b> های شما نمایش داده می شود.\n➿ در صورت اضافه کردن <b>کانال بعدی،</b> آن را ارسال کنید و در غیر این صورت روی دکمه ی <b>بازگشت</b> ضربه بزنید.',
                    quote=True
                )

            elif get_arguments[0] == "withdraw_type":
                if message.text == "🏦 ریال":
                    if not get_user.bank:
                        return await message.reply(
                            text='💳 شما هنوز مشخصات بانکی خود را در بخش پروفایل تنظیم نکرده اید، از بخش پروفایل اقدام به انجام این کار کنید.',
                            quote=True
                        )
                    
                    withdraw_type_text = "ریال"
                    withdraw_type = "rial"
                    tron_price = ""
                    
                elif message.text == "⚡️ ترون":
                    if not get_user.wallet_trc20:
                        return await message.reply(
                            text='💳 شما هنوز مشخصات کیف پول TRC20 خود را در بخش پروفایل تنظیم نکرده اید، از بخش پروفایل اقدام به انجام این کار کنید.',
                            quote=True
                        )
                        
                    withdraw_type_text = "ترون"
                    withdraw_type = "tron"
                    tron_price = f"\n• قیمت زنده ی ترون: <b>{self.tron_price:,} تومان</b>"
                        
                elif message.text == "⚡️ TON":
                    if not get_user.wallet_ton:
                        return await message.reply(
                            text='💳 شما هنوز مشخصات کیف پول TON خود را در بخش پروفایل تنظیم نکرده اید، از بخش پروفایل اقدام به انجام این کار کنید.',
                            quote=True
                        )
                        
                    withdraw_type_text = "TON"
                    withdraw_type = "ton"
                    tron_price = f"\n• قیمت زنده ی TON: <b>{self.ton_price:,} تومان</b>"
                        
                else:
                    return await message.reply(
                        text='💳 روش تسویه ی انتخاب شده اشتباه می باشد.',
                        quote=True
                    )
                    
                await self.database.update_user(get_user, step=f"withdraw|{withdraw_type}")
                await message.reply(
                    text=f'💳 مقدار مد نظر خود را بدون استفاده از هیچ علامت و فقط اعداد انگلیسی برای برداشت ارسال کنید.\n• روش پرداخت: <b>{withdraw_type_text}</b>\n• موجودی قابل برداشت: <b>{get_user.current_balance:,} تومان</b>{tron_price}',
                    reply_markup=Buttons.back,
                    quote=True
                )
                    
            elif get_arguments[0] == "withdraw":
                if not message.text.isnumeric() or int(message.text) > get_user.current_balance:
                    return await message.reply(
                        text='💳 مقدار برداشت بیشتر از موجودی فعلی شما می باشد.',
                        quote=True
                    )
                
                elif int(message.text) < self.setting.least_withdraw:
                    return await message.reply(
                        text=f'💳 <b>حداقل</b> مقدار برداشت <b>{self.setting.least_withdraw:,} تومان</b> است.',
                        quote=True
                    )
                    
                amount = int(message.text)
                await self.database.add_withdraw(user_id=user_id, amount=amount, type=get_arguments[1])
                       
                admins = ADMINS.copy()
                
                async for admin in self.database.get_admins():
                    rights = self.decode(admin.rights)
                    
                    if "invoices" in rights:
                        admins.append(admin.user_id)
                    
                for admin in admins:
                    try:
                        await self.client.send_message(
                            chat_id=admin,
                            text=f"💳 یک درخواست تسوی ی جدید ثبت شد."
                        )
                    except:
                        pass
                    
                await self.database.update_user(get_user, step="financial")
                await message.reply(
                    text='💳 درخواست برداشت شما با موفقیت ثبت شد.',
                    reply_markup=Buttons.financial,
                    quote=True
                )
                
            elif get_arguments[0] == "transfer":
                if not message.text.isnumeric() or int(message.text) <= 0:
                    return await message.reply(
                        text='💰 آیدی عددی کاربر اشتباه می باشد.',
                        quote=True
                    )
                    
                get_input_user = await self.database.get_user(user_id=int(message.text))
                
                if not get_input_user:
                    return await message.reply(
                        text='💰 این کاربر در ربات وجود ندارد.',
                        quote=True
                    )
                    
                elif get_input_user.user_id == user_id:
                    return await message.reply(
                        text='💰 شما نمی توانید به موجودی انتقال دهید.',
                        quote=True
                    )
                    
                try:
                    get_tg_user = await self.client.get_users(get_input_user.user_id)
                    full_name = get_tg_user.full_name
                except:
                    full_name = get_input_user.user_id
                        
                await self.database.update_user(get_user, step=f"transfer_count|{get_input_user.user_id}")
                await message.reply(
                    text=f'💰 مقدار موجودی مورد نظر را برای انتقال به کاربر <b>{full_name}</b> ارسال کنید، دقت کنید که این عمل غیر قابل بازگشت می باشد.',
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "transfer_count":
                if not message.text.isnumeric() or int(message.text) <= 0:
                    return await message.reply(
                        text='💰 مقدار ارسالی اشتباه می باشد.',
                        quote=True
                    )
                
                balance_count = int(message.text)
                
                if get_user.current_balance < balance_count:
                    return await message.reply(
                        text='💰 موجودی شما کافی نمی باشد.',
                        quote=True
                    )
                
                get_input_user = await self.database.get_user(user_id=int(get_arguments[1]))
                
                await self.database.update_user(get_input_user, all_balance=get_input_user.all_balance + balance_count, current_balance=get_input_user.current_balance + balance_count)
                await self.database.update_user(get_user, current_balance=get_user.current_balance - balance_count, step="financial")
        
                try:
                    get_users = await self.client.get_users(get_input_user.user_id)
                    full_name = get_users.mention
                except:
                    full_name = "کاربر"

                for admin in ADMINS:
                    try:
                        await self.client.send_message(
                            chat_id=admin,
                            text=f"💰 کاربر <code>{user_id}</code> - <b>{message.from_user.mention}</b> به مقدار <b>{balance_count:,} تومان</b> تومان به کاربر <code>{get_input_user.user_id}</code> - <b>{full_name}</b> انتقال داد.",
                            quote=True
                        )
                    except:
                        pass
        
                try:
                    await self.client.send_message(
                        chat_id=get_input_user.user_id,
                        text=f"💰 موجودی حساب شما توسط کاربر {message.from_user.full_name} به مقدار <b>{balance_count:,} تومان</b> تومان افزایش یافت.",
                        quote=True
                    )
                except:
                    pass
                
                await message.reply(
                    text='💰 انتقال موجودی با موفقیت انجام شد.',
                    reply_markup=Buttons.financial,
                    quote=True
                )
                    
            elif get_arguments[0] == "admin" and await self.is_admin(user_id):
                if message.text == "📊 آمار ربات":
                    users_count = await self.database.get_users_count()
                    active_15m = await self.database.get_last_use_users(self.timestamp - 900)
                    blocked_users = await self.database.get_users_count(block=True)
                    
                    yesterday_users = await self.database.get_last_users(self.start_of_day)
                    week_users = await self.database.get_last_users(self.start_of_week)
                    month_users = await self.database.get_last_users(self.start_of_month)
                    year_users = await self.database.get_last_users(self.start_of_year)
                    
                    all_balance = await self.database.get_users_all_balance()
                    current_balance = await self.database.get_users_current_balance()
                    
                    banners_total = await self.database.get_banners_count()
                    banners_active = await self.database.get_banners_count(status=0)
                    banners_audited = await self.database.get_banners_count(status=1)
                    
                    seens_total = await self.database.get_seens_count()
                    seens_active = await self.database.get_seens_count(status=0)
                    seens_audited = await self.database.get_seens_count(status=1)
                    
                    all_seens = await self.database.get_all_seens_count()
                    
                    not_done = 0
                    async for seen in self.database.get_seens(status=0):
                        get_banner = await self.database.get_banner(tag=seen.banner_tag)
                        if not get_banner:
                            continue
                        not_done += round(((seen.all_count + seen.count) / 1000) * get_banner.s1000)

                    text_stats = (
                        "📊 <b>گزارش جامع آمار و عملکرد ربات</b>\n"
                         "━ ━ ━ ━ ━ ━ ━ ━ ━ \n\n"

                        "👥 <b>وضعیت کاربران (Users)</b>\n"
                        f"├─ 👤 کل کاربران ربات: <code>{users_count:,}</code> نفر\n"
                        f"├─ ⏱ فعالان ۱۵ دقیقه اخیر: <code>{active_15m:,}</code> کاربر\n"
                        f"├─ 🛑 کاربران متوقف شده: <code>{blocked_users:,}</code> نفر\n"
                        "└─ 📈 آمار رشد ثبت‌نام:\n"
                        f"   ├── 🗓 دیروز: <code>{yesterday_users:,}</code>+\n"
                        f"   ├── 🗓 هفته گذشته: <code>{week_users:,}</code>+\n"
                        f"   ├── 🗓 ماه گذشته: <code>{month_users:,}</code>+\n"
                        f"   └── 🗓 سال گذشته: <code>{year_users:,}</code>+\n\n"
                        "💰 <b>امور مالی و تراکنش‌ها (Financial)</b>\n"
                        f"├─ 💵 جمع کل درآمد کاربران: <code>{all_balance:,}</code> تومان\n"
                        f"├─ 💳 جمع درآمد فعلی (موجودی): <code>{current_balance:,}</code> تومان\n"
                        f"└─ ⏳ درآمد در حال حسابرسی: <code>{not_done:,}</code> تومان\n\n"
                        "📢 <b>بخش بنرهای مدیریت (Admin Banners)</b>\n"
                        f"├─ 📝 کل بنرها: <code>{banners_total:,}</code>\n"
                        f"├─ ⚡️ بنرهای فعال: <code>{banners_active:,}</code>\n"
                        f"└─ ✅ بنرهای حسابرسی شده: <code>{banners_audited:,}</code>\n\n"
                        "👤 <b>بخش بنرهای کاربران (User Banners)</b>\n"
                        f"├─ 📝 کل بنرهای ثبت شده: <code>{seens_total:,}</code>\n"
                        f"├─ ⚡️ بنرهای فعال فعلی: <code>{seens_active:,}</code>\n"
                        f"└─ 📊 بنرهای حسابرسی شده: <code>{seens_audited:,}</code>\n\n"
                        "👁‍🗨 <b>آمار کل بازدید (Total Views)</b>\n"
                        f"└─ 👁 کل سین‌های ثبت شده: <code>{all_seens:,}</code> سین\n"
                        
                    )

                    await message.reply(
                        text=text_stats,
                        quote=True
                    )
                    return
                
                elif message.text == "🔑 ادمین" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="admins")
                    await message.reply(
                        text="🔑 لطفا گزینه ی مورد نظر خود را انتخاب کنید.",
                        reply_markup=Buttons.options,
                        quote=True
                    )
                    
                elif message.text == "🔖 ارسال همگانی" and await self.is_admin(user_id, "send_all"):
                    await self.database.update_user(get_user, step="send_all")
                    await message.reply(
                        text="🔖 پیام خود را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "✉️ پیام به کاربر" and await self.is_admin(user_id, "send_user_pm"):
                    await self.database.update_user(get_user, step="admin_message|user")
                    await message.reply(
                        text="✉️ آیدی عددی کاربر را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "💵 افزایش موجودی" and await self.is_admin(user_id, "edit_balance"):
                    await self.database.update_user(get_user, step="admin_add_balance|user")
                    await message.reply(
                        text="💵 آیدی عددی کاربر را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "⭐️ افزودن بنر" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="add_banner")
                    await message.reply(
                        text="⭐️ بنر خود را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "💥 حذف بنر" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="delete_banner")
                    await message.reply(
                        text="💥 تگ بنر را برای حذف وارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🌪 پیگیری" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="show_banner")
                    await message.reply(
                        text="🌪 تگ بنر را برای پیگیری وارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "☄️ حسابرسی" and await self.is_admin(user_id, "banner"):
                    await self.database.update_user(get_user, step="done_banner")
                    await message.reply(
                        text="☄️ تگ بنر را برای حسابرسی وارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "📸 ریشات" and await self.is_admin(user_id, "banner"):
                    if not await self.database.get_banners_count(status=0):
                        return await message.reply(
                            text="📸 هیچ بنری برای ریشات وجود ندارد.",
                            quote=True
                        )
                    
                    buttons = []
                
                    async for banner in self.database.get_banners(status=0):
                        buttons.append(
                            [
                                InlineKeyboardButton(banner.banner_name, callback_data=f"reshot|{banner.tag}|normal")
                            ]
                        )
                
                    markup = InlineKeyboardMarkup(buttons)
                    
                    await message.reply(
                        text=f"📸 <b>بنر</b> خود را برای <b>ریشات</b> انتخاب کنید.",
                        reply_markup=markup,
                        quote=True
                    )
                    
                elif message.text == "🛡 بنر ها" and await self.is_admin(user_id, "banner"):
                    if not await self.database.get_channel_requests_count():
                        return await message.reply(
                            text="🛡 هیچ <b>بنری</b> برای <b>تایید</b> وجود ندارد.",
                            quote=True
                        )
                        
                    async for channel_request in self.database.get_channel_requests():
                        get_banner = await self.database.get_banner(tag=channel_request.banner_tag)

                        if not get_banner:
                            await self.database.delete_channel_request(channel_request.id)
                            await message.reply(
                                text="🛡 <b>بنر</b> این <b>درخواست</b> دیگر در <b>دسترس</b> نیست."
                            )
                            continue

                        get_channel = await self.database.get_channel(tag=channel_request.channel_tag)

                        if not get_channel:
                            await self.database.delete_channel_request(channel_request.id)
                            await message.reply(
                                text="🛡 <b>کانال درخوست</b> تایید این <b>بنر</b> دیگر در <b>دسترس</b> نیست."
                            )
                            continue

                        markup = InlineKeyboardMarkup(
                            [
                                [
                                    InlineKeyboardButton("لغو بنر 🔴", callback_data=f"channel_request|cancel|{channel_request.tag}"),
                                    InlineKeyboardButton("🟢 تایید بنر", callback_data=f"channel_request|confirm|{channel_request.tag}")
                                ],
                                [
                                    InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{get_channel.user_id}")
                                ]
                            ]
                        )
                        
                        try:
                            get_tg_user = await self.client.get_users(get_channel.user_id)
                            mention = f" - <b>{get_tg_user.mention}</b>"
                            username = f" - <b>@{get_tg_user.username}</b>" if get_tg_user.username else ""
                        except:
                            mention = ""
                            username = ""
                            
                        try:
                            get_chat = await self.client.get_chat(get_channel.chat_id)
                            title = get_chat.title
                            link = await self.client.export_chat_invite_link(get_channel.chat_id)
                        except:
                            title = "-"
                            link = "-"
                            
                        await message.reply(
                            text=f"🛡 تایید بنر\n\n🦢 کاربر: <code>{get_channel.user_id}</code>{mention}{username}\n\n➿ نام بنر: <b>{escape(get_banner.banner_name)}</b>\n\n💡 آیدی کانال: <code>{get_channel.chat_id}</code>\n🧾 نام کانال: <b>{escape(title)}</b>\n🔗 لینک کانال: {link}\n🔖 نوع کانال: <b>{self.channel_type(get_channel.channel_type)}</b>",
                            reply_markup=markup
                        )

                elif message.text == "📢 کانال بنر" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="banner_channel")
                    await message.reply(
                        text=f"📢 <b>کانال بنر</b> را برای ارسال <b>بنر</b> های ساخته شده ارسال کنید.\n➖ کانال کنونی: {self.setting.banner_channel}",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "👤 مشخصات کاربر" and await self.is_admin(user_id, "user_info"):
                    await self.database.update_user(get_user, step="user_info")
                    await message.reply(
                        text="👤 آیدی عددی یا یوزرنیم کاربر را برای دریافت اطلاعات وارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "✨ تسویه ها" and await self.is_admin(user_id, "invoices"):
                    if not await self.database.get_withdraw_count():
                        return await message.reply(
                            text="✨ هیچ درخواست تسویه ای وجود ندارد.",
                            quote=True
                        )
                        
                    async for withdraw in self.database.get_withdraws():
                        markup = InlineKeyboardMarkup(
                            [
                                [
                                    InlineKeyboardButton("لغو برداشت 🔴", callback_data=f"withdraw|cancel|{withdraw.user_id}"),
                                    InlineKeyboardButton("🟢 تایید برداشت", callback_data=f"withdraw|confirm|{withdraw.user_id}")
                                ],
                                [
                                    InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{withdraw.user_id}")
                                ]
                            ]
                        )
                        
                        try:
                            get_tg_user = await self.client.get_users(withdraw.user_id)
                            mention = f" - <b>{get_tg_user.mention}</b>"
                            username = f" - <b>@{get_tg_user.username}</b>" if get_tg_user.username else ""
                        except:
                            mention = ""
                            username = ""
                            
                        get_input_user = await self.database.get_user(user_id=withdraw.user_id)
                        
                        if withdraw.type == "rial":
                            bank_structure = get_input_user.bank.splitlines()
                            bank = f"""
<b>• شماره شبا:</b> <code>{bank_structure[0]}</code>
<b>• شماره کارت:</b> <code>{bank_structure[1]}</code>
<b>• صاحب حساب: {bank_structure[2]}</b>"""

                            await message.reply(
                                text=f"💳 برداشت\n\n🦢 کاربر: <code>{withdraw.user_id}</code>{mention}{username}\n💸 مقدار: <b>{withdraw.amount:,} تومان</b>\n🏦 مشخصات بانکی:\n{bank}",
                                reply_markup=markup
                            )
                            
                        elif withdraw.type == "tron":
                            tron = 0 if not self.tron_price else round(withdraw.amount / self.tron_price, 2)
                            await message.reply(
                                text=f"💳 برداشت\n\n🦢 کاربر: <code>{withdraw.user_id}</code>{mention}{username}\n💸 مقدار: <b>{withdraw.amount:,} تومان</b>\n💰 ترون: <b>{tron}</b>\n⚡️ کیف پول TRC20:\n<code>{get_input_user.wallet_trc20}</code>",
                                reply_markup=markup
                            )
                            
                        else:
                            ton = 0 if not self.ton_price else round(withdraw.amount / self.ton_price, 2)
                            await message.reply(
                                text=f"💳 برداشت\n\n🦢 کاربر: <code>{withdraw.user_id}</code>{mention}{username}\n💸 مقدار: <b>{withdraw.amount:,} تومان</b>\n💰 TON: <b>{ton}</b>\n⚡️ کیف پول TON:\n<code>{get_input_user.wallet_ton}</code>",
                                reply_markup=markup
                            )
                            
                elif message.text == "🌵 کاربران" and await self.is_admin(user_id, "users"):
                    if not await self.database.get_channels_count(verify=True):
                        return await message.reply(
                            text="🌵 هیچ کاربر تایید شده ای وجود ندارد.",
                            quote=True
                        )
                        
                    async for channel in self.database.get_channels(verify=True):
                        markup = InlineKeyboardMarkup(
                            [
                                [
                                    InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{channel.user_id}")
                                ]
                            ]
                        )
                        
                        try:
                            get_tg_user = await self.client.get_users(channel.user_id)
                            mention = f" - <b>{get_tg_user.mention}</b>"
                            username = f" - <b>@{get_tg_user.username}</b>" if get_tg_user.username else ""
                        except:
                            mention = ""
                            username = ""
                            
                        await message.reply(
                            text=f"🐋 ثبت نام\n\n🦢 کاربر: <code>{channel.user_id}</code>{mention}{username}\n♻️ کانال ها:\n<b>{channel.channel}</b>",
                            reply_markup=markup
                        )
                        
                elif message.text == "🔦 داپ ها" and user_id in ADMINS:
                    async for channel in self.database.get_duplicates_channels():
                        await asyncio.sleep(0.5)

                        markup = InlineKeyboardMarkup(
                            [
                                [
                                    InlineKeyboardButton(text='❌ حذف کانال', callback_data=f"admin_delete_channel|{channel.tag}|normal")
                                ]
                            ]
                        )
                            
                        try:
                            get_chat = await self.client.get_chat(channel.chat_id)
                            title = get_chat.title
                            link = await self.client.export_chat_invite_link(channel.chat_id)
                        except:
                            print(format_exc())
                            title = "-"
                            link = "-"

                        try:
                            await message.reply(
                                text=f"💡 آیدی کانال: <code>{channel.chat_id}</code>\n🧾 نام کانال: <b>{escape(title)}</b>\n🔗 لینک کانال: {link}\n🔖 نوع کانال: <b>{self.channel_type(channel.channel_type)}</b>",
                                reply_markup=markup
                            )
                        except:
                            pass

                    async for seen in self.database.get_duplicates_seens():
                        get_banner = await self.database.get_banner(tag=seen.banner_tag)

                        if not get_banner or get_banner.status != 0:
                            continue

                        await asyncio.sleep(1)

                        markup = InlineKeyboardMarkup(
                            [
                                [
                                    InlineKeyboardButton(text='❌ حذف بنر', callback_data=f"admin_delete_seen|{seen.tag}|normal")
                                ]
                            ]
                        )
                            
                        try:
                            print(seen.chat_id)
                            get_chat = await self.client.get_chat(seen.chat_id)
                            title = get_chat.title
                            link = await self.client.export_chat_invite_link(seen.chat_id)
                        except Exception as e:
                            print(e)
                            title = "-"
                            link = "-"

                        try:
                            await message.reply(
                                text=f"💡 آیدی کانال: <code>{seen.chat_id}</code>\n🧾 نام کانال: <b>{escape(title)}</b>\n🔗 لینک کانال: {link}\n⭕️ تکرار: {await self.database.get_seens_count(banner_tag=seen.banner_tag, chat_id=seen.chat_id):,}\n\n➰ سین: <b>{seen.all_count or 0 + seen.count:,}</b>",
                                reply_markup=markup
                            )
                        except Exception as e:
                            print(e)
                            pass

                    await message.reply(
                        text=f"🔦 داپ ها ارسال شدند.",
                    )

                elif message.text == "🍁 اخراج کاربر" and await self.is_admin(user_id, "ban_user"):
                    await self.database.update_user(get_user, step="blocks")
                    await message.reply(
                        text="☁️ گزینه ی مورد نظر خود را انتخاب کنید.",
                        reply_markup=Buttons.options,
                        quote=True
                    )
                        
                elif message.text == "📮 استخراج" and await self.is_admin(user_id, "extract"):
                    await self.database.update_user(get_user, step="extract_users")
                    await message.reply(
                        text="📮 تگ بنر خود را ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🎁 هدیه" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="gifts")
                    await message.reply(
                        text=f"🎁 هدیه ی خود را مانند فرمت زیر ارسال کنید.\n\nTAG\nRANK 1\nRANK 2\nRANK 3",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🔹 روشن/خاموش کردن ربات" and user_id in ADMINS:
                    if self.setting.off:
                        status = "روشن"
                        await self.database.update_setting(self.setting, off=False)
                    else:
                        status = "خاموش"
                        await self.database.update_setting(self.setting, off=True)

                    await message.reply(
                        text=f"🔹 وضعیت ربات به <b>{status}</b> تغییر کرد",
                        reply_markup=Buttons.back,
                        quote=True
                    )

                elif message.text == "💵 حداقل برداشت" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="least_withdraw")
                    await message.reply(
                        text=f"💵 حداقل برداشت خود را ارسال کنید.\n➖ مقدار کنونی: {self.setting.least_withdraw:,} تومان",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🕯 متن استارت" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="starttext")
                    await message.reply(
                        text=f"🕯 متن خود را برای دکمه ی استارت ارسال کنید.\n➖ متن کنونی: {self.setting.start}",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🕯 متن ثبت نام" and user_id in ADMINS:
                    await self.database.update_user(get_user, step="registertext")
                    await message.reply(
                        text=f"🕯 متن خود را برای دکمه ی ثبت نام ارسال کنید.\n➖ متن کنونی: {self.setting.register}",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🤖 تنظیمات ربات" and user_id in ADMINS:
                    bot_settings_keyboard = InlineKeyboardMarkup([
                        [
                            InlineKeyboardButton("💰 تنظیمات مالی", callback_data="settings_finance"),
                            InlineKeyboardButton("📢 تنظیمات کانال‌ها", callback_data="settings_channels")
                        ],
                        [
                            InlineKeyboardButton("💾 تنظیمات بکاپ", callback_data="settings_backup"),
                            InlineKeyboardButton("⚙️ تنظیمات عمومی", callback_data="settings_general")
                        ],
                        [
                            InlineKeyboardButton("📝 متن‌ها و پیام‌ها", callback_data="settings_texts"),
                            InlineKeyboardButton("📌 گروه ثبت‌نام", callback_data="settings_register_group")
                        ],
                        [
                            InlineKeyboardButton("🔄 ریست دیتابیس", callback_data="settings_reset_db"),
                            InlineKeyboardButton("📊 آمار ربات", callback_data="settings_stats")
                        ],
                        [
                            InlineKeyboardButton("🔁 ریاستارت", callback_data="settings_restart"),
                            InlineKeyboardButton("🔙 بازگشت به پنل", callback_data="back_to_admin_panel")
                        ]
                    ])
                    
                    await message.reply(
                        text="🤖 **تنظیمات ربات**\n\n"
                             "━━━━━━━━━━━━━━━━━━━━━━\n\n"
                             "🔹 از این بخش می‌توانید **تنظیمات** مختلف ربات را مدیریت کنید.\n\n"
                             "📌 **گزینه‌های موجود:**\n"
                             "• 💰 تنظیمات مالی - مدیریت نرخ‌ها و برداشت\n"
                             "• 📢 تنظیمات کانال‌ها - مدیریت کانال‌های ربات\n"
                             "• 💾 تنظیمات بکاپ - مدیریت پشتیبان‌گیری\n"
                             "• ⚙️ تنظیمات عمومی - تنظیمات اصلی ربات\n"
                             "• 📝 متن‌ها و پیام‌ها - ویرایش پیام‌ها\n"
                             "• 📌 گروه ثبت‌نام - تنظیم گروه ثبت‌نام\n"
                             "• 🔄 ریست دیتابیس - بازنشانی کامل دیتابیس\n"
                             "• 📊 آمار ربات - مشاهده آمار کامل\n"
                             "• 🔁 ریاستارت - ریاستارت ربات\n\n"
                             "━━━━━━━━━━━━━━━━━━━━━━\n"
                             "🤖 لطفاً یکی از گزینه‌های زیر را انتخاب کنید:",
                        reply_markup=bot_settings_keyboard,
                        quote=True
                    )
                
                else:
                    await message.reply(
                        text="☁️ دستور وارد شده اشتباه می باشد.",
                        quote=True
                    )
                    
            elif get_arguments[0] == "admin_add_balance" and await self.is_admin(user_id, "edit_balance"):
                if get_arguments[1] == "user":
                    if not message.text.isnumeric():
                        return await message.reply(
                            text="☁️ این کاربر وجود ندارد.",
                            quote=True
                        )
                    
                    get_input_user = await self.database.get_user(user_id=int(message.text))
                    
                    if not get_input_user:
                        return await message.reply(
                            text="☁️ این کاربر وجود ندارد.",
                            quote=True
                        )
                        
                    try:
                        get_tg_user = await self.client.get_users(get_input_user.user_id)
                        mention_user = get_tg_user.mention
                    except:
                        mention_user = get_input_user.user_id
                            
                    await self.database.update_user(get_user, step=f"admin_add_balance|{get_input_user.user_id}")
                    await message.reply(
                        text=f"☁️ مقدار موجودی خود را ارسال کنید.\n➖ کاربر: <b>{mention_user}</b>\n➖ موجودی کنونی: {get_input_user.current_balance}\n➖ موجودی کل: {get_input_user.all_balance}",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                else:
                    try:
                        balance = int(message.text)
                    except:
                        return await message.reply(
                            text="☁️ موجودی اشتباه است.",
                            quote=True
                        )
                        
                    get_input_user = await self.database.get_user(user_id=int(get_arguments[1]))
                    
                    await self.database.update_user(get_input_user, current_balance=get_input_user.current_balance + balance, all_balance=get_input_user.all_balance + balance)
                        
                    try:
                        await self.client.send_message(
                            chat_id=get_input_user.user_id,
                            text=f"💰 موجودی حساب شما توسط ادمین به مقدار <b>{balance:,}</b> تومان افزایش یافت."
                        )
                        text = "☁️ پیام شما به کاربر ارسال شد و حساب آن نیز شارژ شد."
                    except:
                        text = "☁️ پیام نتوانست به کاربر ارسال شود ولی حساب آن شارژ شد.."
                    
                    await self.database.update_user(get_user, step="admin")
                    await message.reply(
                        text=text,
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                    
            elif get_arguments[0] == "blocks":
                if message.text not in ["❕ مشاهده", "➕ اضافه کردن", "➖ حذف کردن"]:
                    await message.reply(
                        text="🦕 گزینه انتخاب شده اشتباه می باشد.",
                        quote=True
                    )
                
                elif message.text == "❕ مشاهده":
                    text = ""
                    async for user in self.database.get_blocks():
                        try:
                            get_sub_user = await self.client.get_users(user.user_id)
                            full_name = f" - <i>{get_sub_user.full_name}</i>"
                        except:
                            full_name = ""
                            
                        text += f"<code>{user.user_id}</code>{full_name}\n"
                               
                    await message.reply(
                        text=f"🦕 لیست مسدود های شما:\n\n{text}",
                        reply_markup=Buttons.options,
                        quote=True
                    )
                
                elif message.text == "➕ اضافه کردن":
                    await self.database.update_user(get_user, step="add_block")
                    await message.reply(
                        text="🦕 مسدود خود را برای اضافه ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "➖ حذف کردن":
                    await self.database.update_user(get_user, step="delete_block")
                    await message.reply(
                        text="🦕 مسدود خود را برای حذف کردن ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
            elif get_arguments[0] == "add_block":
                if not message.text.isnumeric():
                    return await message.reply(
                        text="🦕 پارامتر ها اشتباه می باشد.",
                        quote=True
                    )
                
                elif await self.database.get_block(message.text):
                    return await message.reply(
                        text="🦕 مسدودی با این آیدی وجود دارد.",
                        quote=True
                    )
                
                get_input_user = await self.database.get_user(user_id=int(message.text))
                if not get_input_user:
                    return await message.reply(
                        text="☁️ این کاربر وجود ندارد.",
                        quote=True
                    )
                
                get_channel = await self.database.get_channel(user_id=get_input_user.user_id)
                if get_channel:
                    await self.database.delete_channel(get_channel.id)
                    await self.database.update_user(get_input_user, step=None)    
                    
                    try:
                        await self.client.send_message(
                            chat_id=get_input_user.user_id,
                            text="☁️ شما از این گسترده اخراج شدید.",
                            reply_markup=Buttons.register
                        )
                    except:
                        pass

                await self.database.add_block(user_id=message.text)
                await self.database.update_user(get_user, step="blocks")
                
                await message.reply(
                    text=f"🦕 مسدود با موفقیت اضافه شد.\n• مسدود: <b>{message.text}</b>",
                    reply_markup=Buttons.options,
                    quote=True
                )
            
            elif get_arguments[0] == "delete_block":
                if not await self.database.get_block(message.text):
                    return await message.reply(
                        text="🦕 مسدودی با این آیدی وجود ندارد.",
                        quote=True
                    )
                
                await self.database.delete_block(message.text)
                await self.database.update_user(get_user, step="blocks")

                await message.reply(
                    text=f"🦕 مسدود با موفقیت حذف شد.\n• مسدود: <b>{message.text}</b>",
                    reply_markup=Buttons.options,
                    quote=True
                )
                    
            elif get_arguments[0] == "admin_message" and await self.is_admin(user_id, "send_user_pm"):
                if get_arguments[1] == "user":
                    if not message.text.isnumeric() or int(message.text) <= 0:
                        return await message.reply(
                            text='☁️ آیدی عددی کاربر اشتباه می باشد.',
                            quote=True
                        )
                        
                    get_input_user = await self.database.get_user(user_id=int(message.text))
                    
                    if not get_input_user:
                        return await message.reply(
                            text="☁️ این کاربر وجود ندارد.",
                            quote=True
                        )
                        
                    try:
                        get_users = await self.client.get_users(get_input_user.user_id)
                        full_name = get_users.full_name
                    except:
                        full_name = get_arguments[1]
                
                    await self.database.update_user(get_user, step=f"admin_message|{get_input_user.user_id}")
                    await message.reply(
                        text=f"☁️ متن خود را برای ارسال پیام به کاربر {full_name} وارد کنید کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                else:
                    try:
                        await self.client.send_message(
                            chat_id=int(get_arguments[1]),
                            text=f"🕊 پشتیبانی: {message.text}"
                        )
                        text = "☁️ پیام شما به کاربر ارسال شد."
                    except:
                        text = "☁️ پیام نتوانست به کاربر ارسال شود."
                    
                    await self.database.update_user(get_user, step="admin")
                    await message.reply(
                        text=text,
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id))
                    )
                
            elif get_arguments[0] == "send_all" and await self.is_admin(user_id, "send_all"):
                await message.reply(
                    text="☁️ درحال ارسال ...",
                    quote=True
                )
                    
                success = error = 0
                
                async for user in self.database.get_users():
                    try:
                        if message.forward_date:
                            await message.forward(
                                user.user_id
                            )
                        else:
                            await message.copy(
                                user.user_id
                            )
                        success += 1
                    except:
                        error += 1
                        
                    await asyncio.sleep(0.1)
            
                await message.reply(
                    text=f"☁️ ارسال با موفقیت انجام شد.\n- موفق ها: {success}\n- ناموفق ها: {error}\n کل: {await self.database.get_users_count()}",
                    quote=True
                )
                
            elif get_arguments[0] == "banner_channel" and user_id in ADMINS:
                channel_id = message.text
                
                if not channel_id.startswith("-100"):
                    channel_id = f"-100{channel_id}"
                
                try:
                    channel_id = int(channel_id)
                except:
                    return await message.reply(
                        text="☁️ آیدی عددی کانال اشتباه می باشد.",
                        quote=True
                    )
                
                try:
                    get_chat_member = await self.client.get_chat_member(channel_id, self.client.me.id)
                    
                    if get_chat_member.status != ChatMemberStatus.ADMINISTRATOR:
                        raise Exception()
                except:
                    return await message.reply(
                        text="☁️ ربات داخل کانال ادمین نمی باشد.",
                        quote=True
                    )
                    
                await self.database.update_setting(self.setting, banner_channel=channel_id)
                
                await message.reply(
                    text=f"☁️ کانال بنر را برای ارسال بنر های ساخته شده ارسال کنید.\n➖ کانال کنونی: {self.setting.banner_channel}",
                    quote=True
                )
                
            elif get_arguments[0] == "gifts":
                split_lines = message.text.splitlines()
                
                if len(split_lines) != 4:
                    return await message.reply(
                        text="☁️ فرمت ارسال شده اشتباه می باشد.",
                        quote=True
                    )
                elif not split_lines[1].isnumeric() or not split_lines[2].isnumeric() or not split_lines[3].isnumeric():
                    return await message.reply(
                        text="☁️ هدایا باید عدد باشند.",
                        quote=True
                    )
                    
                get_banner = await self.database.get_banner(tag=split_lines[0])
                
                if not get_banner:
                    return await message.reply(
                        text="☁️ تگ اشتباه می باشد.",
                        quote=True
                    )
                    
                await self.database.update_banner(get_banner, gifts="-".join(split_lines[1:]))
                
                gifts_text = ""
                gifts = get_banner.gifts.split("-")
                
                for gift in gifts:
                    gifts_text += f"{gift:,} تومان\n"
                
                await self.database.update_user(get_user, step="gifts")
                await message.reply(
                    text=f"☁️ هدایا تنظیم شدند.\n➖ هدایای کنونی:\n\n<b>{gifts_text}</b>",
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "least_withdraw":
                try:
                    value = int(message.text)
                    
                    if value < 0:
                        raise Exception()
                except:
                    return await message.reply(
                        text="☁️ مقدار اشتباه می باشد.",
                        quote=True
                    )
                
                await self.database.update_setting(self.setting, least_withdraw=value)
                
                await message.reply(
                    text=f"💵 مقدار تنظیم شد.\n➖ مقدار کنونی: {self.setting.least_withdraw:,} تومان",
                    quote=True
                )
                
            elif get_arguments[0] == "starttext":
                await self.database.update_setting(self.setting, start=message.text)
                
                await message.reply(
                    text=f"☁️ متن تنظیم شد.\n➖ متن کنونی: {self.setting.start}",
                    quote=True
                )
                
            elif get_arguments[0] == "user_info" and await self.is_admin(user_id, "user_info"):
                arg_user_id = False

                if message.text.isnumeric():
                    arg_user_id = int(message.text)
                elif message.text.startswith("@"):
                    try:
                        get_users = await self.client.get_users(message.text)
                        user_id = get_users.id
                    except:
                        pass
            
                if not arg_user_id:
                    return await message.reply(
                        text="☁️ فرمت ارسال شده اشتباه می باشد..",
                        quote=True
                    )

                get_input_user = await self.database.get_user(user_id=arg_user_id)
                
                if not get_input_user:
                    return await message.reply(
                        text="☁️ این کاربر وجود ندارد.",
                        quote=True
                    )
                    
                if not get_input_user.bank:
                    bank = "<b>ثبت نکرده اید</b>"
                else:
                    bank_structure = get_input_user.bank.splitlines()
                    bank = f"""
<b>• شماره شبا:</b> <code>{bank_structure[0]}</code>
<b>• شماره کارت:</b> <code>{bank_structure[1]}</code>
<b>• صاحب حساب: {bank_structure[2]}</b>"""
                
                if not get_input_user.wallet_trc20:
                    wallet_trc20 = "<b>ثبت نکرده اید</b>"
                else:
                    wallet_trc20 = f"<code>{get_input_user.wallet_trc20}</code>"
                
                if not get_input_user.wallet_ton:
                    wallet_ton = "<b>ثبت نکرده اید</b>"
                else:
                    wallet_ton = f"<code>{get_input_user.wallet_ton}</code>"
                
                not_done = 0
                async for seen in self.database.get_seens(user_id=get_input_user.user_id, status=0):
                    get_banner = await self.database.get_banner(tag=seen.banner_tag)

                    if not get_banner:
                        continue

                    not_done += round(((seen.all_count + seen.count) / 1000) * get_banner.s1000)

                markup = InlineKeyboardMarkup(
                    [
                        [
                            InlineKeyboardButton("✉️ پیام به کاربر", callback_data=f"admin_message|{get_input_user.user_id}")
                        ]
                    ]
                )

                await message.reply(
                    text=f"""🔖 اطلاعات حساب کاربر به شرح زیر می باشد:

👤 آیدی عددی حساب: <code>{get_input_user.user_id}</code>

🎗 بنر ها: <b>{await self.database.get_seens_count(user_id=get_input_user.user_id)}</b>
🗒 برداشت ها: <b>{await self.database.get_withdraw_histories_count(user_id=get_input_user.user_id)}</b>

✔️ سین کل: <b>{await self.database.get_all_seens_count(user_id=get_input_user.user_id):,}</b>
💵 درآمد درحال حسابرسی: <b>{not_done:,} تومان</b>

💰 موجودی فعلی: <b>{get_input_user.current_balance:,} تومان</b>
💸 مقدار برداشت شده: <b>{get_input_user.all_balance - get_input_user.current_balance:,} تومان</b>
💵 مقدار کل: <b>{get_input_user.all_balance:,} تومان</b>

⚡️ آدرس ولت TRC20: {wallet_trc20}
⚡️ آدرس ولت TON: {wallet_ton}
🏦 مشخصات بانکی: {bank}

🗓 تاریخ عضویت: <b>{self.jalali_date(get_input_user.start_date)}</b>

🤖 <b>@{self.client.me.username}</b>""",
                    quote=True
                )
                
                async for channel in self.database.get_channels(user_id=get_input_user.user_id, verify=True):
                    await asyncio.sleep(0.5)

                    markup = InlineKeyboardMarkup(
                        [
                            [
                                InlineKeyboardButton(text='❌ حذف', callback_data=f"admin_delete_channel|{channel.tag}|normal")
                            ]
                        ]
                    )
                        
                    try:
                        get_chat = await self.client.get_chat(channel.chat_id)
                        title = get_chat.title
                        link = await self.client.export_chat_invite_link(channel.chat_id)
                        
                        text = f"🧾 نام کانال: <b>{escape(title)}</b>\n🔗 لینک کانال: {link}\n🔖 نوع کانال: <b>{self.channel_type(channel.channel_type)}</b>"
                    except ChatAdminRequired:
                        text = "❌ <b>ربات</b> در کانال <b>ادمین</b> نمی باشد."
                    except ChannelPrivate:
                        text = "❌ کانال <b>خصوصی</b> می باشد."
                    except:
                        text = "❌ مشکل <b>ناشناخته</b> ای <b>رخ</b> داد."

                    try:
                        await message.reply(
                            text=f"💡 آیدی کانال: <code>{channel.chat_id}</code>\n{text}",
                            reply_markup=markup
                        )
                    except:
                        pass
                    
            elif get_arguments[0] == "show_banner" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=message.text)
                
                if not get_banner:
                    return await message.reply(
                        text="☁️ بنر اشتباه می باشد.",
                        quote=True
                    )
                    
                elif get_banner.status != 0:
                    return await message.reply(
                        text="☁️ این بنر حسابرسی شده است.",
                        quote=True
                    )
                    
                    
                if get_banner.banner_limit == 0:
                    banner_limit = "نامحدود"
                else:
                    banner_limit = f"{get_banner.banner_limit:,}"
            
                get_seens = await self.database.get_all_seens_count(banner_tag=get_banner.tag)
                
                if get_banner.banner_end == 1:
                    banner_count = f"➿ ظرفیت: <b>{get_banner.count:,}</b>"
                    banner_left = f"<b>{get_banner.count - get_seens:,}</b>"
                else:
                    banner_count = f"🕐 زمان: <b>{get_banner.count:,} روز</b>"
                    banner_left = f"<b>{(get_banner.count - (self.timestamp - get_banner.date) // 86400):,} روز</b>"
                    
                if get_banner.banner_limit == 0 or await self.database.get_seens_count(banner_tag=get_banner.tag) < get_banner.banner_limit:
                    status = "✅"
                else:
                    status = "❌"
                        
                await self.database.update_user(get_user, step=f"edit_banner|{get_banner.tag}")
                await message.reply(
                    text=f"""💡 مشخصات بنر به شرح زیر می باشد:

🕯 نام: <b>{escape(get_banner.banner_name)}</b>

🌀 محدودیت بنر: <b>{banner_limit}</b>
🔖 نوع کانال: <b>{' - '.join(list(map(lambda x: self.channel_type(x), self.decode(get_banner.channel_type))))}</b>

{banner_count}
✔️ سین کل: <b>{get_seens:,}</b>
〰️ باقی مانده: {banner_left}

💵 نرخ 1000 سین: <b>{get_banner.s1000:,} تومان</b>
💰 درآمد کل: <b>{round((get_seens / 1000) * get_banner.s1000):,} تومان</b>

⚜️ قابل دریافت: {status}
📆 تاریخ ساخت: <b>{self.jalali_date(get_banner.date)}</b>

⛏️ دسترسی تغییر وضعیت: <b>{'🟢 فعال' if not get_banner.disable_access else '🔴 غیرفعال'}</b>

〽️ توضیحات: <b>{get_banner.description}</b>""",
                    reply_markup=Buttons.edit_banner,
                    quote=True
                )
             
            elif get_arguments[0] == "add_reshot" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=get_arguments[1], status=0)
                
                if not get_banner:
                    await self.database.update_user(get_user, step="admin")
                    return await message.reply(
                        text="📸 <b>بنر</b> برای <b>ریشات</b> وجود ندارد.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                
                if get_arguments[2] != "time":
                    try:
                        value = int(message.text)
                    except:
                        return await message.reply(
                            text="📸 مقدار دقیقه اشتباه می باشد.",
                            quote=True
                        )

                    if get_arguments[2] == "normal":
                        date = self.timestamp + (value * 60)
                        stype = 1
                        schedule_text = self.jalali_date(date)
                        
                    else:
                        date = value
                        stype = 2
                        schedule_text = f"هر {value:,} دقیقه"
                else:
                    if not re.match(r"^\d\d:\d\d$", message.text):
                        return await message.reply(
                            text="📸 زمان اشتباه می باشد.",
                            quote=True
                        )

                    date = schedule_text = message.text
                    stype = 3 if get_arguments[3] == "normal" else 4

                await self.database.add_schedule(tag=self.string_generator(), banner_tag=get_banner.tag, date=date, stype=stype)
                await self.database.update_user(get_user, step="admin")

                await message.reply(
                    text=f"📸 یک <b>ریشات</b> برای <b>{schedule_text}</b> به بنر <b>{escape(get_banner.banner_name)}</b> اضافه شد.",
                    reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                    quote=True
                )
                
                buttons = []
            
                async for schedule in self.database.get_schedules(banner_tag=get_banner.tag, status=0):
                    buttons.append(
                        [
                            InlineKeyboardButton(self.schedule_text(schedule.date, schedule.stype, True), callback_data=f"schedule|{schedule.tag}|normal")
                        ]
                    )
            
                buttons.append(
                    [
                        InlineKeyboardButton("➕ اضافه کردن", callback_data=f"reshot|{get_banner.tag}|add")
                    ]
                )
            
                buttons.append(
                    [
                        InlineKeyboardButton("🔙 بازگشت", callback_data="reshots|normal")
                    ]
                )

                markup = InlineKeyboardMarkup(buttons)

                await message.reply(
                    text=f"📸 <b>زمان ریشات</b> خود را برای بنر <b>{get_banner.banner_name}</b> انتخاب کنید یا <b>زمان جدیدی</b> اضافه کنید.",
                    reply_markup=markup
                )

            elif get_arguments[0] == "edit_banner" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=get_arguments[1])
                
                if not get_banner:
                    await self.database.update_user(get_user, step="admin")
                    return await message.reply(
                        text="☁️ بنر اشتباه می باشد.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                    
                elif get_banner.status != 0:
                    await self.database.update_user(get_user, step="admin")
                    return await message.reply(
                        text="☁️ این بنر حسابرسی شده است.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                    
                if message.text == "💡 تغییر بنر":
                    await self.database.update_user(get_user, step=f"edit_banner_value|{get_banner.tag}|id")
                    await message.reply(
                        text="☁️ بنر جدید را برای این بنر ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "📊 گروه آمار":
                    await self.database.update_user(get_user, step=f"edit_banner_value|{get_banner.tag}|stats_group")
                    await message.reply(
                        text="☁️ گروه آمار خود را به صورت آیدی عددی ارسال کنید و اگر به آن دسترسی ندارید یک پیام از گروه فوروارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "➿ تغییر ظرفیت/زمان":
                    await self.database.update_user(get_user, step=f"edit_banner_value|{get_banner.tag}|count")
                    await message.reply(
                        text="☁️ ظرفیت/زمان جدید را برای این بنر ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "🌀 تغییر محدودیت":
                    await self.database.update_user(get_user, step=f"edit_banner_value|{get_banner.tag}|limit")
                    await message.reply(
                        text="☁️ محدودیت جدید را برای این بنر ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "💵 تغییر قیمت":
                    await self.database.update_user(get_user, step=f"edit_banner_value|{get_banner.tag}|s1000")
                    await message.reply(
                        text="☁️ نرخ 1000 سین جدید را برای این بنر ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                    
                elif message.text == "⛏️ دسترسی تغییر وضعیت":
                    if get_banner.disable_access:
                        await self.database.update_banner(get_banner, disable_access=False)
                        await message.reply(
                            text=f"⛏️ دسترسی تغییر وضعیت برای دانر ها غیرفعال شد.",
                            quote=True
                        )
                    else:
                        await self.database.update_banner(get_banner, disable_access=True)
                        await message.reply(
                            text=f"⛏️ دسترسی تغییر وضعیت برای دانر ها فعال شد.",
                            quote=True
                        )
                    
                elif message.text == "🔗 آمار":
                    text = ""
                    
                    async for seen in self.database.get_group_seens2(banner_tag=get_banner.tag):
                        try:
                            get_users = await self.client.get_users(seen.user_id)
                            full_name = get_users.full_name
                        except:
                            full_name = seen.user_id

                        get_seens = await self.database.get_all_seens_count(user_id=seen.user_id, banner_tag=get_banner.tag)

                        text += f"""👤 نام کاربر: <b>{full_name}</b>
〰️ تعداد سین ها: <b>{get_seens:,}</b>
💵 درآمد: <b>{round((get_seens / 1000) * get_banner.s1000):,} تومان</b>\n\n"""
                    
                    await message.reply(
                        text=f"💡 آمار این بنر به شرح زیر می باشد:\n\n{text}",
                        quote=True,
                        link_preview_options=LinkPreviewOptions(is_disabled=True)
                    )
                     
            elif get_arguments[0] == "edit_banner_value" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=get_arguments[1])
                
                if not get_banner:
                    await self.database.update_user(get_user, step="admin")
                    return await message.reply(
                        text="☁️ بنر اشتباه می باشد.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                    
                elif get_banner.status != 0:
                    await self.database.update_user(get_user, step="show_banner")
                    return await message.reply(
                        text="☁️ این بنر حسابرسی شده است.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                
                if get_arguments[2] == "id":
                    try:
                        sent_message = await self.client.forward_messages(
                            chat_id=self.setting.banner_channel,
                            from_chat_id=user_id,
                            message_ids=message.id
                        )
                    except:
                        return await message.reply(
                            text="☁️ ربات در کانال بنر ادمین نیست.",
                            quote=True
                        )
                    
                    await self.database.update_banner(get_banner, msg_id=sent_message.id)
                        
                elif get_arguments[2] == "stats_group":
                    if cid_match := re.match(r"(?:-100)?([0-9]+)", message.text):
                        chat_id = int(f"-100{cid_match.group(1)}")
                        
                    elif message.forward_origin and message.forward_origin.type == MessageOriginType.CHANNEL:
                        chat_id = message.forward_origin.chat.id
                    
                    else:
                        return await message.reply(
                            text="☁️ گروه باید خصوصی باشد.",
                            quote=True
                        )
                        
                    try:
                        sent_message = await self.client.forward_messages(
                            chat_id=chat_id,
                            from_chat_id=user_id,
                            message_ids=get_banner.msg_id
                        )
                    except:
                        return await message.reply(
                            text="☁️ ربات در گروه ادمین نیست.",
                            quote=True
                        )
                    
                    await self.database.update_banner(get_banner, stats_group=chat_id)
                        
                else:
                    try:
                        value = int(message.text)
                        
                        if get_arguments[2] == "limit":
                            if value < 0:
                                raise Exception()
                        else:
                            if value <= 0:
                                raise Exception()
                    except:
                        return await message.reply(
                            text="☁️ مقدار اشتباه می باشد.",
                            quote=True
                        )
                    
                    if get_arguments[2] == "count":
                        if get_banner.banner_end == 1:
                            current_value = await self.database.get_all_seens_count(banner_tag=get_banner.tag)
                        else:
                            current_value = (self.timestamp - get_banner.date) / 86400
                        
                        if value <= current_value:
                            return await message.reply(
                                text="☁️ ظرفیت جدید نباید کمتر از مقدار پر شده ی این بنر باشد.",
                                quote=True
                            )
                            
                        await self.database.update_banner(get_banner, count=value)
                        
                    elif get_arguments[2] == "limit":
                        if value > 0 and value <= await self.database.get_seens_count(banner_tag=get_banner.tag):
                            return await message.reply(
                                text="☁️ محدودیت جدید نباید کمتر از مقدار دریافت شده ی این تبلیع باشد.",
                                quote=True
                            )
                            
                        await self.database.update_banner(get_banner, banner_limit=value)
                        
                    else:
                        await self.database.update_banner(get_banner, s1000=value)
                    
                if get_banner.banner_limit == 0:
                    banner_limit = "نامحدود"
                else:
                    banner_limit = f"{get_banner.banner_limit:,}"
                
                get_seens = await self.database.get_all_seens_count(banner_tag=get_banner.tag)
                
                if get_banner.banner_end == 1:
                    banner_count = f"➿ ظرفیت: <b>{get_banner.count:,}</b>"
                    banner_left = f"<b>{get_banner.count - get_seens:,}</b>"
                else:
                    banner_count = f"🕐 زمان: <b>{get_banner.count:,} روز</b>"
                    banner_left = f"<b>{(get_banner.count - (self.timestamp - get_banner.date) // 86400):,} روز</b>"
                    
                if get_banner.banner_limit == 0 or await self.database.get_seens_count(banner_tag=get_banner.tag) < get_banner.banner_limit:
                    status = "✅"
                else:
                    status = "❌"
                        
                await self.database.update_user(get_user, step=f"edit_banner|{get_banner.tag}")
                await message.reply(
                    text=f"""💡 مقدار جدید با موفقیت ثبت شد.

🕯 نام: <b>{escape(get_banner.banner_name)}</b>

🌀 محدودیت بنر: <b>{banner_limit}</b>
🔖 نوع کانال: <b>{' - '.join(list(map(lambda x: self.channel_type(x), self.decode(get_banner.channel_type))))}</b>

{banner_count}
✔️ سین کل: <b>{get_seens:,}</b>
〰️ باقی مانده: {banner_left}

💵 نرخ 1000 سین: <b>{get_banner.s1000:,} تومان</b>
💰 درآمد کل: <b>{round((get_seens / 1000) * get_banner.s1000):,} تومان</b>

⚜️ قابل دریافت: {status}
📆 تاریخ ساخت: <b>{self.jalali_date(get_banner.date)}</b>

〽️ توضیحات: <b>{get_banner.description}</b>""",
                    reply_markup=Buttons.edit_banner,
                    quote=True
                )
                    
            elif get_arguments[0] == "done_banner" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=message.text)
                
                if not get_banner:
                    return await message.reply(
                        text="☁️ بنر اشتباه می باشد.",
                        quote=True
                    )
                    
                elif get_banner.status != 0:
                    return await message.reply(
                        text="☁️ این بنر حسابرسی شده است.",
                        quote=True
                    )
                    
                sent_message = await message.reply(
                    text="☁️ درحال حسابرسی بنر ...",
                    quote=True
                )
                
                await self.database.update_banner(get_banner, status=1)
                await self.database.delete_schedules(get_banner.tag)
                
                await self._do_update_banners(get_banner.tag)
                await self.done_banner(get_banner, await self.database.get_all_seens_count(banner_tag=get_banner.tag))
                
                await sent_message.edit_text(
                    text="☁️ بنر حسابرسی شد."
                )
                
            elif get_arguments[0] == "delete_banner" and await self.is_admin(user_id, "banner"):
                get_banner = await self.database.get_banner(tag=message.text)
                
                if not get_banner:
                    return await message.reply(
                        text="☁️ بنر اشتباه می باشد.",
                        quote=True
                    )
                    
                sent_message = await message.reply(
                    text="☁️ درحال حذف بنر ...",
                    quote=True
                )
                
                try:
                    await self.client.delete_messages(
                        chat_id=self.setting.banner_channel,
                        message_ids=get_banner.msg_id
                    )
                except:
                    pass
                
                await self.database.delete_seens(get_banner.tag)
                await self.database.delete_banner(get_banner.id)
                
                await sent_message.edit_text(
                    text="☁️ بنر با موفقیت حذف شد."
                )
                
            elif get_arguments[0] == "add_banner" and await self.is_admin(user_id, "banner"):
                await self.database.update_user(get_user, step=f"banner_name|{message.id}")
                await message.reply(
                    text="☁️ نام بنر را ارسال کنید.",
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_name" and await self.is_admin(user_id, "banner"):
                if "|" in message.text or len(message.text.splitlines()) > 1 or len(message.text) > 25:
                    return await message.reply(
                        text="☁️ از نماد | یا خط بعد یا بیشتر از 25 کاراکتر در نام استفاده نکنید.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"banner_limit|{get_arguments[1]}|{message.text}")
                await message.reply(
                    text="☁️ محدودیت بنر را ارسال کنید، در صورتی که میخواهید بدون محدودیت باشد عدد 0 را ارسال کنید.",
                    reply_markup=Buttons.back,
                    quote=True
                )

            elif get_arguments[0] == "banner_limit" and await self.is_admin(user_id, "banner"):
                try:
                    banner_limit = int(message.text)
                except:
                    return await message.reply(
                        text="☁️ ظرفیت اشتباه می باشد.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"banner_end|{get_arguments[1]}|{get_arguments[2]}|{banner_limit}")
                await message.reply(
                    text="☁️ پایان بنر را انتخاب کنید.",
                    reply_markup=Buttons.banner_end,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_end" and await self.is_admin(user_id, "banner"):
                if message.text == "👤 تعدادی":
                    banner_end = 1
                    text = "☁️ ظرفیت بنر را ارسال کنید."
                elif message.text == "🕐 زمانی":
                    banner_end = 2
                    text = "☁️ تعداد روز های بنر را ارسال کنید."
                else:
                    return await message.reply(
                        text="☁️ پایان بنر اشتباه می باشد.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"banner_count|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{banner_end}")
                await message.reply(
                    text=text,
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_count" and await self.is_admin(user_id, "banner"):
                try:
                    banner_count = int(message.text)
                    
                    if banner_count <= 0:
                        raise Exception()
                except:
                    return await message.reply(
                        text="☁️ ظرفیت اشتباه می باشد.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"banner_1000|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{banner_count}")
                await message.reply(
                    text="☁️ نرخ هر هزار سین را ارسال کنید.",
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_1000" and await self.is_admin(user_id, "banner"):
                try:
                    banner_1000 = int(message.text)
                except:
                    return await message.reply(
                        text="☁️ ظرفیت اشتباه می باشد.",
                        quote=True
                    )
                    
                await self.database.update_user(get_user, step=f"banner_channel_type|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{banner_1000}|[]")
                await message.reply(
                    text="☁️ نوع مجاز کانال را ارسال کنید.\n➿ کانال های مجاز: ()",
                    reply_markup=Buttons.channel_type,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_channel_type" and await self.is_admin(user_id, "banner"):
                channel_types = self.decode(get_arguments[7])

                if message.text == "✅ تایید":
                    if not channel_types:
                        return await message.reply(
                            text="☁️ هیچ کانال مجازی انتخاب نکرده اید.",
                            quote=True
                        )

                    await self.database.update_user(get_user, step=f"banner_group_stats|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}|{self.encode(channel_types)}")
                    await message.reply(
                        text="☁️ گروه آمار خود را به صورت آیدی عددی ارسال کنید و اگر به آن دسترسی ندارید یک پیام از گروه فوروارد کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )

                    return

                
                if message.text == "➿ همه":
                    channel_types = [1, 2, 3, 4]
                else:
                    if message.text == "➿ چنل وطنی":
                        channel_type = 1
                    elif message.text == "➿ چنل اونلی فنز":
                        channel_type = 2
                    elif message.text == "➿ چنل اخلاقی":
                        channel_type = 3
                    elif message.text == "➿ چنل زیرنویس":
                        channel_type = 4
                    else:
                        return await message.reply(
                            text='☁️ <b>نوع کانال</b> انتخاب شده <b>اشتباه</b> می باشد.',
                            quote=True
                        )
                    
                    if channel_type in channel_types:
                        channel_types.remove(channel_type)
                    else:
                        channel_types.append(channel_type)

                await self.database.update_user(get_user, step=f"banner_channel_type|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}|{self.encode(channel_types)}")
                channel_types = ' - '.join(list(map(lambda x: self.channel_type(x), channel_types)))
                await message.reply(
                    text=f"☁️ نوع مجاز کانال را ارسال کنید.\n➿ کانال های مجاز: ({channel_types})",
                    quote=True
                )
            
            elif get_arguments[0] == "banner_group_stats" and await self.is_admin(user_id, "banner"):
                if cid_match := re.match(r"(?:-100)?([0-9]+)", message.text):
                    chat_id = int(f"-100{cid_match.group(1)}")
                    
                elif message.forward_origin and message.forward_origin.type == MessageOriginType.CHANNEL:
                    chat_id = message.forward_origin.chat.id
                
                else:
                    return await message.reply(
                        text="☁️ گروه باید خصوصی باشد.",
                        quote=True
                    )
                    

                try:
                    sent_message = await self.client.forward_messages(
                        chat_id=chat_id,
                        from_chat_id=user_id,
                        message_ids=int(get_arguments[1])
                    )
                except:
                    return await message.reply(
                        text="☁️ ربات در گروه ادمین نیست.",
                        quote=True
                    )
                
                await self.database.update_user(get_user, step=f"banner_description|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}|{get_arguments[7]}|{chat_id}")
                await message.reply(
                    text="☁️ توضیحات بنر را ارسال کنید.",
                    reply_markup=Buttons.back,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_description" and await self.is_admin(user_id, "banner"):
                if "|" in message.text:
                    return await message.reply(
                        text="☁️ از نماد | در توضیحات استفاده نکنید.",
                        quote=True
                    )
                
                if get_arguments[3] == "0":
                    banner_limit = "نامحدود"
                else:
                    banner_limit = f"{int(get_arguments[3]):,}"
                    
                if get_arguments[4] == "1":
                    banner_count = f"➿ ظرفیت: <b>{int(get_arguments[5]):,}</b>"
                else:
                    banner_count = f"🕐 زمان: <b>{int(get_arguments[5]):,} روز</b>"
                    
                await self.database.update_user(get_user, step=f"banner_confirm|{get_arguments[1]}|{get_arguments[2]}|{get_arguments[3]}|{get_arguments[4]}|{get_arguments[5]}|{get_arguments[6]}|{get_arguments[7]}|{get_arguments[8]}|{message.text}")
                
                try:
                    sent_message = await self.client.forward_messages(
                        chat_id=user_id,
                        from_chat_id=user_id,
                        message_ids=int(get_arguments[1])
                    )
                except:
                    pass
                
                await sent_message.reply(
                    text=f"""☁️ بنر خود را تایید کنید:

🕯 نام: <b>{escape(get_arguments[2])}</b>

🌀 محدودیت بنر: <b>{banner_limit}</b>
🔖 نوع کانال: <b>{' - '.join(list(map(lambda x: self.channel_type(x), self.decode(get_arguments[7]))))}</b>

{banner_count}
💵 نرخ هر 1000 سین: <b>{int(get_arguments[6]):,} تومان</b>

〽️ توضیحات: <b>{message.text}</b>""",
                    reply_markup=Buttons.confirm,
                    quote=True
                )
                
            elif get_arguments[0] == "banner_confirm" and await self.is_admin(user_id, "banner"):
                if message.text != "✅ تایید":
                    return
                
                tag = self.string_generator()
                
                if get_arguments[3] == "0":
                    banner_limit = "نامحدود"
                else:
                    banner_limit = f"{int(get_arguments[3]):,}"
                    
                if get_arguments[4] == "1":
                    banner_count = f"➿ ظرفیت: <b>{int(get_arguments[5]):,}</b>"
                else:
                    banner_count = f"🕐 زمان: <b>{int(get_arguments[5]):,} روز</b>"
                    
                try:
                    sent_message = await self.client.forward_messages(
                        chat_id=self.setting.banner_channel,
                        from_chat_id=user_id,
                        message_ids=int(get_arguments[1])
                    )
                except:
                    return await message.reply(
                        text="☁️ ربات در کانال بنر ادمین نیست.",
                        quote=True
                    )

                await self.database.add_banner(tag=tag, banner_name=get_arguments[2], banner_limit=int(get_arguments[3]), banner_end=int(get_arguments[4]), count=int(get_arguments[5]), s1000=int(get_arguments[6]), channel_type=get_arguments[7], description=get_arguments[9], stats_group=int(get_arguments[8]), msg_id=sent_message.id, last_send=self.timestamp, date=self.timestamp)
                await self.database.update_user(get_user, step="admin")
                
                await message.reply(
                    text=f"☁️ بنر با شناسه ی <code>{tag}</code> اضافه شد.",
                    reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                    quote=True
                )
                
            elif get_arguments[0] == "wallet_hash":
                get_withdraw = await self.database.get_withdraw(user_id=int(get_arguments[1]))
                
                await self.database.update_user(get_user, step="admin")
                    
                if not get_withdraw:
                    await message.reply(
                        text="💳 این درخواست دیگر وجود ندارد.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                else:
                    get_arg_user = await self.database.get_user(user_id=get_withdraw.user_id)
                    await self.database.update_user(get_arg_user, current_balance=get_arg_user.current_balance - get_withdraw.amount)
                    
                    try:
                        await self.client.send_message(
                            chat_id=get_withdraw.user_id,
                            text=f"🟢 درخواست برداشت شما توسط ادمین تایید شد.\n\n• {message.text}"
                        )
                    except:
                        pass
                    
                    await self.database.add_withdraw_history(user_id=get_arg_user.user_id, amount=get_withdraw.amount, date=self.timestamp)
                    await self.database.delete_withdraw(get_withdraw.id)
                    
                    await message.reply(
                        text="💳 درخواست برداشت این کاربر تایید شد و فیش نیز برای کاربر ارسال شد.",
                        reply_markup=Buttons.admin(user_id, await self.admin_rights(user_id)),
                        quote=True
                    )
                
            elif get_arguments[0] == "admins":
                if message.text not in ["❕ مشاهده", "➕ اضافه کردن", "➖ حذف کردن"]:
                    await message.reply(
                        text="🔑 گزینه انتخاب شده اشتباه می باشد.",
                        quote=True
                    )
                
                elif message.text == "❕ مشاهده":
                    async for admin in self.database.get_admins():
                        text = f"<code>{admin.user_id}</code>"
                                
                        try:
                            get_users = await self.client.get_users(admin.user_id)
                            text += f" - <b>{get_users.full_name}</b>"
                        except:
                            pass
                        
                        admin_rights = self.decode(admin.rights)
                        
                        rights_list = {
                            "statistic": "📊 آمار",
                            "send_all": "🔖 ارسال همگانی",
                            "send_user_pm": "✉️ پیام به کاربر",
                            "edit_balance": "💵 افزایش موجودی",
                            "banner": "⭐️ بنر",
                            "invoices": "✨ تسویه ها",
                            "user_info": "👤 مشخصات کاربر",
                            "users": "🌵 کاربران",
                            "ban_user": "🍁 اخراج کاربر",
                            "extract": "📮 استخراج",
                            "support": "🧑🏻‍💻 پشتیبانی",
                            "bot_settings": "🤖 تنظیمات ربات"
                        }
                        
                        buttons = []
                        for right_key, right_name in rights_list.items():
                            emoji = "✅" if right_key in admin_rights else "❌"
                            buttons.append([
                                InlineKeyboardButton(emoji, callback_data=f"right|{right_key}|{admin.user_id}"),
                                InlineKeyboardButton(right_name, callback_data=f"right|{right_key}|{admin.user_id}")
                            ])
                        
                        buttons.append([
                            InlineKeyboardButton("🔙 بازگشت به پنل", callback_data="back_to_admin_panel")
                        ])
                        
                        markup = InlineKeyboardMarkup(buttons)
                        
                        await message.reply(
                            text=f"🔑 ادمین {text}:",
                            reply_markup=markup,
                            quote=True
                        )
                
                elif message.text == "➕ اضافه کردن":
                    await self.database.update_user(get_user, step="add_admin")
                    await message.reply(
                        text="🔑 ادمین خود را برای اضافه ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif message.text == "➖ حذف کردن":
                    await self.database.update_user(get_user, step="delete_admin")
                    await message.reply(
                        text="🔑 ادمین خود را برای حذف کردن ارسال کنید.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
            elif get_arguments[0] == "add_admin":
                if await self.database.get_admin(user_id=message.text):
                    return await message.reply(
                        text="🔑 ادمینی با این آیدی وجود دارد.",
                        reply_markup=Buttons.back,
                        quote=True
                    )
                
                elif not message.text.isnumeric():
                    return await message.reply(
                        text="🔑 پارامتر ها اشتباه می باشد."
                    )
                
                await self.database.add_admin(user_id=message.text)
                await self.database.update_user(get_user, step="admins")
                
                await message.reply(
                    text=f"🔑 ادمین با موفقیت اضافه شد.\n• ادمین: <b>{message.text}</b>",
                    reply_markup=Buttons.options,
                    quote=True
                )
            
            elif get_arguments[0] == "delete_admin":
                get_admin = await self.database.get_admin(user_id=message.text)
                
                if not get_admin:
                    return await message.reply(
                        text="🔑 ادمینی با این آیدی وجود ندارد.",
                        quote=True
                    )
                
                await self.database.delete_admin(get_admin.id)
                await self.database.update_user(get_user, step="admins")

                await message.reply(
                    text=f"🔑 ادمین با موفقیت حذف شد.\n• ادمین: <b>{message.text}</b>",
                    reply_markup=Buttons.options,
                    quote=True
                )