[
  {
    "path": ".gitignore",
    "content": "/Database/hidyBot.db\n/Logs\n/Backup\n/UserBot/Receiptions\n/.idea\n/temp\n/Utils/swapWallet.py\n\n/.handler-saves\nhiddifypanel.db\nconfig.json\n\n*.pyc\n*.pyo!/qodana.yaml\nqodana.yaml\ncheck-host.py\n.vscode/launch.json\nDatabase/hidyBot1.db\n"
  },
  {
    "path": "AdminBot/Json/buttons.json",
    "content": "{\n  \"EN\": {\n    \"CONFIRM\": \"✅Confirm\",\n    \"CANCEL\": \"❌Cancel\",\n    \"BOT_USERS_MANAGEMENT\": \"👤Bot Users Management\",\n    \"USERS_LIST\": \"👤Bot Users List\",\n    \"SEARCH_USERS_BOT\": \"🔍Search Bot Users\",\n    \"ORDERS_MANAGEMENT\": \"📗Orders Management\",\n    \"ORDERS_LIST\": \"📗Orders List\",\n    \"SEARCH_ORDERS\": \"🔍Search Orders\",\n    \"PAYMENT_MANAGEMENT\": \"💵Payment Management\",\n    \"APPROVED_PAYMENTS_LIST\": \"✅Approved Payment List\",\n    \"NON_APPROVED_PAYMENTS_LIST\": \"🚫Non Approved Payment List\",\n    \"PENDING_PAYMENT_LIST\": \"⏳Pending Payment List\",\n    \"CARD_PAYMENT_LIST\": \"💳Card Payment List\",\n    \"DIGITAL_PAYMENT_LIST\": \"💸Digital Payment List\",\n    \"SEARCH_PAYMENTS\": \"🔍Search Payment\",\n    \"USER_SUB_LIST\": \"📋Subscriptions List\",\n    \"EDIT_WALLET\": \"💳Edit Wallet\",\n    \"PAYMENTS_LIST\": \"💵Payment List\",\n    \"GIFT_LIST\": \"🎁Gift List\",\n    \"REFERRED_LIST\": \"🎗Referred List\",\n    \"USERS_SEARCH\": \"🔍Search User\",\n    \"ADD_USER\": \"➕Add User\",\n    \"SERVER_BACKUP\": \"📥Panel Backup\",\n    \"SERVER_STATUS\": \"📈Server Status\",\n    \"USERS_BOT_MANAGEMENT\": \"🤖Users Bot Management\",\n    \"NEXT_PAGE\": \"➡️\",\n    \"PREV_PAGE\": \"⬅️\",\n    \"CONFIGS_USER\": \"Configs\",\n    \"EDIT_USER\": \"Edit User\",\n    \"DELETE_USER\": \"Delete User\",\n    \"EDIT_NAME\": \"👤Edit Name\",\n    \"EDIT_USAGE\": \"📊Edit Usage\",\n    \"RESET_USAGE\": \"🔄Reset Usage\",\n    \"EDIT_DAYS\": \"📆Edit Days\",\n    \"RESET_DAYS\": \"🔄Reset Days\",\n    \"EDIT_COMMENT\": \"📝Edit Comment\",\n    \"UPDATE_MESSAGE\": \"🔄Update Message\",\n    \"BACK\": \"🔙Back\",\n    \"CONFIGS_DIR\": \"Configs\",\n    \"CONFIGS_SUB_AUTO\": \"Auto Subscription\",\n    \"CONFIGS_SUB\": \"Subscription Link\",\n    \"CONFIGS_SUB_B64\": \"Subscription Link b64\",\n    \"CONFIGS_CLASH\": \"Clash Subscription\",\n    \"CONFIGS_HIDDIFY\": \"Hiddify Subscription\",\n    \"CONFIGS_SING_BOX\": \"Sing-box\",\n    \"CONFIGS_FULL_SING_BOX\": \"Full Sing-box\",\n    \"SEARCH_USER_NAME\": \"Search by Name\",\n    \"SEARCH_USER_TELEGRAM_ID\": \"Search by Telegram ID\",\n    \"SEARCH_USER_UUID\": \"Search by UUID\",\n    \"SEARCH_USER_CONFIG\": \"Search by Config\",\n    \"SEARCH_EXPIRED_USERS\": \"Expired Users List\",\n    \"USERS_BOT_ADD_PLAN\": \"➕Add Plan\",\n    \"USERS_BOT_DEL_PLAN\": \"➖Delete Plan\",\n    \"USERS_BOT_OWNER_INFO\": \"👤Owner Info\",\n    \"USERS_BOT_OWNER_INFO_EDIT\": \"👤Edit Owner Info\",\n    \"USERS_BOT_ORDERS_STATUS\": \"📈Payment Status\",\n    \"USERS_BOT_SUB_STATUS\": \"📈Subscription Status\",\n    \"USERS_BOT_OWNER_INFO_EDIT_CARD_NAME\": \"Edit Card Holder Name\",\n    \"USERS_BOT_OWNER_INFO_EDIT_CARD_NUMBER\": \"Edit Card Number\",\n    \"USERS_BOT_OWNER_INFO_EDIT_USERNAME\": \"Edit Support Username\",\n    \"USERS_BOT_SEND_MESSAGE_TO_USERS\": \"📩Send Message to Users\",\n    \"USERS_BOT_SETTINGS\": \"⚙️Settings\",\n    \"USERS_BOT_SETTINGS_SHOW_HIDI_LINK\": \"User Page Hyperlink\",\n    \"USERS_BOT_SETTINGS_SHOW_THREE_RAND\": \"Random 3 Digit Price\",\n    \"USERS_BOT_SETTINGS_MIN_DEPO\": \"Minimum Deposit\",\n    \"USERS_BOT_SETTINGS_PNL_V8_FEATURES\": \"Panel V8 Features\",\n    \"USERS_BOT_SETTINGS_CHANNEL_ID\": \"Support Channel\",\n    \"USERS_BOT_SETTINGS_CHANNEL_ّFORCE_JOIN\": \"Force Join\",\n    \"USERS_BOT_SETTINGS_VISIBLE_SUBS\": \"Visible Subscriptions\",\n    \"USERS_BOT_SETTINGS_SET_WELCOME_MSG\": \"Welcome Message\",\n    \"USERS_BOT_SETTINGS_SET_FAQ_MSG\": \"ّFAQ\",\n    \"USERS_BOT_SETTINGS_SET_FAQ_MESSAGE\": \"Set FAQ\",\n    \"USERS_BOT_SETTINGS_HIDE_FAQ\": \"❌Hide FAQ\",\n    \"USERS_BOT_SETTINGS_TEST_SUB\": \"Test Subscription\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_DAYS\": \"Test Subscription Days\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_SIZE\": \"Test Subscription Size\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER\": \"Subscription Reminder\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE\": \"Usage Reminder\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS\": \"Days Reminder\",\n    \"USERS_BOT_SETTINGS_PANEL_AUTO_BACKUP\": \"Auto Backup\",\n    \"USERS_BOT_SETTINGS_BOT_AUTO_BACKUP\": \"Bot Auto Backup\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL\": \"Manual\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_ANDROID\": \"Android Manual\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_IOS\": \"IOS Manual\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_WIN\": \"Windows Manual\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_MAC\": \"Mac Manual\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_LIN\": \"Linux Manual\",\n    \"USERS_BOT_SETTINGS_BACKUP_BOT\": \"Backup Bot\",\n    \"USERS_BOT_SETTINGS_RESTORE_BOT\": \"Restore Bot\",\n    \"USERS_BOT_SETTINGS_BUY_SUBSCRIPTION_STATUS\": \"Buy Subscription\",\n    \"USERS_BOT_SETTINGS_RENEWAL_SUBSCRIPTION_STATUS\": \"Renewal Subscription\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD\": \"Renewal Method\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_DEFAULT\": \"Default\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED\": \"Advanced\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_FAIRLY\": \"Fairly\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS\": \"Maximum Days for Renewal\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE\": \"Maximum Usage for Renewal\",\n    \"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT\": \"Reset free test limit\",\n    \"ABOUT_BOT\": \"ℹ️\",\n    \"TO_QR\": \"ً🖼QR\",\n    \"SUPPORT_GROUP\": \"Support Group\",\n    \"SERVERS_MANAGEMENT\":\"🖥Servers Management\",\n    \"ADD_SERVER\": \"➕Add Server\",\n    \"EDIT_SERVER\": \"Edit Server\",\n    \"DELETE_SERVER\": \"➖Delete Server\",\n    \"SERVER_LIST_OF_USERS\": \"👤Users List\",\n    \"SERVER_LIST_OF_PLANS\": \"Plans List\",\n    \"SERVER_EDIT_TITLE\": \"Edit title\",\n    \"SERVER_EDIT_USER_LIMIT\": \"Edit User Limit\",\n    \"SERVER_EDIT_URL\": \"Edit URL\",\n    \"CHANGE_STATUS_PAYMENT\": \"Change Payment Status\",\n    \"CONFIRM_PAYMENT\": \"✅Confirm Payment\",\n    \"NO\": \"❌No\",\n    \"YES\": \"✅Yes\",\n    \"ANSWER\": \"Answer\",\n    \"SEND_MESSAGE\": \"Send Message\",\n    \"DEBUG\":\"DEBUG\",\n    \"SKIP\":\"⏩Skip\",\n    \"RESET_TEST\":\"🔄Reset Test\",\n    \"BAN_USER\":\"🚫Ban User\"\n  },\n  \"FA\": {\n    \"CONFIRM\": \"✅تأیید\",\n    \"CANCEL\": \"❌لغو\",\n    \"BOT_USERS_MANAGEMENT\": \"👤مدیریت کاربران ربات\",\n    \"USERS_LIST\": \"👤لیست کاربران ربات\",\n    \"SEARCH_USERS_BOT\": \"🔍جستجوی کاربران ربات\",\n    \"ORDERS_MANAGEMENT\": \"📗مدیریت سفارشات\",\n    \"ORDERS_LIST\": \"📗لیست سفارشات\",\n    \"SEARCH_ORDERS\": \"🔍جستجوی سفارشات\",\n    \"PAYMENT_MANAGEMENT\": \"💵مدیریت تراکنشات\",\n    \"APPROVED_PAYMENTS_LIST\": \"✅لیست تراکنشات تایید شده\",\n    \"NON_APPROVED_PAYMENTS_LIST\": \"🚫لیست تراکنشات رد شده\",\n    \"PENDING_PAYMENT_LIST\": \"⏳لیست تراکنشات در انتظار\",\n    \"CARD_PAYMENT_LIST\": \"💳لیست تراکنشات کارت به کارت\",\n    \"DIGITAL_PAYMENT_LIST\": \"💸لیست تراکنشات دیجیتال\",\n    \"SEARCH_PAYMENTS\": \"🔍جستجوی تراکنش\",\n    \"USER_SUB_LIST\": \"📋لیست سرویس‌ها\",\n    \"EDIT_WALLET\": \"💳ویرایش کیف پول\",\n    \"PAYMENTS_LIST\": \"💵لیست تراکنشات\",\n    \"GIFT_LIST\": \"🎁لیست هدایا\",\n    \"REFERRED_LIST\": \"🎗لیست معرفی شده‌ها\",\n    \"USERS_SEARCH\": \"🔍جستجوی کاربر\",\n    \"ADD_USER\": \"➕افزودن کاربر\",\n    \"SERVER_BACKUP\": \"📥دریافت بکاپ\",\n    \"SERVER_STATUS\": \"📈وضعیت سرور\",\n    \"USERS_BOT_MANAGEMENT\": \"🤖مدیریت ربات کاربران\",\n    \"NEXT_PAGE\": \"➡️\",\n    \"PREV_PAGE\": \"⬅️\",\n    \"CONFIGS_USER\": \"کانفیگ ها\",\n    \"EDIT_USER\": \"ویرایش کاربر\",\n    \"DELETE_USER\": \"حذف کاربر\",\n    \"EDIT_NAME\": \"👤ویرایش نام\",\n    \"EDIT_USAGE\": \"📊ویرایش حجم\",\n    \"RESET_USAGE\": \"🔄بازنشانی حجم\",\n    \"EDIT_DAYS\": \"📆ویرایش مدت\",\n    \"RESET_DAYS\": \"🔄بازنشانی مدت\",\n    \"EDIT_COMMENT\": \"📝ویرایش یادداشت\",\n    \"UPDATE_MESSAGE\": \"🔄به‌روزرسانی پیام\",\n    \"BACK\": \"🔙بازگشت\",\n    \"CONFIGS_DIR\": \"کانفیگ مستقیم\",\n    \"CONFIGS_SUB_AUTO\": \"اشتراک خودکار\",\n    \"CONFIGS_SUB\": \"لینک اشتراک\",\n    \"CONFIGS_SUB_B64\": \"لینک اشتراک b64\",\n    \"CONFIGS_CLASH\": \"اشتراک Clash\",\n    \"CONFIGS_HIDDIFY\": \"اشتراک Hiddify\",\n    \"CONFIGS_SING_BOX\": \"Sing-box\",\n    \"CONFIGS_FULL_SING_BOX\": \"Full Sing-box\",\n    \"SEARCH_USER_NAME\": \"جستجو با نام\",\n    \"SEARCH_USER_TELEGRAM_ID\": \"جستجو با Telegram ID\",\n    \"SEARCH_USER_UUID\": \"جستجو با UUID\",\n    \"SEARCH_USER_CONFIG\": \"جستجو با کانفیگ\",\n    \"SEARCH_EXPIRED_USERS\": \"لیست کاربران منقضی\",\n    \"USERS_BOT_ADD_PLAN\": \"➕افزودن پلن\",\n    \"USERS_BOT_DEL_PLAN\": \"➖حذف پلن\",\n    \"USERS_BOT_OWNER_INFO\": \"👤اطلاعات مالک\",\n    \"USERS_BOT_OWNER_INFO_EDIT\": \"ویرایش اطلاعات مالک\",\n    \"USERS_BOT_ORDERS_STATUS\": \"📊پیگیری تراکنش\",\n    \"USERS_BOT_SUB_STATUS\": \"📊پیگیری اشتراک\",\n    \"USERS_BOT_OWNER_INFO_EDIT_USERNAME\": \"ویرایش نام کاربری پشتیبان\",\n    \"USERS_BOT_OWNER_INFO_EDIT_CARD_NUMBER\": \"ویرایش شماره کارت\",\n    \"USERS_BOT_OWNER_INFO_EDIT_CARD_NAME\": \"ویرایش نام صاحب کارت\",\n    \"USERS_BOT_SEND_MESSAGE_TO_USERS\": \"📩ارسال پیام همگانی\",\n    \"USERS_BOT_SETTINGS\": \"⚙️تنظیمات\",\n    \"USERS_BOT_SETTINGS_SHOW_HIDI_LINK\": \"هایپرلینک هیدیفای\",\n    \"USERS_BOT_SETTINGS_SHOW_THREE_RAND\": \"مشخصه تصادفی قیمت\",\n    \"USERS_BOT_SETTINGS_MIN_DEPO\": \"محدودیت حداقل تراکنش\",\n    \"USERS_BOT_SETTINGS_PNL_V8_FEATURES\": \"اشتراک های نسخه 8\",\n    \"USERS_BOT_SETTINGS_CHANNEL_ID\": \"تنظیم کانال پشتیبانی\",\n    \"USERS_BOT_SETTINGS_CHANNEL_ّFORCE_JOIN\": \"عضویت اجباری\",\n    \"USERS_BOT_SETTINGS_VISIBLE_SUBS\": \"وضعیت نمایش اشتراک ها\",\n    \"USERS_BOT_SETTINGS_SET_WELCOME_MSG\": \"پیام خوش آمدگویی\",\n    \"USERS_BOT_SETTINGS_SET_FAQ_MSG\": \"متن سوالات متداول\",\n    \"USERS_BOT_SETTINGS_SET_FAQ_MESSAGE\": \"تنظیم متن سوالات متداول\",\n    \"USERS_BOT_SETTINGS_HIDE_FAQ\": \"❌حذف سوالات متداول\",\n    \"USERS_BOT_SETTINGS_TEST_SUB\": \"مشخصات اشتراک تستی\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_DAYS\": \"مدت اشتراک تستی\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_SIZE\": \"حجم اشتراک تستی\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER\": \"یادآور وضعیت اشتراک\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE\": \"یادآور وضعیت مصرف\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS\": \"یادآور وضعیت زمان\",\n    \"USERS_BOT_SETTINGS_PANEL_AUTO_BACKUP\": \"ارسال خودکار بکاپ\",\n    \"USERS_BOT_SETTINGS_BOT_AUTO_BACKUP\": \"بکاپ خودکار ربات\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL\": \"متن راهنما\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_ANDROID\": \"راهنمای اندروید\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_IOS\": \"راهنمای IOS\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_WIN\": \"راهنمای ویندوز\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_MAC\": \"راهنمای مک\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL_LIN\": \"راهنمای لینوکس\",\n    \"USERS_BOT_SETTINGS_BACKUP_BOT\": \"پشتیبان گیری ربات\",\n    \"USERS_BOT_SETTINGS_RESTORE_BOT\": \"بازیابی ربات\",\n    \"USERS_BOT_SETTINGS_BUY_SUBSCRIPTION_STATUS\": \"خرید اشتراک\",\n    \"USERS_BOT_SETTINGS_RENEWAL_SUBSCRIPTION_STATUS\": \"تمدید اشتراک\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD\": \"شیوه تمدید\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_DEFAULT\": \"پیشفرض\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED\": \"پیشرفته\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_FAIRLY\": \"منصفانه\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS\": \"حداکثر زمان مجاز برای تمدید\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE\": \"حداکثر مصرف مجاز برای تمدید\",\n    \"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT\": \"بازنشانی تست رایگان\",\n    \"ABOUT_BOT\": \"ℹ️\",\n    \"TO_QR\": \"ً🖼کیوآر\",\n    \"SUPPORT_GROUP\": \"گروه پشتیبانی\",\n    \"SERVERS_MANAGEMENT\":\"🖥 مدیریت سرورها\",\n    \"ADD_SERVER\": \"➕افزودن سرور\",\n    \"EDIT_SERVER\": \"ویرایش سرور\",\n    \"DELETE_SERVER\": \"حذف سرور\",\n    \"SERVER_LIST_OF_USERS\": \"مدیریت کاربران\",\n    \"SERVER_LIST_OF_PLANS\": \"لیست پلن‌ها\",\n    \"SERVER_EDIT_TITLE\": \"ویرایش عنوان\",\n    \"SERVER_EDIT_USER_LIMIT\": \"ویرایش محدودیت کاربر\",\n    \"SERVER_EDIT_URL\": \"ویرایش لینک\",\n    \"CHANGE_STATUS_PAYMENT\": \"تغییر وضعیت تراکنش\",\n    \"CONFIRM_PAYMENT\": \"✅تایید تراکنش\",\n    \"NO\": \"❌خیر\",\n    \"YES\": \"✅بله\",\n    \"ANSWER\": \"📤پاسخ\",\n    \"SEND_MESSAGE\": \"📤ارسال پیام\",\n    \"DEBUG\":\"DEBUG\",\n    \"SKIP\":\"⏩رد کردن\",\n    \"RESET_TEST\":\"🔄بازنشانی اشتراک تستی\",\n    \"BAN_USER\":\"🚫مسدود کردن کاربر\"\n\n  }\n}"
  },
  {
    "path": "AdminBot/Json/commands.json",
    "content": "{\n    \"EN\": {\n        \"START\": \"start\",\n        \"DEBUG\": \"debug\"\n    },\n    \"FA\": {\n        \"START\": \"شروع\",\n        \"DEBUG\": \"اشکال زدایی\"\n    }\n}"
  },
  {
    "path": "AdminBot/Json/messages.json",
    "content": "{\n  \"EN\": {\n    \"WELCOME\": \"Welcome to Hiddify Management Bot\",\n    \"ERROR_INVALID_NUMBER\": \"❌Only numbers are allowed!\",\n    \"ERROR_USER_NOT_FOUND\": \"❌User not found\",\n    \"ERROR_INVALID_COMMAND\": \"❌Invalid command\",\n    \"ERROR_UNKNOWN\": \"❌Unknown error\",\n    \"ERROR_CONFIG_NOT_FOUND\": \"❌Config not found\",\n    \"ERROR_PLAN_NOT_FOUND\": \"❌Plan not found\",\n    \"ERROR_SUB_NOT_FOUND\": \"❌Subscription not found\",\n    \"ERROR_CHANNEL_ID_NOT_SET\": \"❌Channel ID not set, please set it first.\",\n    \"SUCCESS_USER_DELETED\": \"✅User deleted\",\n    \"SUCCESS_USER_EDITED\": \"✅User edited\",\n    \"SUCCESS_USER_ADDED\": \"✅User added\",\n    \"SUCCESS_USER_USAGE_EDITED\": \"✅Usage limit edited to:\",\n    \"SUCCESS_USER_DAYS_EDITED\": \"✅Days edited to:\",\n    \"SUCCESS_USER_NAME_EDITED\": \"✅Name edited to:\",\n    \"SUCCESS_USER_COMMENT_EDITED\": \"✅Comment edited to:\",\n    \"SUCCESS_ADD_USER\": \"✅User added\",\n    \"SUCCESS_SEARCH_USER\": \"✅User found\",\n    \"SUCCESS_SEARCH_SUB\": \"✅Subscription found\",\n    \"SUCCESS_SEND_MSG_USERS\": \"✅Message sent to users\",\n    \"SUCCESS_REMOVED_SERVER\": \"✅Server removed\",\n    \"SUCCESS_RESET_FREE_TEST\": \"✅Free trial limit successfully reset\",\n    \"WAIT\": \"Please wait...\",\n    \"CANCELED\": \"❌Canceled\",\n    \"CANCEL_ADD_USER\": \"❌Add User Canceled\",\n    \"ADD_USER_NAME\": \"Please enter the name of the user: \",\n    \"ADD_USER_COMMENT\": \"Please enter the comment of the user: \",\n    \"ADD_USER_USAGE_LIMIT\": \"Please enter the usage limit of the user (GB): \",\n    \"ADD_USER_DAYS\": \"Please enter the days of package: \",\n    \"ENTER_NEW_USAGE_LIMIT\": \"Please enter new usage limit (GB): \",\n    \"ENTER_NEW_DAYS\": \"Please enter new limit: \",\n    \"ENTER_NEW_NAME\": \"Please enter new name: \",\n    \"ENTER_NEW_COMMENT\": \"Please enter new comment: \",\n    \"RESET_USAGE\": \"✅Usage limit reset\",\n    \"RESET_DAYS\": \"✅Days reset\",\n    \"ADD_USER_CONFIRM\": \"Please confirm the information:\",\n    \"ERROR_NOT_ADMIN\": \"❌You are not admin!\",\n    \"NEW_USER_INFO\": \"[New User Info]\",\n    \"EDITED_USER_INFO\": \"[User Info Updated]\",\n    \"EXPIRED_USERS_LIST\": \"[EXPIRED USERS LIST]\",\n    \"GB\": \"GB\",\n    \"DAY_EXPIRE\": \"Days\",\n    \"INFO_USAGE\": \"📊Usage:\",\n    \"OF\": \"of\",\n    \"INFO_REMAINING_DAYS\": \"📆Remaining Days:\",\n    \"INFO_LAST_CONNECTION\": \"📶Last Connection:\",\n    \"INFO_COMMENT\": \"📝Comment:\",\n    \"INFO_USER_NAME\": \"⬖ Name:\",\n    \"INFO_USER_USERNAME\": \"⬖ Username:\",\n    \"INFO_USER_NUM_ID\": \"⬖ Telegram ID:\",\n    \"HEADER_USERS_LIST\": \"⬖ Users List\",\n    \"HEADER_USERS_LIST_MSG\": \"ℹ️You can see the list of users and their information here.\",\n    \"NUM_USERS\": \"🟢Number of users: \",\n    \"NUM_USERS_ONLINE\": \"🔵Online users: \",\n    \"NUM_GET_FREE_USERS\": \"⬖ Number of received free test: \",\n    \"NUM_ORDERED_USERS\": \"⬖ Number of users placed order: \",\n    \"TOTAL_BALANCE_USERS\": \"⬖ Total balance of users' wallets: \",\n    \"SEARCH_USER\": \"Please select the search method\",\n    \"SEARCH_USER_NAME\": \"Please enter the name of the user: \",\n    \"SEARCH_USER_TELEGRAM_ID\": \"Please enter the Telegram ID of the user: \",\n    \"SEARCH_USER_UUID\": \"Please enter the UUID of the user: \",\n    \"SEARCH_USER_CONFIG\": \"Please enter one of the config of the user: \",\n    \"SEARCH_RESULT\": \"[Search Result]\",\n    \"MONTH\": \"Months\",\n    \"WEEK\": \"Weeks\",\n    \"DAY\": \"Days\",\n    \"HOUR\": \"Hours\",\n    \"MINUTE\": \"Minutes\",\n    \"ONLINE\": \"Online\",\n    \"AGO\": \"ago\",\n    \"NEVER\": \"Never\",\n    \"TOMAN\": \"T\",\n    \"CURRENT_VALUE\": \"Current Value\",\n    \"ERROR_CLIENT_TOKEN\": \"❌Client bot is not set!\",\n    \"USERS_BOT_ADD_PLAN\": \"Please complete the following information to add a plan\",\n    \"USERS_BOT_ADD_PLAN_DAYS\": \"Please enter the days of Plan: \",\n    \"USERS_BOT_ADD_PLAN_USAGE\": \"Please enter the usage limit(GB) of the Plan: \",\n    \"USERS_BOT_ADD_PLAN_PRICE\": \"Please enter the price(TOMAN) of the Plan: \",\n    \"USERS_BOT_ADD_PLAN_DESC\": \"Please enter the description of the Plan: \",\n    \"USERS_BOT_ADD_PLAN_CONFIRM\": \"Please confirm the information:\",\n    \"USERS_BOT_ADD_PLAN_SUCCESS\": \"✅Plan added\",\n    \"USERS_BOT_OWNER_INFO_NOT_FOUND\": \"Owner info not found!\\nPlease set it first.\",\n    \"USERS_BOT_OWNER_INFO_ADD_USERNAME\": \"Please enter the username of the support bot: \",\n    \"USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER\": \"Please enter the card number: \",\n    \"USERS_BOT_OWNER_INFO_ADD_CARD_NAME\": \"Please enter the name of the card owner: \",\n    \"USERS_BOT_SEND_MSG_USERS\": \"Please enter the message you want to send to users:\",\n    \"USERS_BOT_PLANS_LIST\": \"📋Plans List\",\n    \"USERS_BOT_SELECT_PLAN_TO_DELETE\": \"Please select the plan you want to delete:\",\n    \"USERS_BOT_PLAN_DELETED\": \"✅Plan deleted\",\n    \"SUCCESS_UPDATE_DATA\": \"✅Data updated\",\n    \"USERS_BOT_SETTINGS\": \"⚙️Users Bot Settings\",\n    \"USERS_BOT_SETTINGS_HYPERLINK\": \"Set Hyperlink visibility when user request subscription info\",\n    \"USERS_BOT_ORDER_NUMBER_REQUEST\": \"Please enter the payment number:\",\n    \"USERS_BOT_SUB_ID_REQUEST\": \"Please enter the subscription ID:\",\n    \"USERS_BOT_SETTING_MIN_DEPO\": \"Please enter the minimum deposit:\",\n    \"USERS_BOT_SETTING_CHANNEL_ID\": \"Please enter the channel ID:\",\n    \"USERS_BOT_SETTING_FORCE_JOIN_HELP\": \"⭕Please add the bot to your channel and make it admin to work properly.\",\n    \"USERS_BOT_SETTING_WELCOME_MSG\": \"Please enter the welcome message:\",\n    \"USERS_BOT_SETTING_FAQ_MSG\": \"Please enter the faq text to show in the user panel:\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_DAYS\": \"Please enter the days of test subscription:\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_USAGE\": \"Please enter the usage limit(GB) of test subscription:\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS\": \"Set the number of days before the end of the subscription to send a reminder message:\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE\": \"Set the remaining GB to send a reminder message:\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL\": \"Please enter the manual text to show in the user panel:\",\n    \"USERS_BOT_SETTINGS_BACKUP_BOT\": \"Backup Bot File\",\n    \"USERS_BOT_SETTINGS_RESTORE_BOT\": \"This feature is under test, so be careful when using it and ask your questions from the support group.\\nRestore Bot Backup File\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS\":\"Set the number of days before the end of the subscription to allow the user to renew the subscription:\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE\":\"Set the remaining GB to allow the user to renew the subscription:\",\n    \"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT_QUESTION\": \"Are you sure you want to reset your free trial?\\n⚠️By confirming this, all users are able to take a free test again\",\n    \"ERROR_INVALID_USERNAME\": \"❌Invalid username\\nUsername must start with @\",\n    \"ERROR_INVALID_CARD_NUMBER\": \"❌Invalid card number\",\n    \"PAYMENT_CONFIRMED\": \"✅Payment confirmed\",\n    \"PAYMENT_NOT_CONFIRMED\": \"❌Payment not confirmed\",\n    \"ERROR_PAYMENT_ALREADY_CONFIRMED\": \"❌Payment already confirmed\",\n    \"ERROR_PAYMENT_ALREADY_REJECTED\": \"❌Payment already rejected\",\n    \"PAYMENT_CONFIRMED_ADMIN\": \"✅Payment confirmed\",\n    \"PAYMENT_NOT_CONFIRMED_ADMIN\": \"❌Payment not confirmed\",\n    \"ERROR_PAYMENT_NOT_FOUND\": \"❌Payment not found\",\n    \"ERROR_ORDER_NOT_FOUND\": \"❌Order not found\",\n    \"ERROR_GIFT_NOT_FOUND\": \"❌Gift not found\",\n    \"ORDER_ID\": \"Payment number:\",\n    \"SUB_ID\": \"Subscription ID:\",\n    \"USER_TIME_EXPIRED\": \"⚠️EXPIRED\",\n    \"USER_LAST_DAY\": \"Last Day\",\n    \"PAYMENT_ASK_CHANGE_STATUS\": \"Do you want to change the status of the payment?\",\n    \"PAYMENT_ACCEPT_STATUS_CONFIRMED\": \"🟢Confirmed\",\n    \"PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED\": \"🔴Not Confirmed\",\n    \"PAYMENT_ACCEPT_STATUS_WAITING\": \"🟡Waiting\",\n    \"PAYMENT_ACCEPT_STATUS\": \"Status:\",\n    \"CREATED_AT\": \"Created:\",\n    \"WALLET_PAYMENT_CONFIRMED\": \"✅Payment confirmed\\nYour wallet balance has increased.\",\n    \"FEATUR_UNAVAILABLE\": \"❌This feature is not available at the moment.\",\n    \"REQUEST_JOIN_HIDY\": \"Please join the support group to get the latest information.\",\n    \"WELCOME_TO_ADMIN\": \"Hiddify Management Bot has been successfully launched.\\nTo start working, send the /start command.\",\n    \"SUCCESS_RESTORE_BOT\": \"✅Bot restored successfully\",\n    \"ADD_SERVER\": \"Please complete the following information to add a server\",\n    \"ADD_SERVER_TITLE\": \"Please enter the title of Server: \",\n    \"ADD_SERVER_USER_LIMIT\": \"Please enter the user limit of the Server: \",\n    \"ADD_SERVER_URL\": \"Please enter the url of the Server: \",\n    \"ERROR_ADD_SERVER_URL\": \"Please enter the valid url of the Server: \",\n    \"ERROR_SAME_SERVER_URL\": \"This link is already registered for another server, please submit another link:\",\n    \"ADD_SERVER_SUCCESS\": \"✅Server added\",\n    \"INFO_SERVER\": \"Server:\",\n    \"INFO_SERVER_USER_NUMBER\": \"Number of Users:\",\n    \"INFO_SERVER_USER_PLAN\": \"Number of Plan:\",\n    \"DELETE_SERVER_QUESTION\": \"Are you sure you want to delete the server?\\n⚠️After deleting subscriptions related to this server, it is not visible to users.\",\n    \"ERROR_SERVER_NOT_FOUND\": \"❌Server not found\",\n    \"INFO_PLAN_ID\": \"Plan ID:\",\n    \"INFO_PLAN_USAGE\": \"Usage limit(GB):\",\n    \"INFO_PLAN_DAYS\": \"Time limitation:\",\n    \"INFO_PLAN_PRICE\": \"Price\",\n    \"INFO_PLAN_DESC\": \"Description:\",\n    \"INFO_PLAN_NUM_ORDER\": \"Purchases\",\n    \"INFO_PLAN_TOTAL_SALE\": \"Total sales\",\n    \"SUCCESS_SERVER_TITLE_EDITED\":\"✅Title edited to:\",\n    \"SUCCESS_SERVER_USER_LIMIT_EDITED\" : \"✅User limit edited to:\",\n    \"SUCCESS_SERVER_URL_EDITED\": \"✅URL edited to:\",\n    \"SERVER\": \"⬖ Server:\",\n    \"HEADER_ORDERS_LIST\": \"⬖ Orders List\",\n    \"NUM_ORDERS\": \"⬖ Number of Orders: \",\n    \"TOTAL_ORDERS_VALUME\": \"⬖ Total volume ordered(GB): \",\n    \"TOTAL_ORDERS_SALES\": \"⬖ Total value of orders: \",\n    \"LAST_30DAYS_NUM_ORDERS\": \"⬖ Number of Last 30 Days Orders: \",\n    \"LAST_30DAYS_ORDERS_VALUME\": \"⬖ Volume ordered in Last 30 Days(GB): \",\n    \"LAST_30DAYS_ORDERS_SALES\": \"⬖ Value of orders in Last 30 Days: \",\n    \"THIS_MONTH_NUM_ORDERS\": \"⬖ Number of This Month Orders: \",\n    \"THIS_MONTH_ORDERS_VALUME\": \"⬖ Volume ordered in This Month(GB): \",\n    \"THIS_MONTH_ORDERS_SALES\": \"⬖ Value of orders in This Month: \",\n    \"HEADER_PAYMENT_LIST\": \"⬖ Payment List\",\n    \"NUM_PAYMENTS\": \"⬖ Number of Payments: \",\n    \"TOTAL_PAYMENTS_AMOUNT\": \"⬖ Total amount payment: \",\n    \"LAST_30DAYS_NUM_PAYMENTS\": \"⬖ Number of Last 30 Days Payments: \",\n    \"LAST_30DAYS_PAYMENTS_AMOUNT\": \"⬖ Amount of Payments in Last 30 Days: \",\n    \"THIS_MONTH_NUM_PAYMENTS\": \"⬖ Number of This Month Payments: \",\n    \"THIS_MONTH_PAYMENTS_AMOUNT\": \"⬖ Amount of Payments in This Month: \",\n    \"GET_FREE_TEST_STATUS\": \"⬖ Free Test Status: \",\n    \"WALLET_BALANCE\": \"⬖ Wallet Balance: \",\n    \"NUM_ORDER_SUB\": \"⬖ Number of ordered subscriptions: \",\n    \"NUM_NON_ORDER_SUB\": \"⬖ Number of connected subscriptions: \",\n    \"NUM_APPROVED_PAYMENTS\": \"⬖ Number of Approved Payments: \",\n    \"BOT_ORDER_ID\": \"⬖ Order Number: \",\n    \"ORDERED_VALUME\": \"⬖ Ordered Volume: \",\n    \"ORDERED_DAYS\": \"⬖ Ordered Days: \",\n    \"ORDERED_PRICE\": \"⬖ Ordered Price: \",\n    \"SUB_NAME\": \"⬖ Subscription title: \",\n    \"BOT_ORDER_DATE\": \"⬖ Order Date: \",\n    \"ORDER_NUMBER_REQUEST\": \"Please enter the order number:\",\n    \"PAYMENTS_ID\": \"⬖ Payment number: \",\n    \"BOT_PAYMENT_DATE\": \"⬖ Payment Date: \",\n    \"PAIED_AMOUNT\": \"⬖ Paid amount: \",\n    \"STATUS\": \"⬖ Status: \",\n    \"PAYMENTS_METHOD\": \"⬖ Payment Method: \",\n    \"PAYMENT_NUMBER_REQUEST\": \"Please enter the payment number:\",\n    \"CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST\": \"⚠️Are you sure about the changing payment status?\",\n    \"WALLET_CHANGED_TO_PAYMENT_CONFIRMED\": \"✅Payment changed to confirmed by admin\\nYour wallet balance has increased.\",\n    \"PAYMENT_CHANGED_TO_NOT_CONFIRMED\": \"❌Payment changed to rejected by admin And the payment amount is deducted from your wallet balance\\nPlease contact support if a mistake has been made.\",\n    \"PAYMENT_CHANGED_TO_CONFIRMED_ADMIN\": \"✅Payment changed to confirmed\",\n    \"PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN\": \"❌Payment changed to rejected\",\n    \"SUCCESS_SEARCH_ORDER\": \"✅Order found\",\n    \"SUCCESS_SEARCH_PAYMENT\": \"✅Payment found\",\n    \"NOT_SET \": \"Not set\",\n    \"EDIT_WALLET_BALANCE\": \"Please enter the new balance:\",\n    \"SEND_MESSAGE_TO_USER\": \"Please enter message you want to send to the user:\",\n    \"MESSAGE_SENDED\": \"Message Sended\",\n    \"ADMIN\": \"َAdmin:\",\n    \"MESSAGE_FROM_ADMIN\": \"Message from admin\",\n    \"MESSAGE_TEXT\": \"Message:\",\n    \"ERROR_USER_HAVE_TEST_SUB\": \"❌User already have a test subscription\",\n    \"SUCCESS_RESET_TEST_SUB\": \"✅Test subscription reset\",\n    \"WALLET_BALANCE_CHANGED_BY_ADMIN_P1\": \"💰Wallet balance changed to\",\n    \"WALLET_BALANCE_CHANGED_BY_ADMIN_P2\": \"by admin\",\n    \"SUCCESS_BAN_USER\": \"✅User banned\",\n    \"SUCCESS_UNBAN_USER\": \"✅User unbanned\"\n  },\n  \"FA\": {\n    \"WELCOME\": \"به ربات مدیریت هیدی بات خوش آمدید.\",\n    \"ERROR_INVALID_NUMBER\": \"❌تنها اعداد مجاز هستند!\",\n    \"ERROR_USER_NOT_FOUND\": \"❌کاربر یافت نشد\",\n    \"ERROR_INVALID_COMMAND\": \"❌فرمان نامعتبر\",\n    \"ERROR_UNKNOWN\": \"❌خطای ناشناخته\",\n    \"ERROR_CONFIG_NOT_FOUND\": \"❌کانفیگ یافت نشد\",\n    \"ERROR_PLAN_NOT_FOUND\": \"❌پلن یافت نشد\",\n    \"ERROR_SUB_NOT_FOUND\": \"❌اشتراکی با این شناسه یافت نشد\",\n    \"ERROR_CHANNEL_ID_NOT_SET\": \"❌آیدی کانال پشتیبانی تنظیم نشده است، لطفا ابتدا آن را تنظیم کنید.\",\n    \"SUCCESS_USER_DELETED\": \"✅کاربر حذف شد\",\n    \"SUCCESS_USER_EDITED\": \"✅کاربر ویرایش شد\",\n    \"SUCCESS_USER_ADDED\": \"✅کاربر اضافه شد\",\n    \"SUCCESS_USER_USAGE_EDITED\": \"✅محدودیت استفاده کاربر ویرایش شد به:\",\n    \"SUCCESS_USER_DAYS_EDITED\": \"✅روزها ویرایش شد به:\",\n    \"SUCCESS_USER_NAME_EDITED\": \"✅نام ویرایش شد به:\",\n    \"SUCCESS_USER_COMMENT_EDITED\": \"✅یادداشت ویرایش شد به:\",\n    \"SUCCESS_ADD_USER\": \"✅کاربر اضافه شد\",\n    \"SUCCESS_SEARCH_USER\": \"✅کاربر یافت شد\",\n    \"SUCCESS_SEARCH_SUB\": \"✅اشتراک یافت شد\",\n    \"SUCCESS_SEND_MSG_USERS\": \"✅پیام به کاربران ارسال شد\",\n    \"SUCCESS_REMOVED_SERVER\": \"✅سرور حذف شد\",\n    \"SUCCESS_RESET_FREE_TEST\": \"✅محدودیت تست رایگان با موفقیت بازنشانی شد\",\n    \"WAIT\": \"لطفاً منتظر بمانید...\",\n    \"CANCELED\": \"❌لغو شد\",\n    \"CANCEL_ADD_USER\": \"❌افزودن کاربر لغو شد\",\n    \"ADD_USER_NAME\": \"لطفاً نام کاربر را وارد کنید: \",\n    \"ADD_USER_COMMENT\": \"لطفاً نظر کاربر را وارد کنید: \",\n    \"ADD_USER_USAGE_LIMIT\": \"لطفاً محدودیت استفاده کاربر (GB) را وارد کنید: \",\n    \"ADD_USER_DAYS\": \"لطفاً تعداد روز بسته‌ی کاربر را وارد کنید: \",\n    \"ENTER_NEW_USAGE_LIMIT\": \"لطفاً محدودیت استفاده جدید (GB) را وارد کنید: \",\n    \"ENTER_NEW_DAYS\": \"لطفاً محدودیت جدید را وارد کنید: \",\n    \"ENTER_NEW_NAME\": \"لطفاً نام جدید را وارد کنید: \",\n    \"ENTER_NEW_COMMENT\": \"لطفاً یادداشت جدید را وارد کنید: \",\n    \"RESET_USAGE\": \"✅محدودیت استفاده بازنشانی شد\",\n    \"RESET_DAYS\": \"✅روزها بازنشانی شد\",\n    \"ADD_USER_CONFIRM\": \"لطفاً اطلاعات را تأیید کنید:\",\n    \"ERROR_NOT_ADMIN\": \"❌شما ادمین نیستید!\",\n    \"NEW_USER_INFO\": \"[اطلاعات کاربر جدید]\",\n    \"EDITED_USER_INFO\": \"[اطلاعات کاربر به‌روزرسانی شد]\",\n    \"EXPIRED_USERS_LIST\": \"[لیست کاربران منقضی شده]\",\n    \"GB\": \"گیگابایت\",\n    \"DAY_EXPIRE\": \"روز دیگر\",\n    \"INFO_USAGE\": \"📊مصرف:\",\n    \"OF\": \"از\",\n    \"INFO_REMAINING_DAYS\": \"📆انقضا:\",\n    \"INFO_LAST_CONNECTION\": \"📶آخرین اتصال:\",\n    \"INFO_COMMENT\": \"📝یادداشت:\",\n    \"INFO_USER_NAME\": \"⬖ کاربر:\",\n    \"INFO_USER_USERNAME\": \"⬖ نام کاربری:\",\n    \"INFO_USER_NUM_ID\": \"⬖ شناسه کاربر:\",\n    \"HEADER_USERS_LIST\": \"⬖ لیست کاربران\",\n    \"HEADER_USERS_LIST_MSG\": \"ش️ما می‌توانید لیست کاربران و اطلاعات آن‌ها را اینجا مشاهده کنید\",\n    \"NUM_USERS\": \"⬖ تعداد کاربران: \",\n    \"NUM_USERS_ONLINE\": \"🔵کاربران آنلاین: \",\n    \"NUM_GET_FREE_USERS\": \"⬖ تعداد کاربران تست رایگان: \",\n    \"NUM_ORDERED_USERS\": \"⬖ تعداد کاربران سفارشات: \",\n    \"TOTAL_BALANCE_USERS\": \"⬖ مجموع موجودی کیف پول کاربران: \",\n    \"SEARCH_USER\": \"لطفاً روش جستجو را انتخاب کنید\",\n    \"SEARCH_USER_NAME\": \"لطفاً نام کاربر را وارد کنید: \",\n    \"SEARCH_USER_TELEGRAM_ID\": \"لطفا Telegram ID کاربر را وارد کنید: \",\n    \"SEARCH_USER_UUID\": \"لطفاً UUID کاربر را وارد کنید: \",\n    \"SEARCH_USER_CONFIG\": \"لطفاً یکی از کانفیگ های کاربر را وارد کنید: \",\n    \"SEARCH_RESULT\": \"[نتیجه جستجو]\",\n    \"MONTH\": \"ماه\",\n    \"WEEK\": \"هفته\",\n    \"DAY\": \"روز\",\n    \"HOUR\": \"ساعت\",\n    \"MINUTE\": \"دقیقه\",\n    \"ONLINE\": \"آنلاین\",\n    \"AGO\": \"پیش\",\n    \"NEVER\": \"هرگز\",\n    \"TOMAN\": \"تومان\",\n    \"CURRENT_VALUE\": \"مقدار فعلی\",\n    \"ERROR_CLIENT_TOKEN\": \"❌ربات کاربران تنظیم نشده\",\n    \"USERS_BOT_ADD_PLAN\": \"⬇️اطلاعات لازم را برای افزودن پلن وارد کنید\",\n    \"USERS_BOT_ADD_PLAN_DAYS\": \"لطفا زمان(تعداد روزهای) پلن را وارد کنید:\",\n    \"USERS_BOT_ADD_PLAN_USAGE\": \"لطفا محدودیت استفاده(گیگابایت) پلن را وارد کنید:\",\n    \"USERS_BOT_ADD_PLAN_PRICE\": \"لطفا قیمت(تومان) پلن را وارد کنید:\",\n    \"USERS_BOT_ADD_PLAN_DESC\": \"لطفا توضیحات پلن را وارد کنید:\",\n    \"USERS_BOT_ADD_PLAN_CONFIRM\": \"لطفا اطلاعات زیر را تایید کنید\",\n    \"USERS_BOT_ADD_PLAN_SUCCESS\": \"✅پلن با موفقیت افزوده شد\",\n    \"USERS_BOT_OWNER_INFO_NOT_FOUND\": \"❌اطلاعات مالک یافت نشد \\n لطفا ابتدا آن را تنظیم کنید.\",\n    \"USERS_BOT_OWNER_INFO_ADD_USERNAME\": \"لطفا نام کاربری تلگرام پشتیبان را وارد کنید\\nلطفا همراه با @ وارد کنید\\nمثال: @example\",\n    \"USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER\": \"لطفا شماره 16 رقمی کارت بانکی جهت واریز را وارد کنید\",\n    \"USERS_BOT_OWNER_INFO_ADD_CARD_NAME\": \"لطفا نام صاحب حساب بانکی جهت واریز را وارد کنید\",\n    \"USERS_BOT_SEND_MSG_USERS\": \"لطفا پیام خود را برای ارسال به کاربران وارد کنید:\",\n    \"USERS_BOT_PLANS_LIST\": \"📋لیست پلن های موجود\",\n    \"USERS_BOT_SELECT_PLAN_TO_DELETE\": \"لطفا پلن مورد نظر را برای حذف انتخاب کنید\",\n    \"USERS_BOT_PLAN_DELETED\": \"✅پلن با موفقیت حذف شد\",\n    \"USERS_BOT_SETTINGS\": \"⚙️تنظیمات ربات کاربران\",\n    \"USERS_BOT_SETTINGS_HYPERLINK\": \"تنظیم نمایش Hyperlink صفحه هیدیفای روی نام کاربر هنگام دریافت اطلاعات اشتراک\",\n    \"USERS_BOT_ORDER_NUMBER_REQUEST\": \"لطفا [شناسه تراکنش] را وارد کنید:\",\n    \"USERS_BOT_SUB_ID_REQUEST\": \"لطفا شناسه اشتراک را وارد کنید:\",\n    \"USERS_BOT_SETTING_MIN_DEPO\": \"لطفا حداقل مبلغ واریزی را تعیین کنید:\",\n    \"USERS_BOT_SETTING_CHANNEL_ID\": \"لطفا آیدی کانال را وارد کنید:\",\n    \"USERS_BOT_SETTING_FORCE_JOIN_HELP\": \"⭕لطفا برای اجرای این قابلیت، حتما [ربات کاربران] را به کانال خود اضافه و آن را ادمین کنید!\",\n    \"USERS_BOT_SETTING_WELCOME_MSG\": \"لطفا پیام خوش آمدگویی را تنظیم کنید:\",\n    \"USERS_BOT_SETTING_FAQ_MSG\": \"لطفا متن سوالات متداول مورد نظر را برای نمایش در پنل کاربران وارد کنید:\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_DAYS\": \"لطفا تعداد روزهای اشتراک تست را تنظیم کنید:\",\n    \"USERS_BOT_SETTINGS_TEST_SUB_USAGE\": \"لطفا حجم(گیگابایت) اشتراک تست را تنظیم کنید:\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS\": \"تعیین کنید که چند روز قبل از اتمام اشتراک پیام یادآوری تمدید اشتراک ارسال شود:\",\n    \"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE\": \"تعیین کنید که چند گیگ مانده به اتمام اشتراک پیام یادآوری تمدید اشتراک ارسال شود:\",\n    \"USERS_BOT_SETTINGS_PANEL_MANUAL\": \"لطفا متن راهنمای مورد نظر را برای نمایش در پنل کاربران وارد کنید:\",\n    \"USERS_BOT_SETTINGS_BACKUP_BOT\": \"فایل پشتیبان ربات\",\n    \"USERS_BOT_SETTINGS_RESTORE_BOT\": \"📥 لطفا فایل پشتیبان خود را ارسال کنید: \\n توجه داشته باشید که این قابلیت حساس میباشد و در صورت وجود هرگونه سوال یا شبهه، ابتدا با گروه پشتیبانی در ارتباط باشید.\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS\":\"تعیین کنید که چند روز مانده به پایان اشتراک، کاربر مجاز به تمدید اشتراک باشد:\",\n    \"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE\":\"تعیین کنید که چند گیگ مانده به پایان اشتراک، کاربر مجاز به تمدید اشتراک باشد:\",\n    \"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT_QUESTION\": \"آیا از بازنشانی تست رایگان کاربران اطمینان دارید؟\\n⚠️با تایید این مورد تمامی کاربران قادر به گرفتن تست رایگان مجدد می‌باشند\",\n    \"SUCCESS_UPDATE_DATA\": \"✅اطلاعات با موفقیت به روز شد\",\n    \"ERROR_INVALID_USERNAME\": \"❌آیدی نامعتبر است\\n آیدی باید با @ شروع شود\",\n    \"ERROR_INVALID_CARD_NUMBER\": \"❌شماره کارت نامعتبر است\\nشماره کارت باید 16 رقمی باشد\",\n    \"PAYMENT_CONFIRMED\": \"تراکنش شما تایید شد\\n از طریق دکمه [📊وضعیت اشتراک] میتوانید به اطلاعات اشتراک خود دسترسی داشته باشید.\",\n    \"PAYMENT_NOT_CONFIRMED\": \"تراکنش شما تایید نشد!\\nلطفا اگر اشتباهی صورت گرفته با پشتیبانی در تماس باشید.\",\n    \"ERROR_PAYMENT_ALREADY_CONFIRMED\": \"تراکنش قبلا تایید شده است\",\n    \"ERROR_PAYMENT_ALREADY_REJECTED\": \"تراکنش قبلا رد شده است\",\n    \"PAYMENT_CONFIRMED_ADMIN\": \"تراکنش با موفقیت تایید شد\",\n    \"PAYMENT_NOT_CONFIRMED_ADMIN\": \"تراکنش تایید نشد\",\n    \"ERROR_ORDER_NOT_FOUND\": \"❌سفارش یافت نشد\",\n    \"ERROR_PAYMENT_NOT_FOUND\": \"تراکنش یافت نشد\",\n    \"ERROR_GIFT_NOT_FOUND\": \"❌هدیه یافت نشد\",\n    \"ORDER_ID\": \"شناسه تراکنش:\",\n    \"SUB_ID\": \"شناسه اشتراک\",\n    \"USER_TIME_EXPIRED\": \"⚠️منقضی\",\n    \"USER_LAST_DAY\": \"آخرین روز\",\n    \"PAYMENT_ASK_CHANGE_STATUS\": \"آیا میخواهید وضعیت تراکنش را تغییر دهید؟\",\n    \"PAYMENT_ACCEPT_STATUS_CONFIRMED\": \"🟢تایید شده\",\n    \"PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED\": \"🔴رد شده\",\n    \"PAYMENT_ACCEPT_STATUS_WAITING\": \"🟡در انتظار تایید\",\n    \"PAYMENT_ACCEPT_STATUS\": \"وضعیت:\",\n    \"CREATED_AT\": \"تاریخ ایجاد:\",\n    \"WALLET_PAYMENT_CONFIRMED\": \"تراکنش شما تایید شد\\n از طریق دکمه [💰کیف پول] میتوانید به موجودی کیف پول خود دسترسی داشته باشید.\",\n    \"FEATUR_UNAVAILABLE\": \"❌این قابلیت در حال حاضر در دسترس نیست.\",\n    \"REQUEST_JOIN_HIDY\": \"📍جهت دریافت آخرین اطلاعات، در گروه پشتیبانی عضو شوید.\",\n    \"WELCOME_TO_ADMIN\": \"ربات مدیریت هیدی بات با موفقیت راه‌اندازی شد.\\nبرای شروع کار، دستور /start را ارسال کنید.\",\n    \"SUCCESS_RESTORE_BOT\": \"✅ربات با موفقیت بازیابی شد\",\n    \"ADD_SERVER\": \"لطفا اطلاعات زیر را برای افزودن سرور وارد کنید\",\n    \"ADD_SERVER_TITLE\": \"لطفا عنوانی را برای سرور وارد کنید:\",\n    \"ADD_SERVER_USER_LIMIT\": \"لطفا محدودیت تعداد کاربر سرور را وارد کنید:\",\n    \"ADD_SERVER_URL\": \"لطفا لینک سرور را وارد کنید:\",\n    \"ERROR_ADD_SERVER_URL\": \"لطفا لینک معتبر ارسال کنید: \",\n    \"ERROR_SAME_SERVER_URL\": \"این لینک قبلا برای سرور دیگری ثبت شده است، لطفا لینک دیگری ارسال کنید:\",\n    \"ADD_SERVER_SUCCESS\": \"✅سرور با موفقیت افزوده شد\",\n    \"INFO_SERVER\": \"سرور:\",\n    \"INFO_SERVER_USER_NUMBER\": \"تعداد کاربر:\",\n    \"INFO_SERVER_USER_PLAN\": \"تعداد پلن:\",\n    \"DELETE_SERVER_QUESTION\": \"آیا از حذف سرور مطمئن هستید؟\\n⚠️بعد از حذف، اشتراک‌های مربوط به این سرور برای کاربران قابل مشاهده نمی‌باشد و غیر قابل بازگردانی می‌باشد.\",\n    \"ERROR_SERVER_NOT_FOUND\": \"❌سرور یافت نشد\",\n    \"INFO_PLAN_ID\": \"آی دی:\",\n    \"INFO_PLAN_USAGE\": \"محدودیت مصرف(GB):\",\n    \"INFO_PLAN_DAYS\": \"محدودیت زمان(روز):\",\n    \"INFO_PLAN_PRICE\": \"قیمت:\",\n    \"INFO_PLAN_DESC\": \"توضیحات:\",\n    \"INFO_PLAN_NUM_ORDER\": \"تعداد سفارش:\",\n    \"INFO_PLAN_TOTAL_SALE\": \"مجموع فروش:\",\n    \"SUCCESS_SERVER_TITLE_EDITED\":\"✅عنوان سرور ویرایش شد به:\",\n    \"SUCCESS_SERVER_USER_LIMIT_EDITED\" : \"✅محدودیت کاربر ویرایش شد به:\",\n    \"SUCCESS_SERVER_URL_EDITED\": \"✅لینک سرور ویرایش شد به:\",\n    \"SERVER\": \"⬖ سرور: \",\n    \"HEADER_ORDERS_LIST\": \"⬖ لیست سفارشات\",\n    \"NUM_ORDERS\": \"⬖ تعداد سفارشات: \",\n    \"TOTAL_ORDERS_VALUME\": \"⬖ مجموع حجم سفارشات(GB): \",\n    \"TOTAL_ORDERS_SALES\": \"⬖ مجموع ارزش سفارشات: \",\n    \"LAST_30DAYS_NUM_ORDERS\": \"⬖ تعداد سفارشات 30 روز گذشته: \",\n    \"LAST_30DAYS_ORDERS_VALUME\": \"⬖ حجم سفارشات 30 روز گذشته(GB): \",\n    \"LAST_30DAYS_ORDERS_SALES\": \"⬖ ارزش سفارشات 30 روز گذشته: \",\n    \"THIS_MONTH_NUM_ORDERS\": \"⬖ تعداد سفارشات این ماه: \",\n    \"THIS_MONTH_ORDERS_VALUME\": \"⬖ حجم سفارشات این ماه(GB): \",\n    \"THIS_MONTH_ORDERS_SALES\": \"⬖ ارزش سفارشات این ماه: \",\n    \"HEADER_PAYMENT_LIST\": \"⬖ لیست تراکنشات\",\n    \"NUM_PAYMENTS\": \"⬖ تعداد تراکنشات: \",\n    \"TOTAL_PAYMENTS_AMOUNT\": \"⬖ مبلغ تراکنشات: \",\n    \"LAST_30DAYS_NUM_PAYMENTS\": \"⬖ تراکنشات 30 روز گذشته: \",\n    \"LAST_30DAYS_PAYMENTS_AMOUNT\": \"⬖ مبلغ تراکنشات 30 روز گذشته: \",\n    \"THIS_MONTH_NUM_PAYMENTS\": \"⬖ تراکنشات این ماه: \",\n    \"THIS_MONTH_PAYMENTS_AMOUNT\": \"⬖ مبلغ تراکنشات این ماه: \",\n    \"GET_FREE_TEST_STATUS\": \"⬖ وضعیت دریافت تست رایگان: \",\n    \"WALLET_BALANCE\": \"⬖ موجودی کیف پول: \",\n    \"NUM_ORDER_SUB\": \"⬖ تعداد اشتراک‌های خریداری شده: \",\n    \"NUM_NON_ORDER_SUB\": \"⬖ تعداد اشتراک‌های متصل شده: \",\n    \"NUM_APPROVED_PAYMENTS\": \"⬖ تعداد تراکنشات تایید شده: \",\n    \"BOT_ORDER_ID\": \"⬖ شناسه سفارش: \",\n    \"ORDERED_VALUME\": \"⬖ حجم سفارش(GB): \",\n    \"ORDERED_DAYS\": \"⬖ تعداد روز سفارش: \",\n    \"ORDERED_PRICE\": \"⬖ مبلغ سفارش: \",\n    \"SUB_NAME\": \"⬖ عنوان اشتراک: \",\n    \"BOT_ORDER_DATE\": \"⬖ تاریخ سفارش: \",\n    \"ORDER_NUMBER_REQUEST\": \"لطفا شناسه سفارش را وارد کنید:\",\n    \"PAYMENTS_ID\": \"⬖ شناسه تراکنش: \",\n    \"BOT_PAYMENT_DATE\": \"⬖ تاریخ تراکنش:\",\n    \"PAIED_AMOUNT\": \"⬖ مبلغ تراکنش: \",\n    \"STATUS\": \"⬖ وضعیت: \",\n    \"PAYMENTS_METHOD\": \"⬖ روش تراکنش: \",\n    \"PAYMENT_NUMBER_REQUEST\": \"لطفا شناسه تراکنش را وارد کنید:\",\n    \"CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST\": \"⚠️آیا از تغییر وضعیت تراکنش، اطمینان دارید؟\",\n    \"WALLET_CHANGED_TO_PAYMENT_CONFIRMED\": \"✅وضیعت تراکنش شما توسط مدیر به تایید شده تغییر یافت\\nاز طریق دکمه [💰کیف پول] میتوانید به موجودی کیف پول خود دسترسی داشته باشید.\",\n    \"PAYMENT_CHANGED_TO_NOT_CONFIRMED\": \"❌وضعیت تراکنش شما توسط مدیر به رد شده تغییر یافت و مبلغ تراکنش از موجود کیف پول شما کسر شد!\\nلطفا اگر اشتباهی صورت گرفته با پشتیبانی در تماس باشید.\",\n    \"PAYMENT_CHANGED_TO_CONFIRMED_ADMIN\": \"✅وضعیت تراکنش به تایید شده تغییر یافت\",\n    \"PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN\": \"❌وضعیت تراکنش به رد شده تغییر یافت\",\n    \"SUCCESS_SEARCH_ORDER\": \"✅سفارش یافت شد\",\n    \"SUCCESS_SEARCH_PAYMENT\": \"تراکنش یافت شد\",\n    \"NOT_SET\": \"تنظیم نشده\",\n    \"EDIT_WALLET_BALANCE\": \"لطفا مبلغی که میخواهید موجودی کیف پول به آن تغییر کند را به تومان وارد کنید:\",\n    \"SEND_MESSAGE_TO_USER\": \"لطفا متن پیامی که می خواهید برای کاربر ارسال شود را وارد کنید:\",\n    \"MESSAGE_SENDED\": \"پیام ارسال شد\",\n    \"ADMIN\": \"ادمین:\",\n    \"MESSAGE_FROM_ADMIN\": \"📬پیام جدیدی از سمت ادمین دریافت شد\",\n    \"MESSAGE_TEXT\": \"📄متن پیام:\",\n    \"ERROR_USER_HAVE_TEST_SUB\": \"❌کاربر اکنون نیز اشتراک تست رایگان دارد\",\n    \"SUCCESS_RESET_TEST_SUB\": \"✅اشتراک تست رایگان این کاربر با موفقیت بازنشانی شد\",\n    \"WALLET_BALANCE_CHANGED_BY_ADMIN_P1\": \"💰موجودی کیف پول شما توسط مدیر به\",\n    \"WALLET_BALANCE_CHANGED_BY_ADMIN_P2\": \"تومان تغییر یافت\",\n    \"SUCCESS_BAN_USER\": \"✅کاربر مسدود شد\",\n    \"SUCCESS_UNBAN_USER\": \"✅کاربر مسدود شده، آزاد شد\"\n  }\n}"
  },
  {
    "path": "AdminBot/bot.py",
    "content": "# Description: Main Bot File\nimport datetime\nimport html\nimport logging\nimport operator\nimport time\nimport telebot\nimport os\nfrom telebot.types import Message, CallbackQuery\n\nfrom config import TELEGRAM_TOKEN, ADMINS_ID, PANEL_ADMIN_ID, CLIENT_TOKEN, BOT_BACKUP_LOC\nfrom AdminBot.content import BOT_COMMANDS, MESSAGES, KEY_MARKUP\nfrom AdminBot import markups\nfrom AdminBot import templates\nfrom Utils import utils\nfrom Shared.common import user_bot\nfrom Database.dbManager import USERS_DB\nfrom Utils import api\nfrom config import panel_url_validator, API_PATH\n\n# Initialize Bot\nbot = telebot.TeleBot(TELEGRAM_TOKEN, parse_mode=\"HTML\")\nbot.remove_webhook()\n\nURL = 'url'\nselected_server = None\nsearch_mode = \"Single\"\nserver_mode = \"Single\"\nsearched_name = \"\"\nlist_mode = \"\"\nitem_mode= \"\"\nselected_telegram_id = \"0\"\n\nif CLIENT_TOKEN:\n    user_bot = user_bot()\n# ----------------------------------- Helper Functions -----------------------------------\n# Check if message is digit\ndef is_it_digit(message: Message, allow_float=False, response=MESSAGES['ERROR_INVALID_NUMBER'],\n                markup=markups.main_menu_keyboard_markup()):\n    if not message.text:\n        bot.send_message(message.chat.id, response, reply_markup=markup)\n        return False\n    try:\n        value = float(message.text) if allow_float else int(message.text)\n        return True\n    except ValueError:\n        bot.send_message(message.chat.id, response, reply_markup=markup)\n        return False\n\n# Check if message is cancel\ndef is_it_cancel(message: Message, response=MESSAGES['CANCELED']):\n    if message.text == KEY_MARKUP['CANCEL']:\n        bot.send_message(message.chat.id, response, reply_markup=markups.main_menu_keyboard_markup())\n        return True\n    return False\n\n\ndef message_to_html(message: Message):\n    text = message.text\n    entities = message.entities\n\n    html_content = \"\"\n\n    offset = 0\n    for entity in entities:\n        html_content += html.escape(text[offset:entity.offset])\n        if entity.type == 'bold':\n            html_content += f'<b>{html.escape(text[entity.offset:entity.offset + entity.length])}</b>'\n        elif entity.type == 'italic':\n            html_content += f'<i>{html.escape(text[entity.offset:entity.offset + entity.length])}</i>'\n        elif entity.type == 'code':\n            html_content += f'<code>{html.escape(text[entity.offset:entity.offset + entity.length])}</code>'\n        elif entity.type == 'pre':\n            html_content += f'<pre>{html.escape(text[entity.offset:entity.offset + entity.length])}</pre>'\n        elif entity.type == 'text_link':\n            html_content += f'<a href=\"{html.escape(entity.url)}\">{html.escape(text[entity.offset:entity.offset + entity.length])}</a>'\n        offset = entity.offset + entity.length\n    html_content += html.escape(text[offset:])\n    return html_content\n\n\n# ----------------------------------- Add User Area -----------------------------------\n# Add user Data dict\nadd_user_data = {}\n\n\n# Add User - Name\ndef add_user_name(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    add_user_data['name'] = message.text\n    bot.send_message(message.chat.id, MESSAGES['ADD_USER_USAGE_LIMIT'], reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, add_user_limit, server_id)\n\n\n# Add User - Usage Limit\ndef add_user_limit(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, f\"{MESSAGES['ERROR_INVALID_NUMBER']}\\n{MESSAGES['ADD_USER_USAGE_LIMIT']}\",\n                       markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, add_user_limit, server_id)\n        return\n    add_user_data['limit'] = message.text\n    bot.send_message(message.chat.id, MESSAGES['ADD_USER_DAYS'], reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, add_user_usage_days, server_id)\n\n\n# Add User - Usage Days\ndef add_user_usage_days(message: Message, server_id):\n    if is_it_cancel(message, MESSAGES['CANCEL_ADD_USER']):\n        return\n    if not is_it_digit(message, f\"{MESSAGES['ERROR_INVALID_NUMBER']}\\n{MESSAGES['ADD_USER_DAYS']}\",\n                       markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, add_user_usage_days, server_id)\n        return\n    add_user_data['usage_days'] = message.text\n    bot.send_message(message.chat.id,\n                     f\"{MESSAGES['ADD_USER_CONFIRM']}\\n\\n{MESSAGES['INFO_USER_NAME']} {add_user_data['name']}\\n\"\n                     f\"{MESSAGES['INFO_USAGE']} {add_user_data['limit']} {MESSAGES['GB']}\\n{MESSAGES['INFO_REMAINING_DAYS']} {add_user_data['usage_days']} {MESSAGES['DAY']}\",\n                     reply_markup=markups.confirm_add_user_markup())\n    bot.register_next_step_handler(message, confirm_add_user, server_id)\n\n\n# Add User - Confirm to add user\ndef confirm_add_user(message: Message, server_id):\n    \n    if message.text == KEY_MARKUP['CANCEL']:\n        bot.send_message(message.chat.id, MESSAGES['CANCEL_ADD_USER'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    if message.text == KEY_MARKUP['CONFIRM']:\n        msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'])\n        # res = ADMIN_DB.add_default_user(name=add_user_data['name'], package_days=int(add_user_data['usage_days']),\n        #                                 usage_limit_GB=int(add_user_data['limit']))\n        server = USERS_DB.find_server(id=int(server_id))\n        if not server:\n            bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n            return\n        server = server[0]\n        URL = server['url'] + API_PATH\n        res = api.insert(URL, name=add_user_data['name'], package_days=int(add_user_data['usage_days']),\n                         usage_limit_GB=int(add_user_data['limit']))\n        if res:\n            bot.send_message(message.chat.id, MESSAGES['SUCCESS_ADD_USER'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n            usr = utils.user_info(URL, res)\n            if not usr:\n                bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n                return\n            msg = templates.user_info_template(usr, server, MESSAGES['NEW_USER_INFO'])\n            bot.delete_message(message.chat.id, msg_wait.message_id)\n            bot.send_message(message.chat.id, msg, reply_markup=markups.user_info_markup(usr['uuid']))\n\n        else:\n            bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n    else:\n        bot.send_message(message.chat.id, MESSAGES['CANCEL_ADD_USER'], reply_markup=markups.main_menu_keyboard_markup())\n\n\n# ----------------------------------- Edit User Area -----------------------------------\n# Edit User - Name\ndef edit_user_name(message: Message, uuid):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    # status = ADMIN_DB.edit_user(uuid, name=message.text)\n    status = api.update(URL, uuid, name=message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_USER_NAME_EDITED']} {message.text} \",\n                     reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Edit User - Usage\ndef edit_user_usage(message: Message, uuid):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, edit_user_usage, uuid)\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    # status = ADMIN_DB.edit_user(uuid, usage_limit_GB=int(message.text))\n    status = api.update(URL, uuid, usage_limit_GB=int(message.text))\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_USER_USAGE_EDITED']} {message.text} {MESSAGES['GB']}\",\n                     reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Edit User - Days\ndef edit_user_days(message: Message, uuid):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, edit_user_days, uuid)\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    # status = ADMIN_DB.edit_user(uuid, package_days=int(message.text))\n    status = api.update(URL, uuid, package_days=int(message.text))\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id,\n                     f\"{MESSAGES['SUCCESS_USER_DAYS_EDITED']} {message.text} {MESSAGES['DAY_EXPIRE']} \",\n                     reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Edit User - Comment\ndef edit_user_comment(message: Message, uuid):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    # status = ADMIN_DB.edit_user(uuid, comment=message.text)\n    status = api.update(URL, uuid, comment=message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_USER_COMMENT_EDITED']} {message.text} \",\n                     reply_markup=markups.main_menu_keyboard_markup())\n\n\n# ----------------------------------- Search User Area -----------------------------------\n# Search User - Name\ndef search_user_name(message: Message, server_id):\n    global searched_name\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    searched_name = message.text\n    users = utils.search_user_by_name(URL, searched_name)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not users:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n\n    bot.send_message(message.chat.id, templates.users_list_template(users, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.users_list_markup(server_id, users))\n\n\n# Search User - UUID\ndef search_user_uuid(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    user = utils.search_user_by_uuid(URL, message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    server = USERS_DB.find_server(id=int(server_id))\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n        return\n    server = server[0]\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, templates.user_info_template(user, server, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.user_info_markup(user['uuid']))\n\n\n# Search User - Config\ndef search_user_config(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    user = utils.search_user_by_config(URL, message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    server = USERS_DB.find_server(id=int(server_id))\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n        return\n    server = server[0]\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, templates.user_info_template(user, server, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.user_info_markup(user['uuid']))\n\n# All Servers Search User - Name\ndef all_server_search_user_name(message: Message):\n    global searched_name\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    users = []\n    searched_name = message.text\n    servers = USERS_DB.select_servers()\n    if servers:\n        for server in servers:\n            URL = server['url'] + API_PATH\n            searched_users = utils.search_user_by_name(URL, searched_name)\n            if searched_users:\n                users.extend(searched_users)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not users:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n\n    bot.send_message(message.chat.id, templates.users_list_template(users, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.users_list_markup(\"None\", users))\n\n\n# All Servers Search User - UUID\ndef all_server_search_user_uuid(message: Message):\n    selected_server = None\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    servers = USERS_DB.select_servers()\n    if servers:\n        for server in servers:\n            URL = server['url'] + API_PATH\n            user = utils.search_user_by_uuid(URL, message.text)\n            if user:\n                selected_server = server\n                break\n    \n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    \n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, templates.user_info_template(user, selected_server, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.user_info_markup(user['uuid']))\n\n\n# All Servers Search User - Config\ndef all_server_search_user_config(message: Message):\n    selected_server = None\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    servers = USERS_DB.select_servers()\n    if servers:\n        for server in servers:\n            URL = server['url'] + API_PATH\n            user = utils.search_user_by_config(URL, message.text)\n            if user:\n                selected_server = server\n                break\n    \n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, templates.user_info_template(user, selected_server, MESSAGES['SEARCH_RESULT']),\n                     reply_markup=markups.user_info_markup(user['uuid']))\n\n# ----------------------------------- Users Bot Search Area -----------------------------------\n# User Bot Search  - Name\ndef search_bot_user_name(message: Message):\n    global searched_name\n    if is_it_cancel(message):\n        return\n    searched_name = message.text\n    users = USERS_DB.find_user(full_name=searched_name)\n    if not users:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    users.sort(key = operator.itemgetter('created_at'), reverse=True)\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n\n    wallets_list = USERS_DB.select_wallet()\n    orders_list = USERS_DB.select_orders()\n    msg = templates.bot_users_list_template(users, wallets_list, orders_list)\n    bot.send_message(message.chat.id, msg, reply_markup=markups.bot_users_list_markup(users))\n\n# User Bot Search  - Name\ndef search_bot_user_telegram_id(message: Message):\n    global selected_telegram_id\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, search_bot_user_telegram_id)\n        return\n    searched_id = message.text\n    users = USERS_DB.find_user(telegram_id=int(searched_id))\n    if not users:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                        reply_markup=markups.main_menu_keyboard_markup())\n        return\n    user = users[0]\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())\n    selected_telegram_id = user['telegram_id']\n    orders = USERS_DB.find_order(telegram_id=user['telegram_id'])\n    paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])\n    wallet = None\n    wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])\n    if wallets:\n        wallet = wallets[0]\n    non_order_subs = utils.non_order_user_info(user['telegram_id'])\n    order_subs = utils.order_user_info(user['telegram_id'])\n    plans_list = USERS_DB.select_plans()\n    msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)\n    bot.send_message(message.chat.id, msg, reply_markup=markups.bot_user_info_markup(user['telegram_id']))\n\n\n# User Bot Search  - Order\ndef search_bot_user_order(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, search_bot_user_order)\n        return\n    orders = USERS_DB.find_order(id=int(message.text))\n    if not orders:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],\n                        reply_markup=markups.main_menu_keyboard_markup())\n        return\n    order = orders[0]\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_ORDER'], reply_markup=markups.main_menu_keyboard_markup())\n    plans = USERS_DB.find_plan(id=order['plan_id'])\n    if not plans:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                            reply_markup=markups.main_menu_keyboard_markup())\n        return\n    plan = plans[0]\n    #subs = \n    users = USERS_DB.find_user(telegram_id=order['telegram_id'])\n    if not users:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                            reply_markup=markups.main_menu_keyboard_markup())\n        return\n    user = users[0]\n    servers = USERS_DB.find_server(id=plan['server_id'])\n    if not servers:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                            reply_markup=markups.main_menu_keyboard_markup())\n        return\n    server = servers[0]\n    msg = templates.bot_orders_info_template(order, plan, user, server)\n    bot.send_message(message.chat.id, msg)\n\n# User Bot Search  - Payment\ndef search_bot_user_payment(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, search_bot_user_payment)\n        return\n    payments = USERS_DB.find_payment(id=int(message.text))\n    if not payments:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],\n                        reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_PAYMENT'], reply_markup=markups.main_menu_keyboard_markup())\n    payment = payments[0]\n    user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n    if not user_data:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                            reply_markup=markups.main_menu_keyboard_markup())\n        return\n    user_data = user_data[0]\n    \n    msg = templates.bot_payment_info_template(payment,user_data)\n    photo_path = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])\n    bot.send_photo(message.chat.id, photo=open(photo_path, 'rb'),\n                caption=msg, reply_markup=markups.change_status_payment_by_admin(payment['id']))\n\n\n# ----------------------------------- Users Bot Management Area -----------------------------------\n#add_plan_data = {}\n\n\n# Add Plan - Size\n# def users_bot_add_plan_usage(message: Message):\n#     if is_it_cancel(message):\n#         return\n#     if not is_it_digit(message):\n#         return\n#     add_plan_data['usage'] = int(message.text)\n#     bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DAYS'],\n#                      reply_markup=markups.while_edit_user_markup())\n#     bot.register_next_step_handler(message, users_bot_add_plan_days)\n\n\n# # Add Plan - Days\n# def users_bot_add_plan_days(message: Message):\n#     if is_it_cancel(message):\n#         return\n#     if not is_it_digit(message):\n#         return\n#     add_plan_data['days'] = int(message.text)\n#     bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_PRICE'],\n#                      reply_markup=markups.while_edit_user_markup())\n#     bot.register_next_step_handler(message, users_bot_add_plan_price)\n\n\n# # Add Plan - Price\n# def users_bot_add_plan_price(message: Message):\n#     if is_it_cancel(message):\n#         return\n#     if not is_it_digit(message):\n#         return\n#     add_plan_data['price'] = utils.toman_to_rial(message.text)\n#     msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n#     status = utils.users_bot_add_plan(add_plan_data['usage'], add_plan_data['days'], add_plan_data['price'])\n#     bot.delete_message(message.chat.id, msg_wait.message_id)\n#     if not status:\n#         bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n#         return\n#     bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_SUCCESS'],\n#                      reply_markup=markups.main_menu_keyboard_markup())\n\n\n# ----------------------------------- Server Management Area -----------------------------------\nadd_server_data = {}\n\n\n# Add Server - Title\ndef add_server_title(message: Message):\n    if is_it_cancel(message):\n        return\n    add_server_data['title'] = message.text\n    bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_URL'],\n                     reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, add_server_url)\n\n\n# Add Server - url\ndef add_server_url(message: Message):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    url = panel_url_validator(message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not url:\n        bot.reply_to(message, MESSAGES['ERROR_ADD_SERVER_URL'],\n                     reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(message, add_server_url)\n        return\n    servers = USERS_DB.select_servers()\n    if servers:\n        for server in servers:\n            if server['url'] == url:\n                bot.reply_to(message, MESSAGES['ERROR_SAME_SERVER_URL'],\n                            reply_markup=markups.while_edit_user_markup())\n                bot.register_next_step_handler(message, add_server_url)\n                return\n                \n    add_server_data['url'] = url\n    bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_USER_LIMIT'],\n                     reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, add_server_user_limit)\n\n\n# Add Server - User Limit\ndef add_server_user_limit(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, add_server_user_limit)\n        return\n    add_server_data['user_limit'] = int(message.text)\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    status = utils.add_server(url=add_server_data['url'], user_limit=add_server_data['user_limit'], title=add_server_data['title'])\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_SUCCESS'],\n                     reply_markup=markups.main_menu_keyboard_markup())\n    servers = USERS_DB.select_servers()\n    bot.send_message(message.chat.id, KEY_MARKUP['SERVERS_MANAGEMENT'],\n                     reply_markup=markups.servers_management_markup(servers))\n    \n# Edit Server - Server Title\ndef edit_server_title(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    status = USERS_DB.edit_server(int(server_id), title=message.text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n    server = USERS_DB.find_server(id=int(server_id))\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n        return\n    server = server[0]\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_SERVER_TITLE_EDITED']}{server['title']}\",\n                     reply_markup=markups.main_menu_keyboard_markup())\n    plans = USERS_DB.select_plans()\n    msg = templates.server_info_template(server,plans)\n    bot.send_message(message.chat.id, msg,\n                     reply_markup=markups.server_edit_markup(server_id))\n    \n# Edit Server - Server User Limit\ndef edit_server_user_limit(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, edit_server_user_limit, server_id)\n        return\n    status = USERS_DB.edit_server(int(server_id), user_limit=int(message.text))\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n    server = USERS_DB.find_server(id=int(server_id))\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n        return\n    server = server[0]\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_SERVER_USER_LIMIT_EDITED']}{server['user_limit']}\",\n                     reply_markup=markups.main_menu_keyboard_markup())\n    plans = USERS_DB.select_plans()\n    msg = templates.server_info_template(server,plans)\n    bot.send_message(message.chat.id, msg,\n                     reply_markup=markups.server_edit_markup(server_id))\n\n# Edit Server - Server Url\ndef edit_server_url(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    url = panel_url_validator(message.text)\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not url:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_ADD_SERVER_URL'],\n                     reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(message, edit_server_url, server_id)\n        return\n    servers = USERS_DB.select_servers()\n    if servers:\n        for server in servers:\n            if server['url'] == url:\n                bot.reply_to(message, MESSAGES['ERROR_SAME_SERVER_URL'],\n                            reply_markup=markups.while_edit_user_markup())\n                bot.register_next_step_handler(message, edit_server_url, server_id)\n                return\n    status = USERS_DB.edit_server(int(server_id), url=url)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n        return\n    server = USERS_DB.find_server(id=int(server_id))\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n        return\n    server = server[0]\n    bot.send_message(message.chat.id, f\"{MESSAGES['SUCCESS_SERVER_URL_EDITED']}\\n{server['url']}\",\n                     reply_markup=markups.main_menu_keyboard_markup())\n    plans = USERS_DB.select_plans()\n    msg = templates.server_info_template(server,plans)\n    bot.send_message(message.chat.id, msg,\n                     reply_markup=markups.server_edit_markup(server_id))\n\n\n# ----------------------------------- Users Bot Management Area -----------------------------------\nadd_plan_data = {}\n\n\n# Add Plan - Size\ndef users_bot_add_plan_usage(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_add_plan_usage)\n        return\n    add_plan_data['usage'] = int(message.text)\n    bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DAYS'],\n                     reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, users_bot_add_plan_days)\n\n\n# Add Plan - Days\ndef users_bot_add_plan_days(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_add_plan_days)\n        return\n    add_plan_data['days'] = int(message.text)\n    bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_PRICE'],\n                     reply_markup=markups.while_edit_user_markup())\n    bot.register_next_step_handler(message, users_bot_add_plan_price)\n\n\n# Add Plan - Price\ndef users_bot_add_plan_price(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_add_plan_price)\n        return\n    add_plan_data['price'] = utils.toman_to_rial(message.text)\n    bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DESC'],\n                     reply_markup=markups.while_edit_skip_user_markup())\n    bot.register_next_step_handler(message, users_bot_add_plan_description)\ndef users_bot_add_plan_description(message: Message):\n    if is_it_cancel(message):\n        return\n    if message.text == KEY_MARKUP['SKIP']:\n        add_plan_data['description'] = None\n    else:\n        add_plan_data['description'] = message.text\n    \n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    status = utils.users_bot_add_plan(add_plan_data['usage'], add_plan_data['days'],\n                                      add_plan_data['price'], add_plan_data['server_id'], add_plan_data['description'])\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_SUCCESS'],\n                     reply_markup=markups.main_menu_keyboard_markup())\n    plans_list = []\n    plans = USERS_DB.select_plans()\n    if plans:\n        for plan in plans:\n            if plan['status']:\n                if plan['server_id'] == int(add_plan_data['server_id']):\n                        plans_list.append(plan)\n        plans_markup = markups.plans_list_markup(plans_list,add_plan_data['server_id'])\n        bot.send_message(message.chat.id, {MESSAGES['USERS_BOT_PLANS_LIST']},\n                         reply_markup=plans_markup)\n\n\n    \n\n# Users Bot - Edit Owner Info - Username\ndef users_bot_edit_owner_info_username(message: Message):\n    if is_it_cancel(message):\n        return\n    if not message.text.startswith('@'):\n        bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_USERNAME'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    status = USERS_DB.edit_str_config(\"support_username\", value=message.text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Users Bot - Edit Owner Info - Card Number\ndef users_bot_edit_owner_info_card_number(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_edit_owner_info_card_number)\n        return\n    if len(message.text) != 16:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_CARD_NUMBER'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    status = USERS_DB.edit_str_config(\"card_number\", value=message.text)\n\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Users Bot - Edit Owner Info - Cardholder Name\ndef users_bot_edit_owner_info_card_name(message: Message):\n    if is_it_cancel(message):\n        return\n    status = USERS_DB.edit_str_config(\"card_holder\", value=message.text)\n\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Users Bot - Send Message - All Users\ndef users_bot_send_msg_users(message: Message):\n    if is_it_cancel(message):\n        return\n    if not CLIENT_TOKEN:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())\n    users_number_id = USERS_DB.select_users()\n    bot.delete_message(message.chat.id, msg_wait.message_id)\n    if not users_number_id:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_NO_USERS'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    for user in users_number_id:\n        time.sleep(0.05)\n        try:\n            user_bot.send_message(user['telegram_id'], message.text)\n        except Exception as e:\n            logging.warning(f\"Error in send message to user {user['telegram_id']}: {e}\")\n            continue\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEND_MSG_USERS'],\n                     reply_markup=markups.main_menu_keyboard_markup())\n\n\n# Users Bot - Settings - Update Message\ndef users_bot_settings_update_message(message: Message, markup,title=MESSAGES['USERS_BOT_SETTINGS']):\n    settings = utils.all_configs_settings()\n\n    bot.edit_message_text(chat_id=message.chat.id, message_id=message.message_id,\n                          text=title,\n                          reply_markup=markup)\n\n\n# # Users Bot - Order Status\n# def users_bot_order_status(message: Message):\n#     from UserBot.templates import payment_received_template\n#     if is_it_cancel(message):\n#         return\n#     if not is_it_digit(message):\n#         return\n\n#     payment = USERS_DB.find_payment(id=int(message.text))\n#     if not payment:\n#         bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],\n#                          reply_markup=markups.main_menu_keyboard_markup())\n#         return\n\n#     # plan = USERS_DB.find_plan(id=payment[0]['plan_id'])\n#     # if not payment:\n#     #     bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'], reply_markup=markups.main_menu_keyboard_markup())\n#     #     return\n#     payment = payment[0]\n#     user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n#     if not user_data:\n#             bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n#                              reply_markup=markups.main_menu_keyboard_markup())\n#             return\n#     user_data = user_data[0]\n#     is_it_accepted = None\n#     if payment['approved'] == 0:\n#         is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED']\n#     elif payment['approved'] == 1:\n#         is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_CONFIRMED']\n#     else:\n#         is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_WAITING']\n\n#     photo_path = path_recp = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])\n#     bot.send_photo(message.chat.id, photo=open(photo_path, 'rb'),\n#                    caption=payment_received_template(payment,user_data,\n#                                                      footer=f\"{MESSAGES['PAYMENT_ACCEPT_STATUS']} {is_it_accepted}\\n{MESSAGES['CREATED_AT']} {payment['created_at']}\"),\n#                    reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_sub_status(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_sub_status)\n        return\n    bot_user = None\n    if len(message.text) == 7:\n        user = USERS_DB.find_order_subscription(id=int(message.text))\n        if user:\n            orders = USERS_DB.find_order(id=user[0]['order_id'])\n            if orders:\n                bot_users = USERS_DB.find_user(telegram_id=orders[0]['telegram_id'])\n                if bot_users:\n                    bot_user = bot_users[0]\n    elif len(message.text) == 8:\n        user = USERS_DB.find_non_order_subscription(id=int(message.text))\n        if user:\n            bot_users = USERS_DB.find_user(telegram_id=user[0]['telegram_id'])\n            if bot_users:\n                bot_user = bot_users[0]\n    else:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    \n    if not bot_user:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    user_uuid = user[0]['uuid']\n    selected_server = None\n    servers = USERS_DB.select_servers()\n    usr = None\n    if servers:\n        for server in servers:\n            URL = server['url'] + API_PATH\n            usr = utils.user_info(URL, user_uuid)\n            if usr:\n                selected_server = server\n                break\n            else:\n                continue\n        if not usr:\n            bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n            return\n        bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_SUB'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n        msg = templates.user_info_template(usr, selected_server)\n        bot.send_message(message.chat.id, msg,\n                        reply_markup=markups.sub_search_info_markup(usr['uuid'], bot_user))\n\n\n\n\ndef users_bot_settings_min_depo(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_min_depo)\n        return\n    new_min_depo = utils.toman_to_rial(message.text)\n    new_min_depo = int(new_min_depo)\n    status = USERS_DB.edit_int_config(\"min_deposit_amount\", value=new_min_depo)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_channel_id(message: Message):\n    if is_it_cancel(message):\n        return\n    if not message.text.startswith('@'):\n        bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_USERNAME'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n    status = USERS_DB.edit_str_config(\"channel_id\", value=message.text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_welcome_msg(message: Message):\n    if is_it_cancel(message):\n        return\n    \n    status = USERS_DB.edit_str_config(\"msg_user_start\", value=message.html_text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef users_bot_settings_set_faq_msg(message: Message, msg):\n    if is_it_cancel(message):\n        return\n    \n    status = USERS_DB.edit_str_config(\"msg_faq\", value=message.html_text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    try:\n        bot.edit_message_reply_markup(message.chat.id, msg.message_id,\n                                  reply_markup=markups.users_bot_management_settings_faq_markup())\n    except:\n        pass\n\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef users_bot_settings_test_sub_size(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_test_sub_size)\n        return\n    # if float convert float else convert int\n    if '.' in message.text:\n        new_test_sub_size = float(message.text)\n    else:\n        new_test_sub_size = int(message.text)  \n    status = USERS_DB.edit_int_config(\"test_sub_size_gb\", value=new_test_sub_size)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_test_sub_days(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_test_sub_days)\n        return\n    new_test_sub_days = int(message.text)\n    status = USERS_DB.edit_int_config(\"test_sub_days\", value=new_test_sub_days)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_notif_reminder_usage(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_notif_reminder_usage)\n        return\n    if '.' in message.text:\n        new_reminder_usage = float(message.text)\n    else:\n        new_reminder_usage = int(message.text)\n    status = USERS_DB.edit_int_config(\"reminder_notification_usage\", value=new_reminder_usage)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_notif_reminder_days(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_notif_reminder_days)\n        return\n    new_test_sub_days = int(message.text)\n    status = USERS_DB.edit_int_config(\"reminder_notification_days\", value=new_test_sub_days)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\n\ndef users_bot_settings_panel_manual(message: Message, db_key):\n    if is_it_cancel(message):\n        return\n    status = USERS_DB.edit_str_config(db_key, value=message.html_text)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef users_bot_settings_restore_bot(message: Message):\n    if is_it_cancel(message):\n        return\n    # save file\n    file_name = message.document.file_name\n    file_info = bot.get_file(message.document.file_id)\n    downloaded_file = bot.download_file(file_info.file_path)\n    file_save_path = os.path.join(BOT_BACKUP_LOC,\"Restore\")\n    if not os.path.exists(file_save_path):\n        os.makedirs(file_save_path)\n        \n    # save in Backup/bot/restore\n    \n    with open(os.path.join(file_save_path,file_name), 'wb') as new_file:\n        new_file.write(downloaded_file)\n        \n    restore_status = utils.restore_json_bot(os.path.join(file_save_path,file_name))\n    if not restore_status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_RESTORE_BOT'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef users_bot_settings_renewal_method_advanced_days(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_renewal_method_advanced_days)\n        return\n    new_test_sub_days = int(message.text)\n    status = USERS_DB.edit_int_config(\"advanced_renewal_days\", value=new_test_sub_days)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef users_bot_settings_renewal_method_advanced_usage(message: Message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, users_bot_settings_renewal_method_advanced_usage)\n        return\n    if '.' in message.text:\n        new_renewal_usage = float(message.text)\n    else:\n        new_renewal_usage = int(message.text)\n    status = USERS_DB.edit_int_config(\"advanced_renewal_usage\", value=new_renewal_usage)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n\ndef edit_wallet_balance(message: Message,telegram_id):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=markups.while_edit_user_markup()):\n        bot.register_next_step_handler(message, edit_wallet_balance)\n        return\n    new_balance = utils.toman_to_rial(message.text)\n    wallet_status = USERS_DB.find_wallet(telegram_id=telegram_id)\n    if not wallet_status:\n        status = USERS_DB.add_wallet(telegram_id=telegram_id)\n        if not status:\n                bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n                return\n    status = USERS_DB.edit_wallet(telegram_id=telegram_id, balance=new_balance)\n    if not status:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n    bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())\n    user_bot.send_message(telegram_id, f\"{MESSAGES['WALLET_BALANCE_CHANGED_BY_ADMIN_P1']} {message.text} {MESSAGES['WALLET_BALANCE_CHANGED_BY_ADMIN_P2']}\")\n    \n\n\ndef send_message_to_user(message: Message, payment_id):\n    if is_it_cancel(message):\n        return\n    payment_info = USERS_DB.find_payment(id=int(payment_id))\n    if not payment_info:\n        bot.send_message(message.chat.id,\n                            f\"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n        return\n    payment_info = payment_info[0]\n    user_bot.send_message(int(payment_info['telegram_id']),\n                        f\"{MESSAGES['ADMIN']}\\n{message.text}\\n{MESSAGES['ORDER_ID']} {payment_id}\",\n                        reply_markup=markups.send_message_to_user_markup(message.chat.id))\n    bot.send_message(message.chat.id, MESSAGES['MESSAGE_SENDED'],\n                        reply_markup=markups.main_menu_keyboard_markup())\n    \ndef users_bot_send_message_to_user(message: Message, telegram_id):\n    if is_it_cancel(message):\n        return\n    user_bot.send_message(int(telegram_id),\n                        f\"{MESSAGES['MESSAGE_FROM_ADMIN']}\\n{MESSAGES['MESSAGE_TEXT']} {message.text}\", reply_markup=markups.send_message_to_user_markup(message.chat.id))\n    bot.send_message(message.chat.id, MESSAGES['MESSAGE_SENDED'],\n                        reply_markup=markups.main_menu_keyboard_markup())\n    \n# ----------------------------------- Callbacks -----------------------------------\n# Callback Handler for Inline Buttons\n@bot.callback_query_handler(func=lambda call: True)\ndef callback_query(call: CallbackQuery):\n    logging.info(f\"Callback Query: {call.data}\")\n    bot.answer_callback_query(call.id, MESSAGES['WAIT'])\n    # Check if user is not admin\n    if call.from_user.id not in ADMINS_ID:\n        bot.answer_callback_query(call.id, MESSAGES['ERROR_NOT_ADMIN'])\n        return\n    bot.clear_step_handler(call.message)\n    # Split Callback Data to Key(Command) and UUID\n    data = call.data.split(':')\n    key = data[0]\n    value = data[1]\n    global URL\n    #Single , Single_name , Single_expired , All_server_name , All_server_expired\n    global search_mode\n    # All , Single\n    global server_mode\n    global searched_name\n    global selected_server \n    #User_Orders, User_Payments, User_Gifts, Orders, Approved_Payments\n    #Non_Approved_Payments, Pending_Payments, Card_Payments, Digital_Payments\n    #Bot_User, Bot_Users_Search_Name, User_Refferals\n    global list_mode \n    #Order, Payment, Gift\n    global item_mode\n    global selected_telegram_id\n    # ----------------------------------- Users List Area Callbacks -----------------------------------\n    # Single User Info Callback\n    if key == \"info\":\n        if server_mode == \"Single\":\n            usr = utils.user_info(URL, value)\n        else:\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    URL = server['url'] + API_PATH\n                    usr = utils.user_info(URL, value)\n                    if usr:\n                        selected_server = server\n                        break\n        if not usr:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        msg = templates.user_info_template(usr, selected_server)\n        bot.send_message(call.message.chat.id, msg,\n                        reply_markup=markups.user_info_markup(usr['uuid']))\n\n\n    # Next Page Callback\n    elif key == \"next\":\n        # users_list = utils.dict_process(utils.users_to_dict(ADMIN_DB.select_users()))\n        users_list = []\n        server_id = selected_server['id']\n        if search_mode == \"Single\":\n            users_list = api.select(URL)\n            server_id = selected_server['id']\n        elif search_mode == \"Single_name\":\n            users_list = utils.search_user_by_name(URL, searched_name)\n            server_id = selected_server['id']\n        elif search_mode == \"Single_expired\":\n            users_list = api.select(URL)\n            users_list = utils.expired_users_list(users_list)\n            server_id = selected_server['id']\n        elif search_mode == \"All_server_name\":\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    server_url = server['url'] + API_PATH\n                    searched_users = utils.search_user_by_name(server_url, searched_name)\n                    users_list.extend(searched_users)\n            server_id = \"None\"\n        elif search_mode == \"All_server_expired\":\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    server_url = server['url'] + API_PATH\n                    users = api.select(server_url)\n                    users = utils.expired_users_list(users)\n                    users_list.extend(users)\n            server_id = \"None\"\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.users_list_markup(server_id, users_list, int(value)))\n\n    # ----------------------------------- Single User Info Area Callbacks -----------------------------------\n    # Delete User Callback\n    elif key == \"user_delete\":\n        # status = ADMIN_DB.delete_user(uuid=value)\n        bot.send_message(call.message.chat.id, MESSAGES['FEATUR_UNAVAILABLE'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n        return\n        # if not status:\n        #     bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n        #                      reply_markup=markups.main_menu_keyboard_markup())\n        #     return\n        # bot.delete_message(call.message.chat.id, call.message.message_id)\n        # bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_USER_DELETED'],\n        #                  reply_markup=markups.main_menu_keyboard_markup())\n    # Edit User Main Button Callback\n    elif key == \"user_edit\":\n        if server_mode == \"All\":\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    users_list = api.find(server['url'] + API_PATH, value)\n                    if users_list:\n                        URL = server['url'] + API_PATH\n                        selected_server = server\n                        break\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.edit_user_markup(value))\n\n    # Configs User Callback\n    elif key == \"user_config\":\n        if server_mode == \"All\":\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    users_list = api.find(server['url'] + API_PATH, value)\n                    if users_list:\n                        URL = server['url'] + API_PATH\n                        selected_server = server\n                        break\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.sub_url_user_list_markup(value))\n\n    # ----------------------------------- Edit User Area Callbacks -----------------------------------\n    # Edit User - Update Message Callback\n    elif key == \"user_edit_update\":\n        usr = utils.user_info(URL, value)\n        if not usr:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        msg = templates.user_info_template(usr, selected_server, MESSAGES['EDITED_USER_INFO'])\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.edit_user_markup(value))\n    # Edit User - Edit Usage Callback\n    elif key == \"user_edit_usage\":\n        bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_USAGE_LIMIT'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_user_usage, value)\n    # Edit User - Reset Usage Callback\n    elif key == \"user_edit_reset_usage\":\n        status = api.update(URL, uuid=value, current_usage_GB=0)\n        if not status:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n            return\n        bot.send_message(call.message.chat.id, MESSAGES['RESET_USAGE'],\n                         reply_markup=markups.main_menu_keyboard_markup())\n    # Edit User - Edit Days Callback\n    elif key == \"user_edit_days\":\n        bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_DAYS'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_user_days, value)\n    # Edit User - Reset Days Callback\n    elif key == \"user_edit_reset_days\":\n        # status = ADMIN_DB.reset_package_days(uuid=value)\n        last_reset_time = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n        status = api.update(URL, uuid=value, start_date=last_reset_time)\n        # api.insert()\n        if not status:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                             reply_markup=markups.main_menu_keyboard_markup())\n            return\n        bot.send_message(call.message.chat.id, MESSAGES['RESET_DAYS'], reply_markup=markups.main_menu_keyboard_markup())\n    # Edit User - Edit Comment Callback\n    elif key == \"user_edit_comment\":\n        bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_COMMENT'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_user_comment, value)\n    # Edit User - Edit Name Callback\n    elif key == \"user_edit_name\":\n        bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_NAME'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_user_name, value)\n\n    # ----------------------------------- Configs User Info Area Callbacks -----------------------------------\n    # User Configs - DIR Configs Callback\n\n    elif key == \"conf_dir\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.sub_user_list_markup(value,configs))\n    # User Configs - VLESS Configs Callback\n    elif key == \"conf_dir_vless\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['vless']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = templates.configs_template(configs['vless'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=markups.main_menu_keyboard_markup())\n    # User Configs - VMess Configs Callback\n    elif key == \"conf_dir_vmess\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['vmess']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = templates.configs_template(configs['vmess'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=markups.main_menu_keyboard_markup())\n    # User Configs - Trojan Configs Callback\n    elif key == \"conf_dir_trojan\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['trojan']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = templates.configs_template(configs['trojan'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=markups.main_menu_keyboard_markup())\n\n    # User Configs - Main Menu\n    elif key == 'configs_list':\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.sub_url_user_list_markup(value))\n        \n    # User Configs - Subscription Configs Callback\n    elif key == \"conf_sub_url\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB']}\\n<code>{sub['sub_link']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n    # User Configs - Base64 Subscription Configs Callback\n    elif key == \"conf_sub_url_b64\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link_b64'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB_B64']}\\n<code>{sub['sub_link_b64']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n    # User Configs - Subscription Configs For Clash Callback\n    elif key == \"conf_clash\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['clash_configs'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_CLASH']}\\n<code>{sub['clash_configs']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n    # User Configs - Subscription Configs For Hiddify Callback\n    elif key == \"conf_hiddify\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['hiddify_configs'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_HIDDIFY']}\\n<code>{sub['hiddify_configs']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_auto\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link_auto'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB_AUTO']}\\n<code>{sub['sub_link_auto']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_sing_box\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sing_box'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SING_BOX']}\\n<code>{sub['sing_box']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_full_sing_box\":\n        sub = utils.sub_links(value, URL)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sing_box_full'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_FULL_SING_BOX']}\\n<code>{sub['sing_box_full']}</code>\",\n            reply_markup=markups.main_menu_keyboard_markup()\n        )\n\n    else:\n        bot.answer_callback_query(call.id, MESSAGES['ERROR_INVALID_COMMAND'])\n\n    # ----------------------------------- Search User Area Callbacks -----------------------------------\n    # Search User - Name Callback\n    if key == \"search_name\":\n        bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_NAME'],\n                         reply_markup=markups.while_edit_user_markup())\n        if value == \"None\":\n            search_mode = \"All_server_name\"\n            bot.register_next_step_handler(call.message, all_server_search_user_name)\n        else:\n            search_mode = \"Single_name\"\n            bot.register_next_step_handler(call.message, search_user_name, value)\n    # Search User - UUID Callback\n    elif key == \"search_uuid\":\n        bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_UUID'],\n                         reply_markup=markups.while_edit_user_markup())\n        if value == \"None\":\n            bot.register_next_step_handler(call.message, all_server_search_user_uuid)\n        else:\n            bot.register_next_step_handler(call.message, search_user_uuid, value)\n    # Search User - Config Callback\n    elif key == \"search_config\":\n        bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_CONFIG'],\n                         reply_markup=markups.while_edit_user_markup())\n        if value == \"None\":\n            bot.register_next_step_handler(call.message, all_server_search_user_config)\n        else:\n            bot.register_next_step_handler(call.message, search_user_config, value)\n    # Search User - Expired Callback\n    elif key == \"search_expired\":\n        users_list = []\n        if value == \"None\":\n            search_mode = \"All_server_expired\"\n            servers = USERS_DB.select_servers()\n            if servers:\n                for server in servers:\n                    server_url = server['url'] + API_PATH\n                    users = api.select(server_url)\n                    users = utils.expired_users_list(users)\n                    users_list.extend(users)\n        else:\n            search_mode = \"Single_expired\"\n            users_list = api.select(URL)\n            users_list = utils.expired_users_list(users_list)\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        msg = templates.users_list_template(users_list, MESSAGES['EXPIRED_USERS_LIST'])\n        bot.send_message(call.message.chat.id, msg, reply_markup=markups.users_list_markup(value, users_list))\n\n    # ----------------------------------- Server Management Callbacks -----------------------------------\n    elif key == \"server_selected\":\n        server_mode = \"Single\"\n        server = USERS_DB.find_server(id=int(value))\n        if not server:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n            return\n        server = server[0]\n        URL = server['url'] + API_PATH\n        selected_server = server\n        plans = USERS_DB.select_plans()\n        msg = templates.server_info_template(server,plans)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.server_selected_markup(value))\n\n    # Server Management - Add Server Callback\n    elif key == \"add_server\":\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_TITLE'])\n        bot.register_next_step_handler(call.message, add_server_title)\n\n    # Server Management - Delete Server Callback\n    elif key == \"delete_server\":\n        bot.edit_message_text(MESSAGES['DELETE_SERVER_QUESTION'], call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.server_delete_markup(value))\n    \n    # Server Management - Edit Server Callback\n    elif key == \"edit_server\":\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.server_edit_markup(value))\n        \n    # Server Management - Edit Title Server Callback\n    elif key == \"server_edit_title\":\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_TITLE'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_server_title, value)\n        \n    # Server Management - Edit User Limit Server Callback\n    elif key == \"server_edit_user_limit\":\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_USER_LIMIT'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_server_user_limit, value)\n\n    # Server Management - Edit Url Server Callback\n    elif key == \"server_edit_url\":\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_URL'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_server_url, value)\n    # Server Management - Confirm Delete Server Callback\n    elif key == \"confirm_delete_server\":\n        server_id = int(value)\n        #status = USERS_DB.edit_server(value, status=0)\n        status = USERS_DB.delete_server(id=server_id)\n        if not status:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        \n        USERS_DB.delete_plan(server_id=server_id)\n        USERS_DB.delete_order_subscription(server_id=server_id)\n        USERS_DB.delete_non_order_subscription(server_id=server_id)\n    \n        servers = USERS_DB.select_servers()\n        bot.edit_message_text(KEY_MARKUP['SERVERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.servers_management_markup(servers)) \n        bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_REMOVED_SERVER'], reply_markup=markups.main_menu_keyboard_markup())\n\n        \n    # Server Management - List of Plans for Server Callback\n    elif key == \"server_list_of_plans\":\n        plans_list = []\n        plans = USERS_DB.select_plans()\n        if plans:\n            for plan in plans:\n                if plan['status']:\n                    if plan['server_id'] == int(value):\n                        plans_list.append(plan)\n        plans_markup = markups.plans_list_markup(plans_list,value)\n        bot.edit_message_text({MESSAGES['USERS_BOT_PLANS_LIST']}, call.message.chat.id, call.message.message_id,\n                         reply_markup=plans_markup)\n        \n    elif key == \"server_list_of_users\":\n        users_list = api.select(URL)\n        search_mode = \"Single\"\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        msg = templates.users_list_template(users_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_list_markup(value, users_list))\n    \n    elif key == \"server_add_user\":\n        global add_user_data\n        bot.send_message(call.message.chat.id, MESSAGES['ADD_USER_NAME'], reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, add_user_name, value)\n\n    elif key == \"server_search_user\":\n        bot.edit_message_text(MESSAGES['SEARCH_USER'],call.message.chat.id, call.message.message_id, \n                              reply_markup=markups.search_user_markup(server_id=value))\n\n    # ----------------------------------- Users Bot Management Callbacks -----------------------------------\n    elif key == \"users_bot_management_menu\":\n        bot.edit_message_text(KEY_MARKUP['USERS_BOT_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_markup())\n        \n    elif key == \"bot_users_list_management\":\n         bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_users_management_markup())\n        \n    elif key == \"bot_users_list\":\n        list_mode = \"Bot_Users\"\n        users_list = USERS_DB.select_users()\n        wallets_list = USERS_DB.select_wallet()\n        orders_list = USERS_DB.select_orders()\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        users_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_users_list_template(users_list, wallets_list, orders_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_users_list_markup(users_list))\n        users_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n    elif key == \"search_users_bot\":\n         \n         bot.edit_message_text(MESSAGES['SEARCH_USER'], call.message.chat.id, call.message.message_id,\n                          reply_markup=markups.users_bot_users_search_method_markup())\n    \n    elif key == \"bot_users_search_name\":\n        list_mode = \"Bot_Users\"\n        bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_NAME'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, search_bot_user_name)\n\n    elif key == \"bot_users_search_telegram_id\":\n        bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_TELEGRAM_ID'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, search_bot_user_telegram_id)\n\n    elif key == \"bot_user_info\":\n        selected_telegram_id = value\n        users = USERS_DB.find_user(telegram_id=int(value))\n        if not users:\n             bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                              reply_markup=markups.main_menu_keyboard_markup())\n             return\n        user = users[0]\n        orders = USERS_DB.find_order(telegram_id=user['telegram_id'])\n        paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])\n        wallet = None\n        wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])\n        if wallets:\n            wallet = wallets[0]\n        non_order_subs = utils.non_order_user_info(user['telegram_id'])\n        order_subs = utils.order_user_info(user['telegram_id'])\n        plans_list = USERS_DB.select_plans()\n        msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)\n        bot.send_message(call.message.chat.id, msg, reply_markup=markups.bot_user_info_markup(value))\n\n    elif key == \"bot_user_next\":\n        if list_mode == \"Bot_Users\":\n           users_list = USERS_DB.select_users()\n        elif list_mode == \"Bot_Users_Search_Name\":\n            users_list = USERS_DB.find_user(full_name=searched_name)\n        elif list_mode == \"User_Refferals\":\n            users_list = USERS_DB.find_user(telegram_id=int(selected_telegram_id))\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return \n        users_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.bot_users_list_markup(users_list, int(value)))\n\n\n    elif key == \"bot_user_item_info\":\n        if item_mode == \"Order\":\n            orders = USERS_DB.find_order(id=int(value))\n            if not orders:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            order = orders[0]\n            plans = USERS_DB.find_plan(id=order['plan_id'])\n            if not plans:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            plan = plans[0]\n            #subs = \n            users = USERS_DB.find_user(telegram_id=order['telegram_id'])\n            if not users:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            user = users[0]\n            servers = USERS_DB.find_server(id=plan['server_id'])\n            if not servers:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            server = servers[0]\n            msg = templates.bot_orders_info_template(order, plan, user, server)\n            bot.send_message(call.message.chat.id, msg)\n        elif item_mode == \"Payment\":\n            payments = USERS_DB.find_payment(id=int(value))\n            if not payments:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n                return\n            payment = payments[0]\n            user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n            if not user_data:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n                return\n            user_data = user_data[0]\n            msg = templates.bot_payment_info_template(payment,user_data)\n            photo_path = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])\n            if payment['approved'] == None:\n                bot.send_photo(call.message.chat.id, photo=open(photo_path, 'rb'),\n                            caption=msg, reply_markup=markups.confirm_payment_by_admin(payment['id']))\n            else:\n                bot.send_photo(call.message.chat.id, photo=open(photo_path, 'rb'),\n                            caption=msg, reply_markup=markups.change_status_payment_by_admin(payment['id']))\n        elif item_mode == \"Gift\":\n            gift = USERS_DB.find_user_plans(id=int(value))\n\n    elif key == \"bot_user_item_next\":\n        if list_mode == \"User_Orders\":\n            item_list = USERS_DB.find_order(telegram_id=int(selected_telegram_id))\n        elif list_mode == \"User_Payments\":\n            item_list = USERS_DB.find_payment(telegram_id=int(selected_telegram_id))\n        elif list_mode == \"User_Gifts\":\n            item_list = USERS_DB.find_user_plans(telegram_id=int(selected_telegram_id))\n        elif list_mode == \"Orders\":\n            item_list = USERS_DB.select_orders()\n        if list_mode == \"Approved_Payments\":\n            payments_list = USERS_DB.select_payments()\n            item_list = [payment for payment in payments_list if payment['approved'] == 1]\n        elif list_mode == \"Non_Approved_Payments\":\n            payments_list = USERS_DB.select_payments()\n            item_list = [payment for payment in payments_list if payment['approved'] == 0]\n        elif list_mode == \"Pending_Payments\":\n            payments_list = USERS_DB.select_payments()\n            item_list = [payment for payment in payments_list if payment['approved'] == None]\n        elif list_mode == \"Card_Payments\":\n            payments_list = USERS_DB.select_payments()\n            item_list = [payment for payment in payments_list if payment['payment_method'] == \"Card\"]\n        elif list_mode == \"Digital_Payments\":\n            payments_list = USERS_DB.select_payments()\n            item_list = [payment for payment in payments_list if payment['payment_method'] == \"Digital\"]\n        if not item_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return \n        if not list_mode == \"User_Gifts\":\n            item_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.bot_user_item_list_markup(item_list, int(value)))\n\n    elif key == \"bot_users_sub_user_list\":\n        server_mode = \"All\"\n        subs = utils.non_order_user_info(int(value))\n        order_subs = utils.order_user_info(int(value))\n        if order_subs:\n            subs.extend(order_subs)\n        if not subs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'])\n            return\n        msg = templates.users_list_template(subs)\n        bot.send_message(call.message.chat.id, msg, reply_markup=markups.users_list_markup(\"None\", subs))\n\n    elif key == \"users_bot_orders_user_list\":\n        list_mode = \"User_Orders\"\n        item_mode = \"Order\"\n        orders_list = USERS_DB.find_order(telegram_id=int(value))\n        \n        plans_list = USERS_DB.select_plans()\n        if not orders_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'])\n            return\n        orders_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_orders_list_template(orders_list, plans_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(orders_list))\n\n    elif key == \"users_bot_payments_user_list\":\n        list_mode = \"User_Payments\"\n        item_mode = \"Payment\"\n        paymets = USERS_DB.find_payment(telegram_id=int(value))\n        if not paymets:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        paymets.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(paymets)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(paymets))\n    \n    elif key == \"users_bot_wallet_edit_balance\":\n        bot.send_message(call.message.chat.id, MESSAGES['EDIT_WALLET_BALANCE'],\n                            reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, edit_wallet_balance, value)\n    \n    elif key == \"users_bot_reset_test\":\n        users = USERS_DB.find_user(telegram_id=int(value))\n        if not users:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n        user = users[0]\n        if user['test_subscription'] == 0:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_HAVE_TEST_SUB'])\n            return\n        status = USERS_DB.edit_user(telegram_id=int(value), test_subscription=0)\n        if not status:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_RESET_TEST_SUB'])\n    \n    elif key == \"users_bot_ban_user\":\n        users = USERS_DB.find_user(telegram_id=int(value))\n        if not users:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n        user = users[0]\n        if user['banned'] == 0:\n            status = USERS_DB.edit_user(telegram_id=int(value), banned=1)\n            if not status:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n            bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_BAN_USER'])\n            return\n        if user['banned'] == 1:\n            status = USERS_DB.edit_user(telegram_id=int(value), banned=0)\n            if not status:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n            bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_UNBAN_USER'])\n            return\n    elif key == \"users_bot_gifts_user_list\":\n        list_mode = \"User_Gifts\"\n        item_mode = \"Gift\"\n        gift = USERS_DB.find_user_plans(telegram_id=int(value))\n        if not gift:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_GIFT_NOT_FOUND'])\n            return\n        # msg = templates.bot_gift_list_template(paymets)\n        # bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n        #                       reply_markup=markups.bot_user_item_list_markup(gift))\n\n    elif key == \"users_bot_referred_user_list\":\n        list_mode = \"User_Refferals\"\n        users = USERS_DB.find_user(telegram_id=int(value))\n        if not users:\n             bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                              reply_markup=markups.main_menu_keyboard_markup())\n             return\n        user = users[0] \n        #referred_user = \n\n\n\n    elif key == \"users_bot_orders_list_management\":\n        bot.edit_message_text(KEY_MARKUP['ORDERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_orders_management_markup())\n\n    elif key == \"users_bot_orders_list\":\n        list_mode = \"Orders\"\n        item_mode = \"Order\"\n        orders_list = USERS_DB.select_orders()\n        plans_list = USERS_DB.select_plans()\n        if not orders_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'])\n            return\n        orders_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_orders_list_template(orders_list, plans_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(orders_list))\n        \n\n    elif key == \"search_orders\":\n        bot.send_message(call.message.chat.id, MESSAGES['ORDER_NUMBER_REQUEST'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, search_bot_user_order)\n        \n\n    elif key == \"users_bot_payments_list_management\":\n         bot.edit_message_text(KEY_MARKUP['PAYMENT_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_payments_management_markup())\n        \n    elif key == \"search_payments\":\n        bot.send_message(call.message.chat.id, MESSAGES['PAYMENT_NUMBER_REQUEST'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, search_bot_user_payment)\n\n    elif key == \"bot_users_approved_payments_list\":\n        list_mode = \"Approved_Payments\"\n        item_mode = \"Payment\"\n        payments_list = USERS_DB.select_payments()\n        if not payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        approved_payments_list = [payment for payment in payments_list if payment['approved'] == 1]\n        if not approved_payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        approved_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(approved_payments_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(approved_payments_list))\n\n    elif key == \"users_bot_non_approved_payments_list\":\n        list_mode = \"Non_Approved_Payments\"\n        item_mode = \"Payment\"\n        payments_list = USERS_DB.select_payments()\n        if not payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        non_approved_payments_list = [payment for payment in payments_list if payment['approved'] == 0]\n        if not non_approved_payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        non_approved_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(non_approved_payments_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(non_approved_payments_list))\n\n    elif key == \"users_bot_pending_payments_list\":\n        list_mode = \"Pending_Payments\"\n        item_mode = \"Payment\"\n        payments_list = USERS_DB.select_payments()\n        if not payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        pending_payments_list = [payment for payment in payments_list if payment['approved'] == None]\n        if not pending_payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        pending_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(pending_payments_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(pending_payments_list))\n\n    elif key == \"users_bot_card_payments_list\":\n        list_mode = \"Card_Payments\"\n        item_mode = \"Payment\"\n        payments_list = USERS_DB.select_payments()\n        if not payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        card_payments_list = [payment for payment in payments_list if payment['payment_method'] == \"Card\"]\n        if not card_payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        card_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(card_payments_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(card_payments_list))\n\n    elif key == \"users_bot_digital_payments_list\":\n        list_mode = \"Digital_Payments\"\n        item_mode = \"Payment\"\n        payments_list = USERS_DB.select_payments()\n        if not payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        digital_payments_list = [payment for payment in payments_list if payment['payment_method'] == \"Digital\"]\n        if not digital_payments_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        digital_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)\n        msg = templates.bot_payments_list_template(digital_payments_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.bot_user_item_list_markup(digital_payments_list))\n\n\n    # Plan Management - Add Plan Callback\n    elif key == \"users_bot_add_plan\":\n        bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN'],\n                         reply_markup=markups.while_edit_user_markup())\n        bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_USAGE'])\n        add_plan_data['server_id'] = int(value)\n        bot.register_next_step_handler(call.message, users_bot_add_plan_usage)\n\n    # Plan Management - Info Plan Callback\n    elif key == \"info_plan_selected\":\n        plans= USERS_DB.find_plan(id=value)\n        if not plans:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        orders = USERS_DB.find_order(plan_id=value)\n        plan = plans[0]\n        msg = templates.plan_info_template(plan, orders)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.plan_info_selected_markup(plan['server_id']))\n\n\n\n    # Plan Management - Edit Plan Callback\n    elif key == \"users_bot_del_plan\":\n        status = USERS_DB.edit_plan(value, status=0)\n        if status:\n            plans= USERS_DB.find_plan(id=value)\n            if not plans:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n            del_plan = plans[0]\n            server_id = del_plan['server_id']\n            plans_list = []\n            plans = USERS_DB.select_plans()\n            if plans:\n                for plan in plans:\n                    if plan['status']:\n                        if plan['server_id'] == server_id:\n                            plans_list.append(plan)\n            plans_markup = markups.plans_list_markup(plans_list, server_id,delete_mode = True)\n            bot.edit_message_text({MESSAGES['USERS_BOT_SELECT_PLAN_TO_DELETE']}, call.message.chat.id, call.message.message_id,\n                         reply_markup=plans_markup)\n        else:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n\n    # Plan Management - List Plans Callback\n    elif key == \"users_bot_list_plans\":\n        plans_list = []\n        plans = USERS_DB.select_plans()\n        if plans:\n            for plan in plans:\n                if plan['status']:\n                    if plan['server_id'] == int(value):\n                        plans_list.append(plan)\n        plans_markup = markups.plans_list_markup(plans_list,value,delete_mode = True)\n        bot.edit_message_text({MESSAGES['USERS_BOT_SELECT_PLAN_TO_DELETE']}, call.message.chat.id, call.message.message_id,\n                         reply_markup=plans_markup)\n\n    # Owner Info - Edit Owner Info Callback\n    elif key == \"users_bot_owner_info\":\n        owner_info = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         templates.owner_info_template(owner_info['support_username'], owner_info['card_number'],\n                                                       owner_info['card_holder']),\n                         reply_markup=markups.users_bot_edit_owner_info_markup())\n    # Owner Info - Edit Owner Username Callback\n    elif key == \"users_bot_owner_info_edit_username\":\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_USERNAME']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_edit_owner_info_username)\n\n    # Owner Info - Edit Owner Card Number Callback\n    elif key == \"users_bot_owner_info_edit_card_number\":\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_edit_owner_info_card_number)\n\n    # Owner Info - Edit Owner Cardholder Callback\n    elif key == \"users_bot_owner_info_edit_card_name\":\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_CARD_NAME']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_edit_owner_info_card_name)\n\n    # Send Message - Send Message To All Users Callback\n    elif key == \"users_bot_send_msg_users\":\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_SEND_MSG_USERS']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_send_msg_users)\n\n    # User Bot Settings  - Main Settings Callback\n    elif key == \"users_bot_settings\":\n        settings = USERS_DB.select_bool_config()\n        if not settings:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        settings = utils.all_configs_settings()\n        bot.edit_message_text(MESSAGES['USERS_BOT_SETTINGS'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_management_settings_markup(settings))\n\n    # User Bot Settings  - Set Hyperlink Status Callback\n    elif key == \"users_bot_settings_hyperlink\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"visible_hiddify_hyperlink\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"visible_hiddify_hyperlink\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n\n    # User Bot Settings  - Set three random letters for define price\n    elif key == \"users_bot_settings_three_rand_price\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"three_random_num_price\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"three_random_num_price\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n\n    elif key == \"users_bot_settings_panel_auto_backup\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"panel_auto_backup\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"panel_auto_backup\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n    \n    elif key == \"users_bot_settings_bot_auto_backup\": \n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"bot_auto_backup\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"bot_auto_backup\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n\n    elif key == \"users_bot_settings_min_depo\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {utils.rial_to_toman(settings['min_deposit_amount'])}\\n{MESSAGES['USERS_BOT_SETTING_MIN_DEPO']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_min_depo)\n\n    # elif key == \"users_bot_settings_panel_v8\":\n    #     if value == \"1\":\n    #         edit_config = USERS_DB.edit_bool_config(\"hiddify_v8_feature\", value=False)\n    #         if not edit_config:\n    #             bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n    #             return\n    #     elif value == \"0\":\n    #         edit_config = USERS_DB.edit_bool_config(\"hiddify_v8_feature\", value=True)\n    #         if not edit_config:\n    #             bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n    #             return\n    #     users_bot_settings_update_message(call.message)\n\n    elif key == \"users_bot_settings_channel_id\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['channel_id']}\\n{MESSAGES['USERS_BOT_SETTING_CHANNEL_ID']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_channel_id)\n\n    elif key == \"users_bot_settings_force_join\":\n        settings = utils.all_configs_settings()\n        if not settings['channel_id']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CHANNEL_ID_NOT_SET'])\n            return\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"force_join_channel\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"force_join_channel\", value=True)\n            bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_SETTING_FORCE_JOIN_HELP'])\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n\n    elif key == \"users_bot_settings_visible_sub_menu\":\n        settings = utils.all_configs_settings()\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_visible_sub_markup(settings))\n    elif key == \"users_bot_settings_visible_sub\":\n        settings = utils.all_configs_settings()\n        row_key = value\n        current_status = settings[row_key]\n        if current_status == 1:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif current_status == 0:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message,\n                                          markups.users_bot_management_settings_visible_sub_markup(settings))\n\n    elif key == \"users_bot_settings_set_welcome_msg\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['msg_user_start']}\\n{MESSAGES['USERS_BOT_SETTING_WELCOME_MSG']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_welcome_msg)\n\n    elif key == \"users_bot_settings_faq_management\":\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_faq_markup())\n\n    elif key == \"users_bot_settings_set_faq_msg\":\n        settings = utils.all_configs_settings()\n        faq_text = settings['msg_faq']\n        msg = call.message\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {faq_text}\\n{MESSAGES['USERS_BOT_SETTING_FAQ_MSG']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_set_faq_msg, msg)\n\n    elif key == \"users_bot_settings_hide_faq\":\n        settings = utils.all_configs_settings()\n        status = USERS_DB.edit_str_config(\"msg_faq\", value=None)\n        if not status:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n            return\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.users_bot_management_settings_faq_markup())\n        \n    elif key == \"users_bot_settings_test_sub_menu\":\n        settings = utils.all_configs_settings()\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_test_sub_markup(settings))\n\n    elif key == \"users_bot_settings_test_sub\":\n        settings = utils.all_configs_settings()\n        row_key = value\n        current_status = settings['test_subscription']\n        if current_status == 1:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif current_status == 0:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_test_sub_markup(settings))\n    elif key == \"users_bot_settings_test_sub_size\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['test_sub_size_gb']} {MESSAGES['GB']}\\n{MESSAGES['USERS_BOT_SETTINGS_TEST_SUB_USAGE']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_test_sub_size)\n    elif key == \"users_bot_settings_test_sub_days\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['test_sub_days']} {MESSAGES['DAY']}\\n{MESSAGES['USERS_BOT_SETTINGS_TEST_SUB_DAYS']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_test_sub_days)\n\n    # User Bot Settings  - Reminder Notification Callback\n    elif key == \"users_bot_settings_notif_reminder_menu\":\n        settings = utils.all_configs_settings()\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_notif_reminder_markup(\n                                          settings))\n\n    elif key == \"users_bot_settings_notif_reminder\":\n        settings = utils.all_configs_settings()\n        row_key = value\n        current_status = settings['reminder_notification']\n        if current_status == 1:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif current_status == 0:\n            edit_config = USERS_DB.edit_bool_config(row_key, value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message,\n                                          markups.users_bot_management_settings_notif_reminder_markup(settings))\n\n    elif key == \"users_bot_settings_notif_reminder_usage\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['reminder_notification_usage']} {MESSAGES['GB']}\\n{MESSAGES['USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_notif_reminder_usage)\n    elif key == \"users_bot_settings_notif_reminder_days\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['reminder_notification_days']} {MESSAGES['DAY']}\\n{MESSAGES['USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_notif_reminder_days)\n    elif key == \"users_bot_settings_panel_manual_menu\":\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_panel_manual_markup())\n    elif key == \"users_bot_settings_panel_manual\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings[value]}\\n{MESSAGES['USERS_BOT_SETTINGS_PANEL_MANUAL']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_panel_manual, value)\n    elif key == \"users_bot_settings_backup_bot\":\n        backup_file = utils.backup_json_bot()\n        if not backup_file:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        bot.send_document(call.message.chat.id, open(backup_file, 'rb'),caption=MESSAGES['USERS_BOT_SETTINGS_BACKUP_BOT'])\n    \n    elif key == \"users_bot_settings_restore_bot\":\n        bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_SETTINGS_RESTORE_BOT'], reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_restore_bot)\n    \n    elif key == \"users_bot_settings_buy_sub_status\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"buy_subscription_status\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"buy_subscription_status\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n\n    elif key == \"users_bot_settings_renewal_sub_status\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_bool_config(\"renewal_subscription_status\", value=False)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"0\":\n            edit_config = USERS_DB.edit_bool_config(\"renewal_subscription_status\", value=True)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))\n    \n    elif key == \"users_bot_settings_renewal_method_menu\":\n        settings = utils.all_configs_settings()\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_renewal_method_markup(settings))\n    \n    elif key == \"users_bot_settings_renewal_method\":\n        if value == \"1\":\n            edit_config = USERS_DB.edit_int_config(\"renewal_method\", value=1)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"2\":\n            edit_config = USERS_DB.edit_int_config(\"renewal_method\", value=2)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        elif value == \"3\":\n            edit_config = USERS_DB.edit_int_config(\"renewal_method\", value=3)\n            if not edit_config:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n        settings = utils.all_configs_settings()\n        users_bot_settings_update_message(call.message, markups.users_bot_management_settings_renewal_method_markup(settings))\n    \n    elif key == \"users_bot_settings_renewal_method_advanced_days\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['advanced_renewal_days']} {MESSAGES['DAY']}\\n{MESSAGES['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_renewal_method_advanced_days)\n    elif key == \"users_bot_settings_renewal_method_advanced_usage\":\n        settings = utils.all_configs_settings()\n        bot.send_message(call.message.chat.id,\n                         f\"{MESSAGES['CURRENT_VALUE']}: {settings['advanced_renewal_usage']} {MESSAGES['GB']}\\n{MESSAGES['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_settings_renewal_method_advanced_usage)\n    # User Bot Settings  - Order Status Callback\n    # elif key == \"users_bot_orders_status\":\n    #     bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_ORDER_NUMBER_REQUEST']}\")\n    #     bot.register_next_step_handler(call.message, users_bot_order_status)\n\n    elif key == \"users_bot_sub_status\":\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['USERS_BOT_SUB_ID_REQUEST']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_sub_status)\n\n    elif key == \"users_bot_settings_reset_free_test_limit_question\":\n        bot.edit_message_text(MESSAGES['USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT_QUESTION'], call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.users_bot_management_settings_reset_free_test_markup())\n        \n    elif key == \"users_bot_management_settings_reset_free_test_confirm\":\n        users_list = USERS_DB.select_users()\n        free_test_bot_users =  [user for user in users_list if user['test_subscription']]\n        if free_test_bot_users:\n            for user in free_test_bot_users:\n                status = USERS_DB.edit_user(telegram_id=user['telegram_id'],test_subscription=False)\n                if not status:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())\n                    return\n            bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_RESET_FREE_TEST'], reply_markup=markups.main_menu_keyboard_markup())\n        else:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'], reply_markup=markups.main_menu_keyboard_markup())\n            \n            \n\n\n    # ----------------------------------- Payment Callbacks -----------------------------------\n    # Payment - Confirm Payment Callback\n    elif key == \"confirm_payment_by_admin\":\n        if not CLIENT_TOKEN:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n            return\n        payment_id = value\n        payment_info = USERS_DB.find_payment(id=payment_id)\n        if not payment_info:\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            return\n        payment_info = payment_info[0]\n        if payment_info['approved'] == 1:\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['ERROR_PAYMENT_ALREADY_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            return\n        \n        wallet = USERS_DB.find_wallet(telegram_id=payment_info['telegram_id'])\n        if not wallet:\n            create_wallet_status = USERS_DB.add_wallet(payment_info['telegram_id'])\n            if not create_wallet_status: \n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n            wallet = USERS_DB.find_wallet(telegram_id=payment_info['telegram_id'])\n\n        wallet = wallet[0]\n        payment_status = USERS_DB.edit_payment(payment_id, approved=True)\n        if payment_status:\n            new_balance = int(wallet['balance']) + int(payment_info['payment_amount'])\n            wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)\n            if not wallet_status:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                return\n            bot.delete_message(call.message.chat.id, call.message.message_id)\n            user_bot.send_message(int(payment_info['telegram_id']),\n                                  f\"{MESSAGES['WALLET_PAYMENT_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['PAYMENT_CONFIRMED_ADMIN']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n\n    # Payment - Reject Payment Callback\n    elif key == 'cancel_payment_by_admin':\n        if not CLIENT_TOKEN:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n            return\n        payment_id = value\n        payment_info = USERS_DB.find_payment(id=payment_id)\n        if not payment_info:\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            return\n        payment_info = payment_info[0]\n        if payment_info['approved'] == 0:\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['ERROR_PAYMENT_ALREADY_REJECTED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            return\n        payment_status = USERS_DB.edit_payment(payment_id, approved=False)\n        if payment_status:\n            user_bot.send_message(int(payment_info['telegram_id']),\n                                  f\"{MESSAGES['PAYMENT_NOT_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n            bot.send_message(call.message.chat.id,\n                             f\"{MESSAGES['PAYMENT_NOT_CONFIRMED_ADMIN']}\\n{MESSAGES['ORDER_ID']}: {payment_id}\")\n            bot.delete_message(call.message.chat.id, call.message.message_id)\n        else:\n            bot.send_message(call.message.chat.id, f\"{MESSAGES['ERROR_UNKNOWN']}\\n{MESSAGES['ORDER_ID']}: {payment_id}\")\n\n    # Payment - Change status Payment Callback\n    elif key == \"change_status_payment_by_admin\":\n        payments = USERS_DB.find_payment(id=int(value))\n        if not payments:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        payment = payments[0]\n        user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n        if not user_data:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        user_data = user_data[0]\n        msg = templates.bot_payment_info_template(payment,user_data, footer=MESSAGES['CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST'])\n        bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.confirm_change_status_payment_by_admin(value))\n    # Payment - Confirm change status Payment Callback\n    elif key == \"confirm_change_status_payment_by_admin\":\n        if not CLIENT_TOKEN:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n            return\n        payment_id = int(value)\n        payments = USERS_DB.find_payment(id=payment_id)\n        if not payments:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        payment = payments[0]\n        if payment['approved']:\n            payment_status = USERS_DB.edit_payment(payment_id, approved=False)\n            if payment_status:\n                wallet = USERS_DB.find_wallet(telegram_id=payment['telegram_id'])\n                if not wallet:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                wallet = wallet[0]\n                new_balance = int(wallet['balance']) - int(payment['payment_amount'])\n                wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)\n                if not wallet_status:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                payments = USERS_DB.find_payment(id=payment_id)\n                if not payments:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n                    return\n                payment = payments[0]\n                user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n                if not user_data:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                user_data = user_data[0]\n                msg = templates.bot_payment_info_template(payment,user_data)\n                bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.change_status_payment_by_admin(value))\n                user_bot.send_message(int(payment['telegram_id']),\n                                    f\"{MESSAGES['PAYMENT_CHANGED_TO_NOT_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n                bot.send_message(call.message.chat.id,\n                                f\"{MESSAGES['PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n\n        elif payment['approved'] == False:\n            payment_status = USERS_DB.edit_payment(payment_id, approved=True)\n            if payment_status:\n                wallet = USERS_DB.find_wallet(telegram_id=payment['telegram_id'])\n                if not wallet:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                wallet = wallet[0]\n                new_balance = int(wallet['balance']) + int(payment['payment_amount'])\n                wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)\n                if not wallet_status:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                payments = USERS_DB.find_payment(id=payment_id)\n                if not payments:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n                    return\n                payment = payments[0]\n                user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n                if not user_data:\n                    bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n                    return\n                user_data = user_data[0]\n                msg = templates.bot_payment_info_template(payment,user_data)\n                bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.change_status_payment_by_admin(value))\n                user_bot.send_message(int(payment['telegram_id']),\n                                    f\"{MESSAGES['WALLET_CHANGED_TO_PAYMENT_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n                bot.send_message(call.message.chat.id,\n                                f\"{MESSAGES['PAYMENT_CHANGED_TO_CONFIRMED_ADMIN']}\\n{MESSAGES['ORDER_ID']} {payment_id}\")\n                \n    elif key == \"cancel_change_status_payment_by_admin\":\n        payments = USERS_DB.find_payment(id=int(value))\n        if not payments:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])\n            return\n        payment = payments[0]\n        user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])\n        if not user_data:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        user_data = user_data[0]\n        msg = templates.bot_payment_info_template(payment,user_data)\n        bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.change_status_payment_by_admin(value))\n        \n    # Payment - Send Message Callback\n    elif key == \"send_message_by_admin\":\n        if not CLIENT_TOKEN:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n            return\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['SEND_MESSAGE_TO_USER']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, send_message_to_user, value)\n\n    elif key == \"users_bot_send_message_by_admin\":\n        if not CLIENT_TOKEN:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n            return\n        bot.send_message(call.message.chat.id, f\"{MESSAGES['SEND_MESSAGE_TO_USER']}\",\n                         reply_markup=markups.while_edit_user_markup())\n        bot.register_next_step_handler(call.message, users_bot_send_message_to_user, value)\n\n            \n    # Back to User Panel Callback\n    elif key == \"back_to_user_panel\":\n        usr = utils.user_info(URL, value)\n        if not usr:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        msg = templates.user_info_template(usr, selected_server)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.user_info_markup(usr['uuid']))\n    elif key == \"back_to_sub_url_user_list\":\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=markups.sub_url_user_list_markup(value))\n    elif key == \"back_to_server_management\":\n        servers = USERS_DB.select_servers()\n        bot.edit_message_text(KEY_MARKUP['SERVERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                                    reply_markup=markups.servers_management_markup(servers))\n    \n    elif key == \"back_to_server_list_of_plans\":\n        plans_list = []\n        plans = USERS_DB.select_plans()\n        if plans:\n            for plan in plans:\n                if plan['status']:\n                    if plan['server_id'] == int(value):\n                        plans_list.append(plan)\n        plans_markup = markups.plans_list_markup(plans_list,value)\n        bot.edit_message_text({MESSAGES['USERS_BOT_PLANS_LIST']}, call.message.chat.id, call.message.message_id,\n                         reply_markup=plans_markup)\n        \n    elif key == \"back_to_server_selected\":\n        if search_mode == \"Single\":\n            server = USERS_DB.find_server(id=int(value))\n            if not server:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n                return\n            server = server[0]\n            plans = USERS_DB.select_plans()\n            msg = templates.server_info_template(server,plans)\n            bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                                        reply_markup=markups.server_selected_markup(value))\n        else:\n            bot.edit_message_text(MESSAGES['SEARCH_USER'],call.message.chat.id, call.message.message_id, \n                              reply_markup=markups.search_user_markup(server_id=value))\n            search_mode = \"Single\"\n\n    elif key == \"back_to_server_user_list\":\n        users_list = api.select(URL)\n        if not users_list:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n            return\n        msg = templates.users_list_template(users_list)\n        bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_list_markup(value, users_list))\n        \n    elif key == \"back_to_users_bot_users_management\":\n        bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_users_management_markup())\n    elif key == \"back_to_bot_users_or_reffral_management\":\n        if list_mode == \"Bot_Users_Search_Name\" or \"Bot_User\":\n            bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_users_management_markup())\n        elif list_mode == \"User_Refferals\":\n            users = USERS_DB.find_user(telegram_id=int(selected_telegram_id))\n            if not users:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            user = users[0]\n            orders = USERS_DB.find_order(telegram_id=user['telegram_id'])\n            paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])\n            wallet = None\n            wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])\n            if wallets:\n                wallet = wallets[0]\n            non_order_subs = utils.non_order_user_info(user['telegram_id'])\n            order_subs = utils.order_user_info(user['telegram_id'])\n            plans_list = USERS_DB.select_plans()\n            msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)\n            bot.send_message(call.message.chat.id, msg, reply_markup=markups.bot_user_info_markup(value))\n    \n    elif key == \"back_management_item_list\":\n        approved_payments = list_mode == \"Approved_Payments\"\n        non_approved_payments = list_mode == \"Non_Approved_Payments\"\n        pending_payments = list_mode == \"Pending_Payments\"\n        card_payments = list_mode == \"Card_Payments\"\n        digital_payments = list_mode == \"Digital_Payments\"\n        if list_mode == \"Orders\":\n            bot.edit_message_text(KEY_MARKUP['ORDERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_orders_management_markup())\n        elif approved_payments  or non_approved_payments or pending_payments or card_payments or digital_payments:\n            bot.edit_message_text(KEY_MARKUP['PAYMENT_MANAGEMENT'], call.message.chat.id, call.message.message_id,\n                              reply_markup=markups.users_bot_payments_management_markup())\n        elif list_mode == \"User_Payments\" or list_mode == \"User_Gifts\" or list_mode == \"User_Orders\":\n            users = USERS_DB.find_user(telegram_id=int(selected_telegram_id))\n            if not users:\n                bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],\n                                reply_markup=markups.main_menu_keyboard_markup())\n                return\n            user = users[0]\n            orders = USERS_DB.find_order(telegram_id=user['telegram_id'])\n            paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])\n            wallet = None\n            wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])\n            if wallets:\n                wallet = wallets[0]\n            non_order_subs = utils.non_order_user_info(user['telegram_id'])\n            order_subs = utils.order_user_info(user['telegram_id'])\n            plans_list = USERS_DB.select_plans()\n            msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)\n            bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,\n                                  reply_markup=markups.bot_user_info_markup(selected_telegram_id))\n    \n    elif key == \"server_status\":\n        from Utils.serverInfo import get_server_status\n        msg_wait = bot.send_message(call.message.chat.id, MESSAGES['WAIT'])\n        server = USERS_DB.find_server(id=int(value))\n        if not server:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])\n            return\n        server = server[0]\n        server_status_data = get_server_status(server)\n        if not server_status_data:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        bot.delete_message(call.message.chat.id, msg_wait.message_id)\n        bot.send_message(call.message.chat.id, server_status_data, reply_markup=markups.main_menu_keyboard_markup())\n    \n    elif key == \"del_msg\":\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n\n\n\n\n# Check Admin Permission\n@bot.message_handler(func=lambda message: message.chat.id not in ADMINS_ID)\ndef not_admin(message: Message):\n    bot.reply_to(message, MESSAGES['ERROR_NOT_ADMIN'])\n\n\n# Send Welcome Message Handler\n@bot.message_handler(commands=['help', 'start', 'restart'])\ndef send_welcome(message: Message):\n    bot.reply_to(message, MESSAGES['WELCOME'], reply_markup=markups.main_menu_keyboard_markup())\n    bot.send_message(message.chat.id, MESSAGES['REQUEST_JOIN_HIDY'], reply_markup=markups.start_bot_markup())\n\n\n# Send users list Message Handler\n# @bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_LIST'])\n# def all_users_list(message: Message):\n#     # users_list = utils.dict_process(utils.users_to_dict(ADMIN_DB.select_users()))\n#     users_list = api.select(URL)\n#     if not users_list:\n#         bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])\n#         return\n#     msg = templates.users_list_template(users_list)\n#     bot.send_message(message.chat.id, msg, reply_markup=markups.users_list_markup(users_list))\n\n\n# Add User Message Handler\n# @bot.message_handler(func=lambda message: message.text == KEY_MARKUP['ADD_USER'])\n# def add_user(message: Message):\n#     global add_user_data\n#     bot.send_message(message.chat.id, MESSAGES['ADD_USER_NAME'], reply_markup=markups.while_add_user_markup())\n#     bot.register_next_step_handler(message, add_user_name)\n\n\n# Panel Backup Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVER_BACKUP'])\ndef server_backup(message: Message):\n    msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'])\n    zip_file_name = utils.full_backup()\n    if not zip_file_name:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n        logging.error(\"Backup failed\")\n        return\n    \n    if message.chat.id in ADMINS_ID:\n        bot.send_document(message.chat.id, open(zip_file_name, 'rb'), caption=\"🤖Backup\",disable_notification=True)\n    else:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n        \n    bot.delete_message(message.chat.id, msg_wait.message_id)\n\n\n# Server Status Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVER_STATUS'])\ndef server_status(message: Message):\n    servers = USERS_DB.select_servers()\n    bot.send_message(message.chat.id, KEY_MARKUP['SERVER_STATUS'],\n                     reply_markup=markups.server_status_markup(servers))\n\n\n# Search User Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_SEARCH'])\ndef search_user(message: Message):\n    global server_mode\n    server_mode = \"All\"\n    bot.send_message(message.chat.id, MESSAGES['SEARCH_USER'],\n    reply_markup=markups.search_user_markup())\n\n\n# Users Bot Management Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_BOT_MANAGEMENT'])\ndef users_bot_management(message: Message):\n    if not CLIENT_TOKEN:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])\n        return\n    bot.send_message(message.chat.id, KEY_MARKUP['USERS_BOT_MANAGEMENT'],\n                     reply_markup=markups.users_bot_management_markup())\n    \n# Server Management Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVERS_MANAGEMENT'])\ndef servers_management(message: Message):\n    servers = USERS_DB.select_servers()\n    bot.send_message(message.chat.id, KEY_MARKUP['SERVERS_MANAGEMENT'],\n                     reply_markup=markups.servers_management_markup(servers))\n\n# About Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['ABOUT_BOT'])\ndef about_bot(message: Message):\n    bot.send_message(message.chat.id, templates.about_template())\n\n# Debug Handler\n@bot.message_handler(commands=['debug'])\ndef debug(message: Message):\n    debug_zip = utils.debug_data()\n    if not debug_zip:\n        bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n        return\n    bot.send_document(message.chat.id, open(debug_zip, 'rb'), caption=\"👹Debug\")\n\n\n# ----------------------------------- Main -----------------------------------\n# Start Bot\ndef start():\n    # Bot Start Commands\n    try:\n        bot.set_my_commands([\n            telebot.types.BotCommand(\"/start\", BOT_COMMANDS['START']),\n            telebot.types.BotCommand(\"/debug\", BOT_COMMANDS['DEBUG']),\n        ])\n    except telebot.apihelper.ApiTelegramException as e:\n        if e.result.status_code == 401:\n            logging.error(\"Invalid Telegram Bot Token!\")\n            exit(1)\n\n    # Welcome to Admin\n    for admin in ADMINS_ID:\n        try:\n            bot.send_message(admin, MESSAGES['WELCOME_TO_ADMIN'])\n        except Exception as e:\n            logging.warning(f\"Error in send message to admin {admin}: {e}\")\n\n    bot.enable_save_next_step_handlers()\n    bot.load_next_step_handlers()\n    bot.infinity_polling()\n"
  },
  {
    "path": "AdminBot/content.py",
    "content": "import os\nimport json\nfrom config import LANG\n\nFOLDER = \"Json\"\n\nMSG_FILE = \"messages.json\"\nBTN_FILE = \"buttons.json\"\nCMD_FILE = \"commands.json\"\n\nwith open(os.path.join(os.path.dirname(__file__),FOLDER, MSG_FILE), encoding='utf-8') as f:\n    MESSAGES = json.load(f)\nMESSAGES = MESSAGES[LANG]\n\nwith open(os.path.join(os.path.dirname(__file__),FOLDER, BTN_FILE), encoding='utf-8') as f:\n    KEY_MARKUP = json.load(f)\nKEY_MARKUP = KEY_MARKUP[LANG]\n\nwith open(os.path.join(os.path.dirname(__file__),FOLDER, CMD_FILE), encoding='utf-8') as f:\n    BOT_COMMANDS = json.load(f)\nBOT_COMMANDS = BOT_COMMANDS[LANG]\n"
  },
  {
    "path": "AdminBot/markups.py",
    "content": "# Description: This file contains all the reply and inline keyboard markups used in the bot.\nfrom telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton\nfrom AdminBot.content import KEY_MARKUP\nfrom AdminBot.content import MESSAGES\nfrom config import CLIENT_TOKEN, HIDY_BOT_ID\nfrom Utils.utils import all_configs_settings, rial_to_toman\n\n\n# Main Menu Reply Keyboard Markup\ndef main_menu_keyboard_markup():\n    markup = ReplyKeyboardMarkup(row_width=3, resize_keyboard=True)\n    #markup.add(KeyboardButton(KEY_MARKUP['USERS_LIST']))\n    #markup.add(KeyboardButton(KEY_MARKUP['USERS_SEARCH']), KeyboardButton(KEY_MARKUP['ADD_USER']))\n    markup.add(KeyboardButton(KEY_MARKUP['SERVERS_MANAGEMENT']))\n    markup.add(KeyboardButton(KEY_MARKUP['USERS_SEARCH']))\n    if CLIENT_TOKEN:\n        markup.add(KeyboardButton(KEY_MARKUP['USERS_BOT_MANAGEMENT']))\n    markup.add()\n    markup.add(KeyboardButton(KEY_MARKUP['SERVER_STATUS']), KeyboardButton(KEY_MARKUP['ABOUT_BOT']),\n               KeyboardButton(KEY_MARKUP['SERVER_BACKUP']))\n\n    return markup\n\n#----------------------------------Hiddify User ---------------------------------\n# Users List Inline Keyboard Markup\ndef users_list_markup(server_id, users, page=1):\n    markup = InlineKeyboardMarkup(row_width=3)\n    USER_PER_PAGE = 20\n    start = (page - 1) * USER_PER_PAGE\n    end = start + USER_PER_PAGE\n    keys = []\n\n    for user in users[start:end]:\n        status_tag = \"\"\n        if user['last_connection'] == \"Online\" or user['last_connection'] == \"آنلاین\":\n            status_tag = \"🔵\"\n        else:\n            status_tag = \"🟡\"\n        if user['remaining_day'] == 0:\n            status_tag = \"🔴\"\n        if user['usage']['remaining_usage_GB'] <= 0:\n            status_tag = \"🔴️\"\n\n        keys.append(InlineKeyboardButton(f\"{status_tag}|{user['name']}\", callback_data=f\"info:{user['uuid']}\"))\n    markup.add(*keys)\n    if page < len(users) / USER_PER_PAGE:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f\"next:{page + 1}\"), row_width=2)\n    if page > 1:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f\"next:{page - 1}\"), row_width=1)\n    if server_id != \"None\":\n        markup.add(InlineKeyboardButton(KEY_MARKUP['ADD_USER'], callback_data=f\"server_add_user:{server_id}\"))\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_SEARCH'], callback_data=f\"server_search_user:{server_id}\"))\n        markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_server_selected:{server_id}\"))\n    return markup\n\n\n# Single User Inline Keyboard Markup\ndef user_info_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_USER'], callback_data=f\"user_config:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_USER'], callback_data=f\"user_edit:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['DELETE_USER'], callback_data=f\"user_delete:{uuid}\"))\n    return markup\n\n\n# Single User Edit Inline Keyboard Markup\ndef edit_user_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_NAME'], callback_data=f\"user_edit_name:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_USAGE'], callback_data=f\"user_edit_usage:{uuid}\"),\n               InlineKeyboardButton(KEY_MARKUP['RESET_USAGE'], callback_data=f\"user_edit_reset_usage:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_DAYS'], callback_data=f\"user_edit_days:{uuid}\"),\n               InlineKeyboardButton(KEY_MARKUP['RESET_DAYS'], callback_data=f\"user_edit_reset_days:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_COMMENT'], callback_data=f\"user_edit_comment:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['UPDATE_MESSAGE'], callback_data=f\"user_edit_update:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n    return markup\n\n\n# # Add User Reply Keyboard Markup\n# def while_add_user_markup():\n#     markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)\n#     markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))\n#     return markup\n\n\n# Edit User Reply Keyboard Markup\ndef while_edit_user_markup():\n    markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)\n    markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))\n    return markup\n\ndef while_edit_skip_user_markup():\n    markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)\n    markup.add(KeyboardButton(KEY_MARKUP['SKIP']))\n    markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))\n    return markup\n\n# Confirm Add User Reply Keyboard Markup\ndef confirm_add_user_markup():\n    markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)\n    markup.add(KeyboardButton(KEY_MARKUP['CONFIRM']))\n    markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))\n    return markup\n\n\n# Subscription URL Inline Keyboard Markup\ndef sub_url_user_list_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_DIR'], callback_data=f\"conf_dir:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_AUTO'], callback_data=f\"conf_sub_auto:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB'], callback_data=f\"conf_sub_url:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_B64'], callback_data=f\"conf_sub_url_b64:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_CLASH'], callback_data=f\"conf_clash:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_HIDDIFY'], callback_data=f\"conf_hiddify:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SING_BOX'], callback_data=f\"conf_sub_sing_box:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_FULL_SING_BOX'],\n                                        callback_data=f\"conf_sub_full_sing_box:{uuid}\"))\n\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n\n    return markup\n\n\n# Subscription Configs Inline Keyboard Markup\ndef sub_user_list_markup(uuid,configs):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    if configs['vless']:\n        markup.add(InlineKeyboardButton('Vless', callback_data=f\"conf_dir_vless:{uuid}\"))\n    if configs['vmess']:\n        markup.add(InlineKeyboardButton('Vmess', callback_data=f\"conf_dir_vmess:{uuid}\"))\n    if configs['trojan']:\n        markup.add(InlineKeyboardButton('Trojan', callback_data=f\"conf_dir_trojan:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_sub_url_user_list:{uuid}\"))\n    return markup\n\n\n# Search User Inline Keyboard Markup\ndef search_user_markup(server_id=None):\n    callback_data = server_id if server_id else \"None\"\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_NAME'], callback_data=f\"search_name:{callback_data}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_UUID'], callback_data=f\"search_uuid:{callback_data}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_CONFIG'], callback_data=f\"search_config:{callback_data}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_EXPIRED_USERS'], callback_data=f\"search_expired:{callback_data}\"))\n    if server_id:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_server_user_list:{server_id}\"))\n    return markup\n\n#----------------------------------End Hiddify User ---------------------------------\n#----------------------------------Bot User Management ------------------------------\n\n# Users Bot Management - Inline Keyboard Markup\ndef users_bot_management_markup(value=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 3\n    # markup.add(\n    #     InlineKeyboardButton(KEY_MARKUP['USERS_BOT_ORDERS_STATUS'], callback_data=f\"users_bot_orders_status:None\"),\n    # markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_ADD_PLAN'], callback_data=f\"users_bot_add_plan:None\"),\n    #            InlineKeyboardButton(KEY_MARKUP['USERS_BOT_DEL_PLAN'], callback_data=f\"users_bot_list_plans:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BOT_USERS_MANAGEMENT'],\n                                    callback_data=f\"bot_users_list_management:None\"))\n    # markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_MANAGEMENT'],\n    #                                 callback_data=f\"users_bot_orders_list_management:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['PAYMENT_MANAGEMENT'],\n                                    callback_data=f\"users_bot_payments_list_management:None\"),\n                                    InlineKeyboardButton(KEY_MARKUP['ORDERS_MANAGEMENT'],\n                                    callback_data=f\"users_bot_orders_list_management:None\"),)\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SUB_STATUS'], callback_data=f\"users_bot_sub_status:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SEND_MESSAGE_TO_USERS'],\n                                    callback_data=f\"users_bot_send_msg_users:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_OWNER_INFO'], callback_data=f\"users_bot_owner_info:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Users Bot Users List Management - Inline Keyboard Markup\ndef users_bot_users_management_markup(value=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_LIST'], callback_data=f\"bot_users_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USERS_BOT'], callback_data=f\"search_users_bot:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_management_menu:None\"))\n    return markup\n\n# Users Bot Search Method  - Inline Keyboard Markup\ndef users_bot_users_search_method_markup(value=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_NAME'], callback_data=f\"bot_users_search_name:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_TELEGRAM_ID'], callback_data=f\"bot_users_search_telegram_id:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_users_bot_users_management:None\"))\n    return markup\n\n# Users List Inline Keyboard Markup\ndef bot_users_list_markup(users, page=1):\n    markup = InlineKeyboardMarkup(row_width=3)\n    USER_PER_PAGE = 20\n    start = (page - 1) * USER_PER_PAGE\n    end = start + USER_PER_PAGE\n    keys = []\n    for user in users[start:end]:\n        name = user['full_name'] if user['full_name'] else user['telegram_id']\n        keys.append(InlineKeyboardButton(f\"{name}\", callback_data=f\"bot_user_info:{user['telegram_id']}\"))\n    markup.add(*keys)\n    if page < len(users) / USER_PER_PAGE:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f\"bot_user_next:{page + 1}\"), row_width=2)\n    if page > 1:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f\"bot_user_next:{page - 1}\"), row_width=1)\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_bot_users_or_reffral_management:None\"))\n    return markup\n\n\n# User Item List Inline Keyboard Markup\ndef bot_user_item_list_markup(items, page=1):\n    markup = InlineKeyboardMarkup(row_width=3)\n    USER_PER_PAGE = 20\n    start = (page - 1) * USER_PER_PAGE\n    end = start + USER_PER_PAGE\n    keys = []\n    for item in items[start:end]:\n        keys.append(InlineKeyboardButton(f\"{item['id']}\", callback_data=f\"bot_user_item_info:{item['id']}\"))\n    markup.add(*keys)\n    if page < len(items) / USER_PER_PAGE:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f\"bot_user_item_next:{page + 1}\"), row_width=2)\n    if page > 1:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f\"bot_user_item_next:{page - 1}\"), row_width=1)\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_management_item_list:None\"))\n    return markup\n\n# Users Bot Users info Management - Inline Keyboard Markup\ndef bot_user_info_markup(telegram_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USER_SUB_LIST'], callback_data=f\"bot_users_sub_user_list:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_LIST'], callback_data=f\"users_bot_orders_user_list:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['PAYMENTS_LIST'], callback_data=f\"users_bot_payments_user_list:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_WALLET'], callback_data=f\"users_bot_wallet_edit_balance:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['RESET_TEST'], callback_data=f\"users_bot_reset_test:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BAN_USER'], callback_data=f\"users_bot_ban_user:{telegram_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_MESSAGE'], callback_data=f\"users_bot_send_message_by_admin:{telegram_id}\"))\n    # markup.add(InlineKeyboardButton(KEY_MARKUP['GIFT_LIST'], callback_data=f\"users_bot_gifts_user_list:{telegram_id}\"),\n    #            InlineKeyboardButton(KEY_MARKUP['REFERRED_LIST'], callback_data=f\"users_bot_referred_user_list:{telegram_id}\"))\n    #markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_management_menu:None\"))\n    return markup\n\n# Users Bot Users List Management - Inline Keyboard Markup\ndef users_bot_orders_management_markup(value=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_LIST'], callback_data=f\"users_bot_orders_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_ORDERS'], callback_data=f\"search_orders:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_management_menu:None\"))\n    return markup\n\ndef confirm_payment_by_admin(payment_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['CONFIRM_PAYMENT'], callback_data=f\"confirm_payment_by_admin:{payment_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f\"cancel_payment_by_admin:{payment_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_MESSAGE'], callback_data=f\"send_message_by_admin:{payment_id}\"))\n    return markup\n\ndef send_message_to_user_markup(admin_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['ANSWER'], callback_data=f\"answer_to_admin:{admin_id}\"))\n    return markup\n\ndef change_status_payment_by_admin(payment_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['CHANGE_STATUS_PAYMENT'], callback_data=f\"change_status_payment_by_admin:{payment_id}\"))\n    return markup\n\ndef confirm_change_status_payment_by_admin(payment_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['YES'], callback_data=f\"confirm_change_status_payment_by_admin:{payment_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f\"cancel_change_status_payment_by_admin:{payment_id}\"))\n    return markup\n\n# Users Bot Payments List Management - Inline Keyboard Markup\ndef users_bot_payments_management_markup(value=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['APPROVED_PAYMENTS_LIST'],\n                                    callback_data=f\"bot_users_approved_payments_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['NON_APPROVED_PAYMENTS_LIST'],\n                                    callback_data=f\"users_bot_non_approved_payments_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['PENDING_PAYMENT_LIST'],\n                                    callback_data=f\"users_bot_pending_payments_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CARD_PAYMENT_LIST'],\n                                    callback_data=f\"users_bot_card_payments_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['DIGITAL_PAYMENT_LIST'], \n                                    callback_data=f\"users_bot_digital_payments_list:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_PAYMENTS'], callback_data=f\"search_payments:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_management_menu:None\"))\n    return markup\n\n#----------------------------------Bot User Settings Management ------------------------------\n\n# Users Bot Management - Settings - Inline Keyboard Markup\ndef users_bot_management_settings_markup(settings):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    status_hyperlink = \"✅\" if settings['visible_hiddify_hyperlink'] else \"❌\"\n    status_three_rand = \"✅\" if settings['three_random_num_price'] else \"❌\"\n    status_panel_auto_backup = \"✅\" if settings['panel_auto_backup'] else \"❌\"\n    status_bot_auto_backup = \"✅\" if settings['bot_auto_backup'] else \"❌\"\n    status_force_join = \"✅\" if settings['force_join_channel'] else \"❌\"\n    status_buy_sub = \"✅\" if settings['buy_subscription_status'] else \"❌\"\n    status_renewal_sub = \"✅\" if settings['renewal_subscription_status'] else \"❌\"\n\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_SHOW_HIDI_LINK']} | {status_hyperlink}\",\n                                    callback_data=f\"users_bot_settings_hyperlink:{settings['visible_hiddify_hyperlink']}\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_SHOW_THREE_RAND']} | {status_three_rand}\",\n                                    callback_data=f\"users_bot_settings_three_rand_price:{settings['three_random_num_price']}\"))\n    \n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_BUY_SUBSCRIPTION_STATUS']} | {status_buy_sub}\",\n                                    callback_data=f\"users_bot_settings_buy_sub_status:{settings['buy_subscription_status']}\"),\n               InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_SUBSCRIPTION_STATUS']} | {status_renewal_sub}\",\n                                    callback_data= f\"users_bot_settings_renewal_sub_status:{settings['renewal_subscription_status']}\"))\n    \n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_CHANNEL_ّFORCE_JOIN']} | {status_force_join}\",\n                                    callback_data=f\"users_bot_settings_force_join:{settings['force_join_channel']}\"),\n               InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_CHANNEL_ID'],\n                                    callback_data=f\"users_bot_settings_channel_id:None\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_AUTO_BACKUP']} | {status_panel_auto_backup}\",\n                             callback_data=f\"users_bot_settings_panel_auto_backup:{settings['panel_auto_backup']}\"),)\n            #    InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_BOT_AUTO_BACKUP']} | {status_bot_auto_backup}\",\n            #                         callback_data=f\"users_bot_settings_bot_auto_backup:{settings['bot_auto_backup']}\")\n            #    )\n\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_SET_WELCOME_MSG'],\n                                    callback_data=f\"users_bot_settings_set_welcome_msg:None\"),\n               InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL'],\n                                    callback_data=\"users_bot_settings_panel_manual_menu:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_SET_FAQ_MSG'],\n                                    callback_data=f\"users_bot_settings_faq_management:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_VISIBLE_SUBS'],\n                                    callback_data=f\"users_bot_settings_visible_sub_menu:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_TEST_SUB'],\n                                    callback_data=f\"users_bot_settings_test_sub_menu:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_NOTIF_REMINDER'],\n                                    callback_data=f\"users_bot_settings_notif_reminder_menu:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_MIN_DEPO'],\n                                    callback_data=f\"users_bot_settings_min_depo:{settings['min_deposit_amount']}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD'],\n                                    callback_data=f\"users_bot_settings_renewal_method_menu:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT'],\n                                    callback_data=f\"users_bot_settings_reset_free_test_limit_question:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_BACKUP_BOT'],\n                                    callback_data=f\"users_bot_settings_backup_bot:None\"),\n               InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_RESTORE_BOT'],\n                                    callback_data=f\"users_bot_settings_restore_bot:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_management_menu:None\"))\n    return markup\n\n# Users Bot Management - Settings - Renewal Method - Inline Keyboard Markup\ndef users_bot_management_settings_renewal_method_markup(settings):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 3\n    default, advanced, fairly = \"❌\", \"❌\", \"❌\"\n    \n    if settings['renewal_method'] == 1:\n        default = \"✅\"\n    elif settings['renewal_method'] == 2:\n        advanced = \"✅\"\n    elif settings['renewal_method'] == 3:\n        fairly = \"✅\"\n        \n        \n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD_DEFAULT']} | {default}\",\n                                    callback_data=f\"users_bot_settings_renewal_method:1\"),\n                InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED']} | {advanced}\",\n                                    callback_data=f\"users_bot_settings_renewal_method:2\"),\n                InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD_FAIRLY']} | {fairly}\",\n                      callback_data=f\"users_bot_settings_renewal_method:3\"),\n    )\n               \n    if settings['renewal_method'] == 2:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS'],\n                                        callback_data=f\"users_bot_settings_renewal_method_advanced_days:None\"))\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE'],\n                                        callback_data=f\"users_bot_settings_renewal_method_advanced_usage:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Users Bot Management - Settings - Free Test - Inline Keyboard Markup\ndef users_bot_management_settings_test_sub_markup(settings):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    status_test_sub = \"✅\" if settings['test_subscription'] else \"❌\"\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_TEST_SUB']} | {status_test_sub}\",\n                                    callback_data=f\"users_bot_settings_test_sub:test_subscription\"))\n    if settings['test_subscription']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_TEST_SUB_SIZE'],\n                                        callback_data=f\"users_bot_settings_test_sub_size:None\"))\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_TEST_SUB_DAYS'],\n                                        callback_data=f\"users_bot_settings_test_sub_days:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Users Bot Management - Settings - Reminder Notificaation - Inline Keyboard Markup\ndef users_bot_management_settings_notif_reminder_markup(settings):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    status_test_sub = \"✅\" if settings['reminder_notification'] else \"❌\"\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['USERS_BOT_SETTINGS_NOTIF_REMINDER']} | {status_test_sub}\",\n                                    callback_data=f\"users_bot_settings_notif_reminder:reminder_notification\"))\n    if settings['reminder_notification']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE'],\n                                        callback_data=f\"users_bot_settings_notif_reminder_usage:None\"))\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS'],\n                                        callback_data=f\"users_bot_settings_notif_reminder_days:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Users Bot Management - Settings - Subscription Links - Inline Keyboard Markup\ndef users_bot_management_settings_visible_sub_markup(settings):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n\n    status_visible_conf_dir = \"✅\" if settings['visible_conf_dir'] else \"❌\"\n    status_conf_sub_auto = \"✅\" if settings['visible_conf_sub_auto'] else \"❌\"\n    status_conf_sub_url = \"✅\" if settings['visible_conf_sub_url'] else \"❌\"\n    status_conf_sub_url_b64 = \"✅\" if settings['visible_conf_sub_url_b64'] else \"❌\"\n    status_conf_clash = \"✅\" if settings['visible_conf_clash'] else \"❌\"\n    status_conf_hiddify = \"✅\" if settings['visible_conf_hiddify'] else \"❌\"\n    status_conf_sub_sing_box = \"✅\" if settings['visible_conf_sub_sing_box'] else \"❌\"\n    status_conf_sub_full_sing_box = \"✅\" if settings['visible_conf_sub_full_sing_box'] else \"❌\"\n\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_DIR']} | {status_visible_conf_dir}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_dir\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_SUB_AUTO']} | {status_conf_sub_auto}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_sub_auto\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_SUB']} | {status_conf_sub_url}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_sub_url\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_SUB_B64']} | {status_conf_sub_url_b64}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_sub_url_b64\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_CLASH']} | {status_conf_clash}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_clash\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_HIDDIFY']} | {status_conf_hiddify}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_hiddify\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_SING_BOX']} | {status_conf_sub_sing_box}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_sub_sing_box\"))\n    markup.add(InlineKeyboardButton(f\"{KEY_MARKUP['CONFIGS_FULL_SING_BOX']} | {status_conf_sub_full_sing_box}\",\n                                    callback_data=f\"users_bot_settings_visible_sub:visible_conf_sub_full_sing_box\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Users Bot Management - Settings - Manual - Inline Keyboard Markup\ndef users_bot_management_settings_panel_manual_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL_ANDROID'],\n                                    callback_data=f\"users_bot_settings_panel_manual:msg_manual_android\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL_IOS'],\n                                    callback_data=f\"users_bot_settings_panel_manual:msg_manual_ios\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL_WIN'],\n                                    callback_data=f\"users_bot_settings_panel_manual:msg_manual_windows\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL_MAC'],\n                                    callback_data=f\"users_bot_settings_panel_manual:msg_manual_mac\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_PANEL_MANUAL_LIN'],\n                                    callback_data=f\"users_bot_settings_panel_manual:msg_manual_linux\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\ndef users_bot_management_settings_faq_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    settings = all_configs_settings()\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_SET_FAQ_MESSAGE'],\n                                    callback_data=f\"users_bot_settings_set_faq_msg:None\"))\n    if settings['msg_faq']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS_HIDE_FAQ'],\n                                    callback_data=f\"users_bot_settings_hide_faq:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n\n# Users Bot Management - Edit Owner Info - Inline Keyboard Markup\ndef users_bot_edit_owner_info_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_OWNER_INFO_EDIT_USERNAME'],\n                                    callback_data=f\"users_bot_owner_info_edit_username:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_OWNER_INFO_EDIT_CARD_NUMBER'],\n                                    callback_data=f\"users_bot_owner_info_edit_card_number:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_OWNER_INFO_EDIT_CARD_NAME'],\n                                    callback_data=f\"users_bot_owner_info_edit_card_name:None\"))\n    return markup\n\ndef users_bot_management_settings_reset_free_test_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIRM'],\n                                    callback_data=f\"users_bot_management_settings_reset_free_test_confirm:None\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"users_bot_settings:None\"))\n    return markup\n\n# Single Subscription Inline Keyboard Markup\ndef sub_search_info_markup(uuid,user):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_USER'], callback_data=f\"user_config:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_USER'], callback_data=f\"user_edit:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['DELETE_USER'], callback_data=f\"user_delete:{uuid}\"))\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    markup.add(InlineKeyboardButton(f\"{name}\", callback_data=f\"bot_user_info:{user['telegram_id']}\"))\n    return markup\n\n#--------------------------------------End Bot User Management -----------------------------------\n#----------------------------------End Bot User Settings Management ------------------------------\n#-----------------------------------------Servers Management -------------------------------------\n\n# Server Management - Server List - Inline Keyboard Markup\ndef servers_management_markup(servers):\n    markup = InlineKeyboardMarkup(row_width=1)\n    keys = []\n    if servers:\n        for server in servers:\n            #if server['status']:\n            keys.append(InlineKeyboardButton(f\"{server['title']}\",\n                                             callback_data=f\"server_selected:{server['id']}\"))\n    keys.append(InlineKeyboardButton(KEY_MARKUP['ADD_SERVER'],\n                                     callback_data=f\"add_server:None\"))\n    markup.add(*keys)\n    return markup\n\n# Server Management - Server Info - Inline Keyboard Markup\ndef server_selected_markup(server_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SERVER_LIST_OF_USERS'],\n                                    callback_data=f\"server_list_of_users:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SERVER_LIST_OF_PLANS'],\n                                    callback_data=f\"server_list_of_plans:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_SERVER'],\n                                    callback_data=f\"edit_server:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_server_management:None\"))\n    \n    return markup\n\n# Server Management - Server Delete - Inline Keyboard Markup\ndef server_delete_markup(server_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIRM'],\n                                    callback_data=f\"confirm_delete_server:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CANCEL'],\n                                    callback_data=f\"server_selected:{server_id}\"))\n    return markup\n\n\n# Server Management - Server Edit - Inline Keyboard Markup\ndef server_edit_markup(server_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SERVER_EDIT_TITLE'],\n                                    callback_data=f\"server_edit_title:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SERVER_EDIT_USER_LIMIT'],\n                                    callback_data=f\"server_edit_user_limit:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SERVER_EDIT_URL'],\n                                    callback_data=f\"server_edit_url:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['DELETE_SERVER'],\n                                    callback_data=f\"delete_server:{server_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_server_selected:{server_id}\"))\n    return markup\n\n# Server Management - Plans List - Inline Keyboard Markup\ndef plans_list_markup(plans, server_id, delete_mode=False):\n    markup = InlineKeyboardMarkup(row_width=1)\n    plan_selected_callback_data = \"users_bot_del_plan:\" if delete_mode else \"info_plan_selected:\" \n    back_callback_data = \"back_to_server_list_of_plans:\" if delete_mode else \"back_to_server_selected:\"\n    keys = []\n    if plans:\n        for plan in plans:\n            keys.append(InlineKeyboardButton(\n                f\"{plan['size_gb']}{MESSAGES['GB']} | {plan['days']}{MESSAGES['DAY']} | {rial_to_toman(plan['price'])} {MESSAGES['TOMAN']}\",\n                callback_data = f\"{plan_selected_callback_data}{plan['id']}\"))\n    if not delete_mode:\n        keys.append(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_ADD_PLAN'], callback_data=f\"users_bot_add_plan:{server_id}\"))\n        keys.append(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_DEL_PLAN'], callback_data=f\"users_bot_list_plans:{server_id}\"))\n    keys.append(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"{back_callback_data}{server_id}\"))\n    markup.add(*keys)\n    return markup\n\n# Server Management - Plans List - Inline Keyboard Markup\ndef plan_info_selected_markup(server_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_server_list_of_plans:{server_id}\"))\n    return markup\n\n#-------------------------------------End Servers Management -------------------------------------\n\ndef start_bot_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    bot_id = HIDY_BOT_ID.replace(\"@\", \"\")\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SUPPORT_GROUP'], url=f\"https://t.me/{bot_id}\"))\n    return markup\n\ndef server_status_markup(servers):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    keys = []\n    for server in servers:\n        if server['status']:\n            keys.append(InlineKeyboardButton(f\"{server['title']}\",\n                                             callback_data=f\"server_status:{server['id']}\"))\n    markup.add(*keys)\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"del_msg:None\"))\n    return markup"
  },
  {
    "path": "AdminBot/templates.py",
    "content": "# Description: This file contains all the templates used in the bot.\nfrom config import LANG, VERSION, API_PATH\nfrom AdminBot.content import MESSAGES\nfrom Utils import api, utils \nimport datetime\nimport urllib.parse\n\n\n# Single User Info Message Template\ndef user_info_template(usr, server, header=\"\"):\n    if not usr['comment']:\n        usr['comment'] = \"-\"\n    if usr['remaining_day'] == 0:\n        usr['remaining_day'] = MESSAGES['USER_TIME_EXPIRED']\n    elif usr['remaining_day'] == 1:\n        usr['remaining_day'] = MESSAGES['USER_LAST_DAY']\n    else:\n        usr['remaining_day'] = f\"{usr['remaining_day']} {MESSAGES['DAY_EXPIRE']}\"\n\n    return f\"\"\"\n{header}\n{MESSAGES['INFO_USER_NAME']} <a href='{usr['link']}'> {usr['name']} </a>\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['SERVER']} {server['title']}\n{MESSAGES['INFO_USAGE']} {usr['usage']['current_usage_GB']} {MESSAGES['OF']} {usr['usage']['usage_limit_GB']} {MESSAGES['GB']}\n{MESSAGES['INFO_REMAINING_DAYS']} {usr['remaining_day']}\n{MESSAGES['INFO_LAST_CONNECTION']} {usr['last_connection']}\n{MESSAGES['INFO_COMMENT']} {usr['comment']}\n\"\"\"\n\n# Server Info Message Template\ndef server_info_template(server, plans, header=\"\"):\n    plans_num = 0\n    user_index = 0\n    URL = server['url'] + API_PATH\n    users_list = api.select(URL)\n    if users_list:\n        user_index = len(users_list)\n    if plans:\n        for plan in plans:\n            if plan['status']:\n                if plan['server_id'] == server['id']:\n                    plans_num += 1\n\n    return f\"\"\"\n{header}\n{MESSAGES['INFO_SERVER']} <a href='{server['url']}/admin'> {server['title']} </a>\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['INFO_SERVER_USER_NUMBER']} {user_index} {MESSAGES['OF']} {server['user_limit']}\n{MESSAGES['INFO_SERVER_USER_PLAN']} {plans_num}\n\"\"\"\n\n# Plan Info Message Template\ndef plan_info_template(plan, orders, header=\"\"):\n    num_orders = 0\n    if orders:\n        for order in orders:\n            num_orders += 1\n    sale = num_orders * plan['price']\n    return f\"\"\"\n{header}\n{MESSAGES['INFO_PLAN_ID']} {plan['id']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['INFO_PLAN_USAGE']} {plan['size_gb']} \n{MESSAGES['INFO_PLAN_DAYS']} {plan['days']} \n{MESSAGES['INFO_PLAN_PRICE']} {utils.rial_to_toman(plan['price'])} {MESSAGES['TOMAN']}\n{MESSAGES['INFO_PLAN_DESC']} {plan['description']}\n{MESSAGES['INFO_PLAN_NUM_ORDER']} {num_orders} \n{MESSAGES['INFO_PLAN_TOTAL_SALE']} {utils.rial_to_toman(sale)} {MESSAGES['TOMAN']}\n\"\"\"\n\n# Users List Message Template\ndef users_list_template(users, heder=\"\"):\n    # Number of Online Users\n    online_users = 0\n    for user in users:\n        if user['last_connection'] == \"Online\" or user['last_connection'] == \"آنلاین\":\n            online_users += 1\n\n    return f\"\"\"\n{heder}\n{MESSAGES['HEADER_USERS_LIST']}\n{MESSAGES['HEADER_USERS_LIST_MSG']}\n{MESSAGES['NUM_USERS']} {len(users)}\n{MESSAGES['NUM_USERS_ONLINE']} {online_users} \n\"\"\"\n\n\n# Bot Users List Message Template\ndef bot_users_list_template(users, wallets, orders, header=\"\"):\n\n    users_get_free = 0\n    ordered_users = 0\n    total_balance_wallets= 0\n    if wallets:\n        for wallet in wallets:\n            total_balance_wallets += wallet['balance']\n    if orders:\n        for user in users:\n            if user['test_subscription']:\n                users_get_free += 1\n            for order in orders:\n                if order['telegram_id'] == user['telegram_id']:\n                    ordered_users += 1\n                    break\n    else:\n        for user in users:\n            if user['test_subscription']:\n                users_get_free += 1\n        \n\n    return f\"\"\"\n{header}\n<b>{MESSAGES['HEADER_USERS_LIST']}</b>\n{MESSAGES['HEADER_USERS_LIST_MSG']}\n{MESSAGES['NUM_USERS']} {len(users)}\n{MESSAGES['NUM_GET_FREE_USERS']} {users_get_free}\n{MESSAGES['NUM_ORDERED_USERS']} {ordered_users}\n{MESSAGES['TOTAL_BALANCE_USERS']} {utils.rial_to_toman(total_balance_wallets)}{MESSAGES['TOMAN']}\n\"\"\"\n\n# Bot Users Info Message Template\ndef bot_users_info_template(user, orders, payments, wallet, non_order_subs, order_subs, plans, header=\"\"):\n    total_orders = 0\n    total_payment = 0\n    approved_payment = 0\n    total_order_subs = 0\n    total_non_order_subs = 0\n    total_balance = 0\n    total_valume = 0\n    total_sales = 0\n    if orders:\n        total_orders = len(orders)\n        if plans:\n            for order in orders:\n                for plan in plans:\n                    if order['plan_id'] == plan['id']:\n                        total_valume += plan['size_gb']\n                        total_sales += plan['price']\n                        break\n    if payments:\n        total_payment = len(payments)\n        approved_payments = [payment for payment in payments if payment['approved'] == 1]\n        if approved_payments:\n            approved_payment = len(approved_payments)\n    if non_order_subs:\n        total_non_order_subs = len(non_order_subs)\n    if order_subs:\n        total_order_subs = len(order_subs)\n    if wallet:\n        total_balance = wallet['balance']\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    username = f\"@{user['username']}\" if user['username'] else MESSAGES['NOT_SET']\n    free_test_status = \"✅\" if user['test_subscription'] else \"❌\"\n\n    return f\"\"\"\n{header}\n{MESSAGES['INFO_USER_NAME']}{name}\n{MESSAGES['INFO_USER_USERNAME']}{username}\n{MESSAGES['INFO_USER_NUM_ID']}{user['telegram_id']}\n{MESSAGES['GET_FREE_TEST_STATUS']}{free_test_status}\n{MESSAGES['WALLET_BALANCE']}{utils.rial_to_toman(total_balance)}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['NUM_ORDER_SUB']} {total_order_subs}\n{MESSAGES['NUM_NON_ORDER_SUB']} {total_non_order_subs}\n{MESSAGES['NUM_PAYMENTS']} {total_payment}\n{MESSAGES['NUM_APPROVED_PAYMENTS']} {approved_payment}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['NUM_ORDERS']} {total_orders}\n{MESSAGES['TOTAL_ORDERS_VALUME']} {total_valume}\n{MESSAGES['TOTAL_ORDERS_SALES']} {utils.rial_to_toman(total_sales)}{MESSAGES['TOMAN']}\n\"\"\"\n\n# Bot Users Order Info Message Template\ndef bot_orders_info_template(order, plan, user, server, header=\"\"):\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    username = f\"@{user['username']}\" if user['username'] else MESSAGES['NOT_SET']\n\n    return f\"\"\"\n{header}\n{MESSAGES['BOT_ORDER_ID']}<code>{order['id']}</code>\n{MESSAGES['BOT_ORDER_DATE']}{order['created_at']}\n{MESSAGES['INFO_USER_NAME']}<b>{name}</b>\n{MESSAGES['INFO_USER_USERNAME']}{username}\n{MESSAGES['INFO_USER_NUM_ID']}{user['telegram_id']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['ORDERED_VALUME']}{plan['size_gb']}\n{MESSAGES['ORDERED_DAYS']}{plan['days']}\n{MESSAGES['ORDERED_PRICE']}{utils.rial_to_toman(plan['price'])}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['SUB_NAME']}{order['user_name']}\n{MESSAGES['SERVER']}{server['title']}\n\"\"\"\n\n# Payment Received Template - Send to Admin\ndef bot_payment_info_template(payment,user, header=\"\", footer=\"\"):\n    #approved = \"✅\" if payment['approved'] else \"❌\"\n    if payment['approved']: approved = \"✅\"\n    elif payment['approved'] == False: approved = \"❌\"\n    else: approved = \"⏳\"\n    username = f\"@{user['username']}\" if user['username'] else MESSAGES['NOT_SET']\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    return f\"\"\"\n{header}\n\n{MESSAGES['PAYMENTS_ID']} <code>{payment['id']}</code>\n{MESSAGES['INFO_USER_NAME']} <b>{name}</b>\n{MESSAGES['INFO_USER_USERNAME']} {username}\n{MESSAGES['INFO_USER_NUM_ID']} {user['telegram_id']}\n{MESSAGES['BOT_PAYMENT_DATE']} {payment['created_at']}\n{MESSAGES['PAIED_AMOUNT']} <b>{utils.rial_to_toman(payment['payment_amount'])}</b> {MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['STATUS']} {approved}\n{MESSAGES['PAYMENTS_METHOD']} {payment['payment_method']}\n\n{footer}\n\"\"\"\n\n# Bot Users List Message Template\ndef bot_orders_list_template(orders, plans, header=\"\"):\n\n    total_orders = 0\n    total_valume = 0\n    total_sales = 0\n    last30day = datetime.datetime.now() - datetime.timedelta(days=30)\n    last30days_orders = [order for order in orders if datetime.datetime.strptime(order['created_at'], \"%Y-%m-%d %H:%M:%S\") >= last30day]\n    last30days_num_orders = 0\n    last30days_valume = 0\n    last30days_sales = 0\n    first_day_this_month = datetime.datetime.today().replace(day=1)\n    this_month_orders = [order for order in orders if datetime.datetime.strptime(order['created_at'], \"%Y-%m-%d %H:%M:%S\") >= first_day_this_month]\n    this_month_num_orders = 0\n    this_month_valume = 0\n    this_month_sales = 0\n    if orders:\n        total_orders = len(orders)\n        if plans:\n            for order in orders:\n                for plan in plans:\n                    if order['plan_id'] == plan['id']:\n                        total_valume += plan['size_gb']\n                        total_sales += plan['price']\n                        break\n    if last30days_orders:\n        last30days_num_orders = len(last30days_orders)\n        if plans:\n            for order in last30days_orders:\n                for plan in plans:\n                    if order['plan_id'] == plan['id']:\n                        last30days_valume += plan['size_gb']\n                        last30days_sales += plan['price']\n                        break\n    if this_month_orders:\n        this_month_num_orders = len(this_month_orders)\n        if plans:\n            for order in this_month_orders:\n                for plan in plans:\n                    if order['plan_id'] == plan['id']:\n                        this_month_valume += plan['size_gb']\n                        this_month_sales += plan['price']\n                        break\n        \n\n    return f\"\"\"\n{header}\n<b>{MESSAGES['HEADER_ORDERS_LIST']}</b>\n{MESSAGES['NUM_ORDERS']} {total_orders}\n{MESSAGES['TOTAL_ORDERS_VALUME']} {total_valume}\n{MESSAGES['TOTAL_ORDERS_SALES']} {utils.rial_to_toman(total_sales)}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['LAST_30DAYS_NUM_ORDERS']} {last30days_num_orders}\n{MESSAGES['LAST_30DAYS_ORDERS_VALUME']} {last30days_valume }\n{MESSAGES['LAST_30DAYS_ORDERS_SALES']} {utils.rial_to_toman(last30days_sales)}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['THIS_MONTH_NUM_ORDERS']} {this_month_num_orders}\n{MESSAGES['THIS_MONTH_ORDERS_VALUME']} {this_month_valume}\n{MESSAGES['THIS_MONTH_ORDERS_SALES']} {utils.rial_to_toman(this_month_sales)}{MESSAGES['TOMAN']}\n\"\"\"\n\n# Bot Users List Message Template\ndef bot_payments_list_template(payments, header=\"\"):\n\n    total_payments = 0\n    total_amount = 0\n    last30day = datetime.datetime.now() - datetime.timedelta(days=30)\n    last30days_payments  = [payment for payment in payments if datetime.datetime.strptime(payment['created_at'], \"%Y-%m-%d %H:%M:%S\") >= last30day]\n    last30days_num_payments = 0\n    last30days_amount = 0\n    first_day_this_month = datetime.datetime.today().replace(day=1)\n    this_month_orders = [payment for payment in payments if datetime.datetime.strptime(payment['created_at'], \"%Y-%m-%d %H:%M:%S\") >= first_day_this_month]\n    this_month_num_payments = 0\n    this_month_amount = 0\n    if payments:\n        total_payments = len(payments)\n        for payment in payments:\n                total_amount += payment['payment_amount']\n\n    if last30days_payments:\n        last30days_num_payments = len(last30days_payments)\n        for payment in last30days_payments:\n                last30days_amount += payment['payment_amount']\n\n    if this_month_orders:\n        this_month_num_payments = len(this_month_orders)\n        for payment in this_month_orders:\n                this_month_amount += payment['payment_amount']\n        \n\n    return f\"\"\"\n{header}\n<b>{MESSAGES['HEADER_PAYMENT_LIST']}</b>\n{MESSAGES['NUM_PAYMENTS']}{total_payments}\n{MESSAGES['TOTAL_PAYMENTS_AMOUNT']}{utils.rial_to_toman(total_amount)}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['LAST_30DAYS_NUM_PAYMENTS']}{last30days_num_payments}\n{MESSAGES['LAST_30DAYS_PAYMENTS_AMOUNT']}{utils.rial_to_toman(last30days_amount)}{MESSAGES['TOMAN']}\n❖⬩╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍⬩❖\n{MESSAGES['THIS_MONTH_NUM_PAYMENTS']}{this_month_num_payments}\n{MESSAGES['THIS_MONTH_PAYMENTS_AMOUNT']}{utils.rial_to_toman(this_month_amount)}{MESSAGES['TOMAN']}\n\"\"\"\n\n# Configs List Message Template\ndef configs_template(configs):\n    messages = []\n    result = []\n    chunk_size = 5\n\n    for config in configs:\n       messages.append(f\"<b>{urllib.parse.unquote(config[1])}</b>\\n<code>{config[0]}</code>\\n\")\n\n    for i in range(0, len(messages), chunk_size):\n        chunk = messages[i:i + chunk_size]\n        result.append(\"\\n\".join(chunk))\n    return result\n\n\n# System Status Message Template\ndef system_status_template(status):\n    return f\"\"\"\n<b> System Status </b>\n--------------------------------\n<b> CPU: </b> {status['cpu']}%\n<b> RAM: </b> {status['ram']}%\n<b> DISK: </b> {status['disk']}%\n\"\"\"\n\n\n# Last Online Time Template\ndef last_online_time_template(last_online_time):\n    if last_online_time.days >= 30:\n        return f\"{last_online_time.days // 30} {MESSAGES['MONTH']} {MESSAGES['AGO']} \"\n    elif last_online_time.days >= 7:\n        return f\"{last_online_time.days // 7} {MESSAGES['WEEK']} {MESSAGES['AGO']}\"\n    elif last_online_time.days > 0:\n        return f\"{last_online_time.days} {MESSAGES['DAY']} {MESSAGES['AGO']}\"\n    elif last_online_time.seconds > 3600:\n        return f\"{last_online_time.seconds // 3600} {MESSAGES['HOUR']} {MESSAGES['AGO']}\"\n    elif last_online_time.seconds <= 5 * 60:\n        return f\"{MESSAGES['ONLINE']}\"\n    elif last_online_time.seconds > 60:\n        return f\"{last_online_time.seconds // 60} {MESSAGES['MINUTE']} {MESSAGES['AGO']}\"\n    else:\n        return MESSAGES['NEVER']\n\n\n# Owner Info Message Template\ndef owner_info_template(username, card_number_card, card_name):\n    username = username if username else \"-\"\n    card_number_card = card_number_card if card_number_card else \"-\"\n    card_name = card_name if card_name else \"-\"\n    if LANG == 'FA':\n        return f\"\"\"\n<b> اطلاعات مالک </b>\n--------------------------------\n<b> نام کاربری پشتیبان: </b> {username}\n<b> شماره کارت بانکی: </b> {card_number_card}\n<b> نام صاحب حساب بانکی: </b> {card_name}\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\n<b> Owner Info </b>\n--------------------------------\n<b> Telegram Support Username: </b> {username} \n<b> Bank Card Number: </b> {card_number_card}\n<b> Bank Card Name: </b> {card_name}\n\"\"\"\n\n\n# About Bot Message Template\ndef about_template():\n    if LANG == 'FA':\n        return f\"\"\"\n🤖هیدی بات، راحت تر از همیشه!\n\n<a href='https://github.com/B3H1Z/Hiddify-Telegram-Bot'> لینک پروژه </a>\n\n<a href='https://t.me/HidyBotGroup'> گروه پشتیبانی </a> | <a href='https://t.me/HidyBotChannel'> کانال اطلاع رسانی </a>\n\nاین پروژه به صورت رایگان توسعه داده شده و جهت ادامه توسعه رایگان، حمایت های شما میتواند انگیزه بخش باشد❤️\n\nنسخه: {VERSION}\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\n🤖Hiddify Bot, Easier than ever!\n\n<a href='https://github.com/B3H1Z/Hiddify-Telegram-Bot'> Project </a>|<a href='https://t.me/HidyBotGroup'> Support Group </a>\n\nThis project is developed for free and your financial support can be motivating for further development❤️\n\nVersion: {VERSION}\n\"\"\"\n"
  },
  {
    "path": "Cronjob/backup.py",
    "content": "from AdminBot.bot import bot\nfrom config import ADMINS_ID\nfrom Utils.utils import full_backup,all_configs_settings\nimport logging\ntry:\n    bot.remove_webhook()\nexcept:\n    pass\n\ndef cron_backup():\n    zip_file_name = full_backup()\n    if not zip_file_name:\n        logging.error(\"Backup failed\")\n        return\n    settings = all_configs_settings()\n    if not settings['panel_auto_backup']:\n        return\n    for admin_id in ADMINS_ID:\n        bot.send_document(admin_id, open(zip_file_name, 'rb'), caption=\"🤖Backup\",disable_notification=True)\n    \n    "
  },
  {
    "path": "Cronjob/backupBot.py",
    "content": "from Utils.utils import all_configs_settings, backup_json_bot\nfrom AdminBot.bot import bot\nfrom config import ADMINS_ID\ntry:\n    bot.remove_webhook()\nexcept:\n    pass\n\n# Send backup file to admins\ndef cron_backup_bot():\n    file_name = backup_json_bot()\n    settings = all_configs_settings()\n    if not settings['bot_auto_backup']:\n        return\n    if file_name:\n        for admin_id in ADMINS_ID:\n            bot.send_document(admin_id, open(file_name, 'rb'), caption=\"🤖Bot Backup\",disable_notification=True)"
  },
  {
    "path": "Cronjob/reminder.py",
    "content": "from Utils.utils import *\nfrom UserBot.bot import bot\nfrom config import CLIENT_TOKEN\nfrom UserBot.templates import package_size_end_soon_template, package_days_expire_soon_template\ntry:\n    bot.remove_webhook()\nexcept:\n    pass\n\nsettings = all_configs_settings()\nALERT_PACKAGE_GB = settings.get('reminder_notification_usage', 3)\nALERT_PACKAGE_DAYS = settings.get('reminder_notification_days', 3)\n\n\ndef alert_package_gb(package_remaining_gb):\n    if package_remaining_gb <= ALERT_PACKAGE_GB:\n        return True\n    return False\n\n\ndef alert_package_days(package_remaining_days):\n    if package_remaining_days <= ALERT_PACKAGE_DAYS:\n        return True\n    return False\n\n\n# Send a reminder to users about their packages\ndef cron_reminder():\n    if not CLIENT_TOKEN:\n        return\n    if not settings['reminder_notification']:\n        return\n\n    telegram_users = USERS_DB.select_users()\n    if telegram_users:\n        for user in telegram_users:\n            user_telegram_id = user['telegram_id']\n            user_subscriptions_list = non_order_user_info(user_telegram_id) + order_user_info(user_telegram_id)\n            if user_subscriptions_list:\n                for user_subscription in user_subscriptions_list:\n                    package_days = user_subscription.get('remaining_day', 0)\n                    package_gb = user_subscription.get('usage', {}).get('remaining_usage_GB', 0)\n                    sub_id = user_subscription.get('sub_id')\n                    if package_days == 0:\n                        continue\n                    if alert_package_gb(package_gb):\n                        bot.send_message(user_telegram_id, package_size_end_soon_template(sub_id, package_gb))\n                    if alert_package_days(package_days):\n                        bot.send_message(user_telegram_id, package_days_expire_soon_template(sub_id, package_days))\n"
  },
  {
    "path": "Database/dbManager.py",
    "content": "import datetime\nimport json\nimport logging\nimport os\nimport sqlite3\nfrom sqlite3 import Error\nfrom version import is_version_less\n#from urllib.parse import urlparse\n\n#from Utils import api\n#from config import PANEL_URL, API_PATH, USERS_DB_LOC\n\n\n\n\nclass UserDBManager:\n    def __init__(self, db_file):\n        self.conn = self.create_connection(db_file)\n        self.create_user_table()\n        #self.set_default_configs()\n\n    #close connection\n    def __del__(self):\n        self.conn.close()\n    \n    def close(self):\n        self.conn.close()\n    \n\n    def create_connection(self, db_file):\n        \"\"\" Create a database connection to a SQLite database \"\"\"\n        try:\n            conn = sqlite3.connect(db_file, check_same_thread=False)\n            return conn\n        except Error as e:\n            logging.error(f\"Error while connecting to database \\n Error:{e}\")\n            return None\n\n    def create_user_table(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"CREATE TABLE IF NOT EXISTS users (\"\n                        \"id INTEGER PRIMARY KEY AUTOINCREMENT,\"\n                        \"telegram_id INTEGER NOT NULL UNIQUE,\"\n                        \"full_name TEXT NULL,\"\n                        \"username TEXT NULL,\"\n                        # \"referral_code INTEGER NOT NULL,\"\n                        # \"referred_by INTEGER NULL,\"\n                        # \"discount_percent INTEGER NOT NULL DEFAULT 0,\"\n                        # \"count_warn INTEGER NOT NULL DEFAULT 0,\"\n                        \"test_subscription BOOLEAN NOT NULL DEFAULT 0,\"\n                        \"banned BOOLEAN NOT NULL DEFAULT 0,\"\n                        \"created_at TEXT NOT NULL)\")\n            self.conn.commit()\n            logging.info(\"User table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS plans (\"\n                        \"id INTEGER PRIMARY KEY,\"\n                        \"size_gb INTEGER NOT NULL,\"\n                        \"days INTEGER NOT NULL,\"\n                        \"price INTEGER NOT NULL,\"\n                        \"server_id INTEGER NOT NULL,\"\n                        \"description TEXT NULL,\"\n                        \"status BOOLEAN NOT NULL,\"\n                        \"FOREIGN KEY (server_id) REFERENCES server (id))\")\n            self.conn.commit()\n            logging.info(\"Plans table created successfully!\")\n\n            # cur.execute(\"CREATE TABLE IF NOT EXISTS user_plans (\"\n            #             \"id INTEGER PRIMARY KEY,\"\n            #             \"telegram_id INTEGER NOT NULL UNIQUE,\"\n            #             \"plan_id INTEGER NOT NULL,\"\n            #             \"FOREIGN KEY (telegram_id) REFERENCES users (telegram_id),\"\n            #             \"FOREIGN KEY (plan_id) REFERENCES plans (id))\")\n            # self.conn.commit()\n            # logging.info(\"Plans table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS orders (\"\n                        \"id INTEGER PRIMARY KEY,\"\n                        \"telegram_id INTEGER NOT NULL,\"\n                        \"plan_id INTEGER NOT NULL,\"\n                        \"user_name TEXT NOT NULL,\"\n                        \"created_at TEXT NOT NULL,\"\n                        \"FOREIGN KEY (telegram_id) REFERENCES user (telegram_id),\"\n                        \"FOREIGN KEY (plan_id) REFERENCES plans (id))\")\n            self.conn.commit()\n            logging.info(\"Orders table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS order_subscriptions (\"\n                        \"id INTEGER PRIMARY KEY,\"\n                        \"order_id INTEGER NOT NULL,\"\n                        \"uuid TEXT NOT NULL,\"\n                        \"server_id INTEGER NOT NULL,\"\n                        \"FOREIGN KEY (server_id) REFERENCES server (id),\"\n                        \"FOREIGN KEY (order_id) REFERENCES orders (id))\")\n            self.conn.commit()\n            logging.info(\"Order subscriptions table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS non_order_subscriptions (\"\n                        \"id INTEGER PRIMARY KEY,\"\n                        \"telegram_id INTEGER NOT NULL,\"\n                        \"uuid TEXT NOT NULL UNIQUE,\"\n                        \"server_id INTEGER NOT NULL,\"\n                        \"FOREIGN KEY (server_id) REFERENCES server (id),\"\n                        \"FOREIGN KEY (telegram_id) REFERENCES users (telegram_id))\")\n            self.conn.commit()\n            logging.info(\"Non order subscriptions table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS str_config (\"\n                        \"key TEXT NOT NULL UNIQUE,\"\n                        \"value TEXT NULL)\")\n            self.conn.commit()\n            logging.info(\"str_config table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS int_config (\"\n                        \"key TEXT NOT NULL UNIQUE,\"\n                        \"value INTEGER NOT NULL)\")\n            self.conn.commit()\n            logging.info(\"int_config table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS bool_config (\"\n                        \"key TEXT NOT NULL UNIQUE,\"\n                        \"value BOOLEAN NOT NULL)\")\n            self.conn.commit()\n            logging.info(\"bool_config table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS wallet (\"\n                        \"telegram_id INTEGER NOT NULL UNIQUE,\"\n                        \"balance INTEGER NOT NULL DEFAULT 0,\"\n                        \"FOREIGN KEY (telegram_id) REFERENCES users (telegram_id))\")\n            self.conn.commit()\n            logging.info(\"wallet table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS payments (\"\n                        \"id INTEGER PRIMARY KEY,\"\n                        \"telegram_id INTEGER NOT NULL,\"\n                        \"payment_amount INTEGER NOT NULL,\"\n                        \"payment_method TEXT NOT NULL,\"\n                        \"payment_image TEXT NOT NULL,\"\n                        # \"user_name TEXT NOT NULL,\"\n                        \"approved BOOLEAN NULL,\"\n                        \"created_at TEXT NOT NULL,\"\n                        \"FOREIGN KEY (telegram_id) REFERENCES users (telegram_id))\")\n            self.conn.commit()\n            logging.info(\"Payments table created successfully!\")\n\n            cur.execute(\"CREATE TABLE IF NOT EXISTS servers (\"\n                        \"id INTEGER PRIMARY KEY AUTOINCREMENT,\"\n                        \"url TEXT NOT NULL,\"\n                        \"title TEXT, description TEXT,\"\n                        \"user_limit INTEGER NOT NULL,\"\n                        \"status BOOLEAN NOT NULL,\"\n                        \"default_server BOOLEAN NOT NULL DEFAULT 0)\")\n            self.conn.commit()\n            logging.info(\"Servers table created successfully!\")\n\n\n        except Error as e:\n            logging.error(f\"Error while creating user table \\n Error:{e}\")\n            return False\n        return True\n\n    def select_users(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM users\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all users \\n Error:{e}\")\n            return None\n\n    def find_user(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find user!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM users WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"User {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding user {kwargs} \\n Error:{e}\")\n            return None\n\n    def delete_user(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to delete user!\")\n            return False\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM users WHERE {key}=?\", (value,))\n                self.conn.commit()\n            logging.info(f\"User {kwargs} deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting user {kwargs} \\n Error:{e}\")\n            return False\n\n    def edit_user(self, telegram_id, **kwargs):\n        cur = self.conn.cursor()\n\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE users SET {key}=? WHERE telegram_id=?\", (value, telegram_id))\n                self.conn.commit()\n                logging.info(f\"User [{telegram_id}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating user [{telegram_id}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def add_user(self, telegram_id, full_name,username, created_at):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"INSERT INTO users(telegram_id, full_name,username, created_at) VALUES(?,?,?,?)\",\n                        (telegram_id, full_name,username, created_at))\n            self.conn.commit()\n            logging.info(f\"User [{telegram_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding user [{telegram_id}] \\n Error: {e}\")\n            return False\n\n    def add_plan(self, plan_id, size_gb, days, price, server_id, description=None, status=True):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"INSERT INTO plans(id,size_gb, days, price, server_id, description, status) VALUES(?,?,?,?,?,?,?)\",\n                        (plan_id, size_gb, days, price, server_id, description, status))\n            self.conn.commit()\n            logging.info(f\"Plan [{size_gb}GB] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding plan [{size_gb}GB] \\n Error: {e}\")\n            return False\n\n    def select_plans(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM plans ORDER BY price ASC\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all plans \\n Error:{e}\")\n            return None\n\n    def find_plan(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find plan!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM plans WHERE {key}=? ORDER BY price ASC\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Plan {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding plan {kwargs} \\n Error:{e}\")\n            return None\n\n    def delete_plan(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to delete plan!\")\n            return False\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM plans WHERE {key}=?\", (value,))\n                self.conn.commit()\n            logging.info(f\"Plan {kwargs} deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting plan {kwargs} \\n Error:{e}\")\n            return False\n\n    def edit_plan(self, plan_id, **kwargs):\n        cur = self.conn.cursor()\n\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE plans SET {key}=? WHERE id=?\", (value, plan_id))\n                self.conn.commit()\n                logging.info(f\"Plan [{plan_id}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating plan [{plan_id}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n    \n    def add_user_plans(self, telegram_id, plan_id):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"INSERT INTO user_plans(telegram_id, plan_id) VALUES(?,?)\",\n                        (telegram_id, plan_id))\n            self.conn.commit()\n            logging.info(f\"Plan [{plan_id}] Reserved for [{telegram_id}] successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while Reserving plan [{plan_id}] for [{telegram_id}] \\n Error: {e}\")\n            return False\n\n    def select_user_plans(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM user_plans\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all user_plans \\n Error:{e}\")\n            return None\n\n    def find_user_plans(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find user_plan!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM user_plans WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Plan {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding user_plans {kwargs} \\n Error:{e}\")\n            return None\n\n    def delete_user_plans(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to delete user_plan!\")\n            return False\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM user_plans WHERE {key}=?\", (value,))\n                self.conn.commit()\n            logging.info(f\"Plan {kwargs} deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting user_plans {kwargs} \\n Error:{e}\")\n            return False\n\n    def edit_user_plans(self, user_plans_id, **kwargs):\n        cur = self.conn.cursor()\n\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE user_plans SET {key}=? WHERE id=?\", (value, user_plans_id))\n                self.conn.commit()\n                logging.info(f\"user_plans [{user_plans_id}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating user_plans [{user_plans_id}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n    \n    def add_order(self, order_id, telegram_id,user_name, plan_id, created_at):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO orders(id,telegram_id, plan_id,user_name,created_at) VALUES(?,?,?,?,?)\",\n                (order_id, telegram_id, plan_id,user_name, created_at))\n            self.conn.commit()\n            logging.info(f\"Order [{order_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding order [{order_id}] \\n Error: {e}\")\n            return False\n\n    def select_orders(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM orders\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all orders \\n Error:{e}\")\n            return None\n\n    def find_order(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find order!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM orders WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Order {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding order {kwargs} \\n Error:{e}\")\n            return None\n\n    def edit_order(self, order_id, **kwargs):\n        cur = self.conn.cursor()\n\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE orders SET {key}=? WHERE id=?\", (value, order_id))\n                self.conn.commit()\n                logging.info(f\"Order [{order_id}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating order [{order_id}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def add_order_subscription(self, sub_id, order_id, uuid, server_id):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO order_subscriptions(id,order_id,uuid,server_id) VALUES(?,?,?,?)\",\n                (sub_id, order_id, uuid, server_id))\n            self.conn.commit()\n            logging.info(f\"Order [{order_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding order [{order_id}] \\n Error: {e}\")\n            return False\n\n    def select_order_subscription(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM order_subscriptions\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all orders \\n Error:{e}\")\n            return None\n\n    def find_order_subscription(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find order!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM order_subscriptions WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Order {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding order {kwargs} \\n Error:{e}\")\n            return None\n\n    def edit_order_subscriptions(self, order_id, **kwargs):\n        cur = self.conn.cursor()\n\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE order_subscriptions SET {key}=? WHERE order_id=?\", (value, order_id))\n                self.conn.commit()\n                logging.info(f\"Order [{order_id}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating order [{order_id}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def delete_order_subscription(self, **kwargs):\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM order_subscriptions WHERE {key}=?\", (value,))\n                self.conn.commit()\n                logging.info(f\"Order [{value}] deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting order [{kwargs}] \\n Error: {e}\")\n            return False\n\n    def add_non_order_subscription(self, non_sub_id, telegram_id, uuid, server_id):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO non_order_subscriptions(id,telegram_id,uuid,server_id) VALUES(?,?,?,?)\",\n                (non_sub_id, telegram_id, uuid, server_id))\n            self.conn.commit()\n            logging.info(f\"Order [{telegram_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding order [{telegram_id}] \\n Error: {e}\")\n            return False\n\n    def select_non_order_subscriptions(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM non_order_subscriptions\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all orders \\n Error:{e}\")\n            return None\n\n    def find_non_order_subscription(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find order!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM non_order_subscriptions WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Order {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding order {kwargs} \\n Error:{e}\")\n            return None\n\n    def delete_non_order_subscription(self, **kwargs):\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM non_order_subscriptions WHERE {key}=?\", (value,))\n                self.conn.commit()\n                logging.info(f\"Order [{value}] deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting order [{kwargs}] \\n Error: {e}\")\n            return False\n\n    def edit_bool_config(self, key_row, **kwargs):\n        cur = self.conn.cursor()\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE bool_config SET {key}=? WHERE key=?\", (value, key_row))\n                self.conn.commit()\n                logging.info(f\"Settings [{key}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating settings [{key}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def find_bool_config(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find settings!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM bool_config WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Settings {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding settings {kwargs} \\n Error:{e}\")\n            return None\n\n    def add_bool_config(self, key, value):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT or IGNORE INTO bool_config(key,value) VALUES(?,?)\",\n                (key, value))\n            self.conn.commit()\n            logging.info(f\"Settings [{key}] added successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while adding settings [{key}] \\n Error: {e}\")\n            return False\n        finally:\n            cur.close()\n            \n\n    def select_bool_config(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM bool_config\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all settings \\n Error:{e}\")\n            return None\n\n    def select_str_config(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM str_config\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all settings \\n Error:{e}\")\n            return None\n\n    def find_str_config(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find settings!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM str_config WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Settings {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding settings {kwargs} \\n Error:{e}\")\n            return None\n\n    def edit_str_config(self, key_row, **kwargs):\n        cur = self.conn.cursor()\n        for key, value in kwargs.items():\n            try:\n                cur.execute(f\"UPDATE str_config SET {key}=? WHERE key=?\", (value, key_row))\n                self.conn.commit()\n                logging.info(f\"Settings [{key}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating settings [{key}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def add_str_config(self, key, value):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT or IGNORE INTO str_config(key,value) VALUES(?,?)\",\n                (key, value))\n            self.conn.commit()\n            logging.info(f\"Settings [{key}] added successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while adding settings [{key}] \\n Error: {e}\")\n            return False\n        finally:\n            cur.close()\n\n    def select_int_config(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM int_config\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all settings \\n Error:{e}\")\n            return None\n\n    def find_int_config(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find settings!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM int_config WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Settings {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding settings {kwargs} \\n Error:{e}\")\n            return None\n    def edit_int_config(self, key_row, **kwargs):\n        cur = self.conn.cursor()\n        for key, value in kwargs.items():            \n            try:\n                cur.execute(f\"UPDATE int_config SET {key}=? WHERE key=?\", (value, key_row))\n                self.conn.commit()\n                logging.info(f\"Settings [{key}] successfully update [{key}] to [{value}]\")\n            except Error as e:\n                logging.error(f\"Error while updating settings [{key}] [{key}] to [{value}] \\n Error: {e}\")\n                return False\n\n        return True\n\n    def add_int_config(self, key, value):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT or IGNORE INTO int_config(key,value) VALUES(?,?)\",\n                (key, value))\n            self.conn.commit()\n            logging.info(f\"Settings [{key}] added successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while adding settings [{key}] \\n Error: {e}\")\n            return False\n        finally:\n            cur.close()\n\n    def set_default_configs(self):\n        \n        self.add_bool_config(\"visible_hiddify_hyperlink\", True)\n        self.add_bool_config(\"three_random_num_price\", False)\n        self.add_bool_config(\"force_join_channel\", False)\n        self.add_bool_config(\"panel_auto_backup\", True)\n        self.add_bool_config(\"bot_auto_backup\", True)\n        self.add_bool_config(\"test_subscription\", True)\n        self.add_bool_config(\"reminder_notification\", True)\n        \n        self.add_bool_config(\"renewal_subscription_status\", True)\n        self.add_bool_config(\"buy_subscription_status\", True)\n\n\n        self.add_bool_config(\"visible_conf_dir\", False)\n        self.add_bool_config(\"visible_conf_sub_auto\", True)\n        self.add_bool_config(\"visible_conf_sub_url\", False)\n        self.add_bool_config(\"visible_conf_sub_url_b64\", False)\n        self.add_bool_config(\"visible_conf_clash\", False)\n        self.add_bool_config(\"visible_conf_hiddify\", False)\n        self.add_bool_config(\"visible_conf_sub_sing_box\", False)\n        self.add_bool_config(\"visible_conf_sub_full_sing_box\", False)\n\n        self.add_str_config(\"bot_admin_id\", None)\n        self.add_str_config(\"bot_token_admin\", None)\n        self.add_str_config(\"bot_token_client\", None)\n        self.add_str_config(\"bot_lang\", None)\n\n        self.add_str_config(\"card_number\", None)\n        self.add_str_config(\"card_holder\", None)\n        self.add_str_config(\"support_username\", None)\n        self.add_str_config(\"channel_id\", None)\n        self.add_str_config(\"msg_user_start\", None)\n\n        self.add_str_config(\"msg_manual_android\", None)\n        self.add_str_config(\"msg_manual_ios\", None)\n        self.add_str_config(\"msg_manual_windows\", None)\n        self.add_str_config(\"msg_manual_mac\", None)\n        self.add_str_config(\"msg_manual_linux\", None)\n\n        self.add_str_config(\"msg_faq\", None)\n\n        self.add_int_config(\"min_deposit_amount\", 10000)\n\n        self.add_int_config(\"reminder_notification_days\", 3)\n        self.add_int_config(\"reminder_notification_usage\", 3)\n\n        self.add_int_config(\"test_sub_days\", 1)\n        self.add_int_config(\"test_sub_size_gb\", 1)\n        \n        self.add_int_config(\"advanced_renewal_days\", 3)\n        self.add_int_config(\"advanced_renewal_usage\", 3)\n        \n        self.add_int_config(\"renewal_method\", 1)\n\n\n\n    def add_wallet(self, telegram_id):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO wallet(telegram_id) VALUES(?)\",\n                (telegram_id,))\n            self.conn.commit()\n            logging.info(f\"Balance [{telegram_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding balance [{telegram_id}] \\n Error: {e}\")\n            return False\n\n    def select_wallet(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM wallet\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all balance \\n Error:{e}\")\n            return None\n\n    def find_wallet(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find balance!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM wallet WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Balance {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding balance {kwargs} \\n Error:{e}\")\n            return None\n\n    def edit_wallet(self, telegram_id, **kwargs):\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"UPDATE wallet SET {key}=? WHERE telegram_id=?\", (value, telegram_id,))\n                self.conn.commit()\n                logging.info(f\"balance successfully update [{key}] to [{value}]\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while updating balance [{key}] to [{value}] \\n Error: {e}\")\n            return False\n\n    def add_payment(self, payment_id, telegram_id, payment_amount, payment_method, payment_image, created_at):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO payments(id,telegram_id, payment_amount,payment_method,payment_image,created_at) VALUES(?,?,?,?,?,?)\",\n                (payment_id, telegram_id, payment_amount, payment_method, payment_image, created_at))\n            self.conn.commit()\n            logging.info(f\"Payment [{payment_id}] added successfully!\")\n            return True\n\n        except Error as e:\n            logging.error(f\"Error while adding payment [{payment_id}] \\n Error: {e}\")\n            return False\n\n    def edit_payment(self, payment_id, **kwargs):\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"UPDATE payments SET {key}=? WHERE id=?\", (value, payment_id))\n                self.conn.commit()\n                logging.info(f\"payment successfully update [{key}] to [{value}]\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while updating payment [{key}] to [{value}] \\n Error: {e}\")\n            return False\n\n    def find_payment(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find payment!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM payments WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Payment {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding payment {kwargs} \\n Error:{e}\")\n            return None\n        \n    def select_payments(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM payments\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all payments \\n Error:{e}\")\n            return None\n    \n    def select_servers(self):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\"SELECT * FROM servers\")\n            rows = cur.fetchall()\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while selecting all servers \\n Error:{e}\")\n            return None\n        \n    def add_server(self, url, user_limit, title=None, description=None, status=True, default_server=False):\n        cur = self.conn.cursor()\n        try:\n            cur.execute(\n                \"INSERT INTO servers(url,title,description,user_limit,status,default_server) VALUES(?,?,?,?,?,?)\",\n                (url, title, description, user_limit, status, default_server))\n            self.conn.commit()\n            logging.info(f\"Server [{url}] added successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while adding server [{url}] \\n Error: {e}\")\n            return False\n    \n    def edit_server(self, server_id, **kwargs):\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"UPDATE servers SET {key}=? WHERE id=?\", (value, server_id))\n                self.conn.commit()\n                logging.info(f\"Server [{server_id}] successfully update [{key}] to [{value}]\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while updating server [{server_id}] [{key}] to [{value}] \\n Error: {e}\")\n            return False\n    \n    def find_server(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to find server!\")\n            return None\n        rows = []\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"SELECT * FROM servers WHERE {key}=?\", (value,))\n                rows = cur.fetchall()\n            if len(rows) == 0:\n                logging.info(f\"Server {kwargs} not found!\")\n                return None\n            rows = [dict(zip([key[0] for key in cur.description], row)) for row in rows]\n            return rows\n        except Error as e:\n            logging.error(f\"Error while finding server {kwargs} \\n Error:{e}\")\n            return None\n        \n    def delete_server(self, **kwargs):\n        if len(kwargs) != 1:\n            logging.warning(\"You can only use one key to delete server!\")\n            return False\n        cur = self.conn.cursor()\n        try:\n            for key, value in kwargs.items():\n                cur.execute(f\"DELETE FROM servers WHERE {key}=?\", (value,))\n                self.conn.commit()\n            logging.info(f\"server {kwargs} deleted successfully!\")\n            return True\n        except Error as e:\n            logging.error(f\"Error while deleting server {kwargs} \\n Error:{e}\")\n            return False\n        \n    \n    def backup_to_json(self, backup_dir):\n        try:\n\n            backup_data = {}  # Store backup data in a dictionary\n\n            # List of tables to backup\n            tables = ['users', 'plans', 'orders', 'order_subscriptions', 'non_order_subscriptions',\n                      'str_config', 'int_config', 'bool_config', 'wallet', 'payments', 'servers']\n\n            for table in tables:\n                cur = self.conn.cursor()\n                cur.execute(f\"SELECT * FROM {table}\")\n                rows = cur.fetchall()\n\n                # Convert rows to list of dictionaries\n                table_data = []\n                for row in rows:\n                    columns = [column[0] for column in cur.description]\n                    table_data.append(dict(zip(columns, row)))\n\n                backup_data[table] = table_data\n            return backup_data\n\n        except sqlite3.Error as e:\n            logging.error('SQLite error:', str(e))\n            return False\n    def restore_from_json(self, backup_file):\n        logging.info(f\"Restoring database from {backup_file}...\")\n        try:\n            cur = self.conn.cursor()\n\n            with open(backup_file, 'r') as json_file:\n                backup_data = json.load(json_file)\n                \n            if not isinstance(backup_data, dict):\n                logging.error('Backup data should be a dictionary.')\n                print('Backup data should be a dictionary.')\n                return\n            # print(backup_data.get('version'), VERSION)\n            # if backup_data.get('version') != VERSION:\n            #     if backup_data.get('version') is None:\n            #         logging.error('Backup data version is not found.')\n            #         print('Backup data version is not found.')\n            #         return\n            #     if VERSION.find('-pre'):\n            #         VERSION = VERSION.split('-pre')[0]\n            #     if is_version_less(backup_data.get('version'),VERSION ):\n            #         logging.error('Backup data version is less than current version.')\n            #         print('Backup data version is less than current version.')\n            #         if is_version_less(backup_data.get('version'), '5.5.0'):\n            #             logging.error('Backup data version is less than 5.5.0.')\n            #             print('Backup data version is less than 5.5.0.')\n            #             return \n\n            self.conn.execute('BEGIN TRANSACTION')\n\n            for table, data in backup_data.items():\n                if table == 'version':\n                    continue\n                logging.info(f\"Restoring table {table}...\")\n                for entry in data:\n                    if not isinstance(entry, dict):\n                        logging.error('Invalid entry format. Expected a dictionary.')\n                        print('Invalid entry format. Expected a dictionary.')\n                        continue\n\n                    keys = ', '.join(entry.keys())\n                    placeholders = ', '.join(['?' for _ in entry.values()])\n                    values = tuple(entry.values())\n                    query = f\"INSERT OR REPLACE INTO {table} ({keys}) VALUES ({placeholders})\"\n                    logging.info(f\"Query: {query}\")\n                    \n                    try:\n                        cur.execute(query, values)\n                    except sqlite3.Error as e:\n                        logging.error('SQLite error:', str(e))\n                        logging.error('Entry:', entry)\n                        print('SQLite error:', str(e))\n                        print('Entry:', entry)\n\n            self.conn.commit()\n            logging.info('Database restored successfully.')\n            return True\n\n        except sqlite3.Error as e:\n            logging.error('SQLite error:', str(e))\n            return False\n    \n\nUSERS_DB_LOC = os.path.join(os.getcwd(), \"Database\", \"hidyBot.db\")\nUSERS_DB = UserDBManager(USERS_DB_LOC)\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    Hidy-Bot | Hiddify-Telegram-Bot  Copyright (C) 2023  B3H1Z\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README-FA.md",
    "content": "\n\n<p align=\"center\">\n  <a href=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot\" target=\"_blank\" rel=\"noopener noreferrer\">\n    <picture>\n      <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/icon.png?raw=True\">\n      <img width=\"200\" height=\"200\" src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/icon.png?raw=True\">\n    </picture>\n  </a>\n</p>\n<p align=\"center\">\n\t<a href=\"./README.md\">\n\tEnglish\n\t</a>\n\t|\n\t<a href=\"./README-FA.md\">\n\tفارسی\n\t</a>\n<br>\n  <a href=\"https://t.me/HidyBotGroup\">گروه تلگرام</a>\n\n</p>\n\n<h1 align=\"center\"/>هیدی بات</h1>\n\nبا استفاده از این ربات می‌توانید پنل هیدیفای خود را از طریق تلگرام مدیریت کنید.\n\nبعضی از ویژگی‌ها عبارتند از:\n-  مدیریت چند پنل\n-  فروش کانفیگ\n-  افزودن کاربران\n-  حذف کاربران\n-  ویرایش کاربران\n-  نمایش لیست کاربران\n-  جستجوی کاربران (بر اساس نام، تنظیمات، UUID)\n-  نمایش اطلاعات کاربران (نام، ترافیک، تاریخ و غیره)\n-  نمایش پیکربندی‌ها و لینک‌های اشتراک کاربر\n-  دریافت پشتیبان از پنل شما\n-  نمایش وضعیت سرور (رم، پردازنده، دیسک)\n- چند زبانه (انگلیسی، فارسی)\n- ربات کاربران\n\n## نصب \nبرای نصب ربات دستور زیر را اجرا کنید:\n \n```bash\nsudo bash -c \"$(curl -Lfo- https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/install.sh)\"\n```\n<br>\n\nمطمئن شوید که اطلاعات زیر را آماده دارید:\n1. `شناسه تلگرام ادمین` : آن را از ربات[ User Info Bot](https://t.me/userinfobot) بگیرید (مثال: `123456789`)\n2. `توکن ربات ادمین` : آن را از ربات [BotFather](https://t.me/BotFather) بگیرید (\n   مثال: `1234567890:ABCdEfGhIjKlMnOpQrStUvWxYz`)\n3. `توکن ربات کاربران` : آن را از ربات [BotFather](https://t.me/BotFather) بگیرید (\n   مثال: `1234567890:ABCdEfGhIjKlMnOpQrStUvWxYz`)\n4. `آدرس پنل هیدیفای` : آدرس پنل هیدیفای خود را وارد کنید (\n   مثال: `https://panel.example.com/7frgemkvtE0/78854985-68dp-425c-989b-7ap0c6kr9bd4`)\n5. `زبان ربات` : گزینه‌ها `en` و `fa` می‌باشند [پیش‌فرض `fa`]\n\nحالا می‌توانید با ارسال دستور `/start` از ربات در تلگرام استفاده کنید.\n\n\n## دستورات\n به‌روزرسانی ربات\n```bash\ncd /opt/Hiddify-Telegram-Bot/ && curl -fsSL -o /opt/Hiddify-Telegram-Bot/update.sh https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/update.sh && chmod +x /opt/Hiddify-Telegram-Bot/update.sh && bash /opt/Hiddify-Telegram-Bot/update.sh\n```\n راه‌اندازی مجدد ربات\n```bash\ncd /opt/Hiddify-Telegram-Bot/ && chmod +x restart.sh && ./restart.sh\n```\n متوقف کردن ربات\n\n```bash\npkill -9 -f hiddifyTelegramBot.py\n```\n مشاهده لاگ های ربات\n```bash\ncat /opt/Hiddify-Telegram-Bot/Logs/hidyBot.log\n```\n مشاهده و تغییر پیکربندی ربات\n```bash\ncd /opt/Hiddify-Telegram-Bot/ && python3 config.py && chmod +x restart.sh && ./restart.sh\n```\n نصب مجدد ربات\n```bash\ncd /opt/ && rm -rf /opt/Hiddify-Telegram-Bot/ && sudo bash -c \"$(curl -Lfo- https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/install.sh)\"\n```\n  حذف ربات\n```bash\ncd /opt/Hiddify-Telegram-Bot/ && chmod +x uninstall.sh && ./uninstall.sh\n```\n\n## اسکرین شات‌ها\n#### ربات کاربران \n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-1.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-2.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-3.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-4.jpg?raw=True\" width=35% height=35%>\n#### ربات ادمین\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-1.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-2.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-6.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-8.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-5.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-3.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-4.jpg?raw=True\" width=35% height=35%>\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-7.jpg?raw=True\" width=35% height=35%>"
  },
  {
    "path": "README.md",
    "content": "﻿<p align=\"center\">\r\n  <a href=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot\" target=\"_blank\" rel=\"noopener noreferrer\">\r\n    <img width=\"200\" height=\"200\" src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/icon.png?raw=True\" alt=\"Hidy Bot\">\r\n  </a>\r\n</p>\r\n\r\n<p align=\"center\">\r\n  <a href=\"./README.md\">English</a> |\r\n  <a href=\"./README-FA.md\">فارسی</a>\r\n<br>\r\n  <a href=\"https://t.me/HidyBotGroup\">Telegram Group</a>\r\n  <br>\r\n  <a href=\"https://b3h1z.github.io/HidyBot-Docs/docs/en/home.html\">Commercial-Edition Documentation</a>\r\n\r\n</p>\r\n<h1 align=\"center\">Hidy Bot</h1>\r\n\r\nHidy Bot is a Telegram bot that allows you to manage your Hiddify panel, build your store and manage users directly from Telegram.\r\n> [!WARNING]\r\n> **Archived Version Notice**\r\n> This repository is no longer active and is limited to **Hiddify version 8**. To access the latest updates and premium features, please upgrade to our **Commercial version**.\r\n## Features\r\n- [x] Multi panel support\r\n- [x] Sell config\r\n- [x] Add users\r\n- [x] Remove users\r\n- [x] Edit user details\r\n- [x] View users list\r\n- [x] Search users (by name, configuration, UUID)\r\n- [x] Show user information (name, traffic, date, etc.)\r\n- [x] Display user configs and subscription links\r\n- [x] Get a backup of your panel + Auto send\r\n- [x] View server status (RAM, CPU, disk)\r\n- [x] Multi language (English, Persian)\r\n- [x] Client bot\r\n- [x] and more...\r\n\r\n## Installation\r\n\r\nTo install the bot, run the following command:\r\n\r\n```bash\r\nsudo bash -c \"$(curl -Lfo- https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/install.sh)\"\r\n```\r\n<br>\r\n\r\nMake sure you have the following information ready:\r\n\r\n1. `Admin Telegram Number ID` : Get it from [User info bot](https://t.me/userinfobot) (Example: `123456789`)\r\n2. `Admin Telgram Bot Token` : Get it from [BotFather](https://t.me/BotFather) (\r\n   Example: `1234567890:ABCdEfGhIjKlMnOpQrStUvWxYz`)\r\n3. `Client Telegram Bot Token` : Get it from [BotFather](https://t.me/BotFather) (\r\n   Example: `1234567890:ABCdEfGhIjKlMnOpQrStUvWxYz`)\r\n4. `Hiddify Panel URL` : The url of your Hiddify panel (\r\n   Example: `https://panel.example.com/7frgemkvtE0/78854985-68dp-425c-989b-7ap0c6kr9bd4`)\r\n5. `Bot Language` : Options are `en` and `fa` [default is `fa`]\r\n\r\n\r\nNow you can use the bot in Telegram by sending the `/start` command.\r\n\r\n\r\n\r\n\r\n## Commands\r\n- ### Update bot\r\n```bash\r\ncd /opt/Hiddify-Telegram-Bot/ && curl -fsSL -o /opt/Hiddify-Telegram-Bot/update.sh https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/update.sh && chmod +x /opt/Hiddify-Telegram-Bot/update.sh && bash /opt/Hiddify-Telegram-Bot/update.sh\r\n```\r\n- ### Restart bot\r\n```bash\r\ncd /opt/Hiddify-Telegram-Bot/ && chmod +x restart.sh && ./restart.sh\r\n```\r\n- ### Stop bot\r\n```bash\r\npkill -9 -f hiddifyTelegramBot.py\r\n```\r\n- ### Get bot logs\r\n```bash\r\ncat /opt/Hiddify-Telegram-Bot/Logs/hidyBot.log\r\n```\r\n- ### Edit bot configs\r\n```bash\r\ncd /opt/Hiddify-Telegram-Bot/ && python3 config.py && chmod +x restart.sh && ./restart.sh\r\n```\r\n- ### Reinstall bot\r\n```bash\r\ncd /opt/ && rm -rf /opt/Hiddify-Telegram-Bot/ && sudo bash -c \"$(curl -Lfo- https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/install.sh)\"\r\n```\r\n- ### Uninstall bot\r\n```bash\r\ncd /opt/Hiddify-Telegram-Bot/ && chmod +x uninstall.sh && ./uninstall.sh\r\n```\r\n\r\n## Screenshots\r\n#### Users Bot\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-1.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-2.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-3.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-u-4.jpg?raw=True\" width=35% height=35%>\r\n#### Admin Bot\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-1.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-2.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-6.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-8.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-5.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-3.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-4.jpg?raw=True\" width=35% height=35%>\r\n- <img src=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot/blob/main/Screenshots/scr-a-7.jpg?raw=True\" width=35% height=35%>\r\n"
  },
  {
    "path": "Shared/common.py",
    "content": "# Common file for avoiding circular import.\n\ndef admin_bot():\n    from AdminBot.bot import bot as admin_bot\n    return admin_bot\n\n\ndef user_bot():\n    from UserBot.bot import bot as user_bot\n    return user_bot\n"
  },
  {
    "path": "UserBot/Json/buttons.json",
    "content": "{\n  \"EN\": {\n    \"BACK\": \"🔙Back\",\n    \"SUBSCRIPTION_STATUS\": \"📊Subscription Status\",\n    \"YES\": \"✅Yes\",\n    \"NO\": \"❌No\",\n    \"CONFIGS_DIR\": \"Configs\",\n    \"CONFIGS_SUB_AUTO\": \"Auto Subscription\",\n    \"CONFIGS_SUB\": \"Subscription Link\",\n    \"CONFIGS_SUB_B64\": \"Subscription Link b64\",\n    \"CONFIGS_CLASH\": \"Clash Subscription\",\n    \"CONFIGS_HIDDIFY\": \"Hiddify Subscription\",\n    \"CONFIGS_SING_BOX\": \"Sing-box\",\n    \"CONFIGS_FULL_SING_BOX\": \"Full Sing-box\",\n    \"UNLINK_SUBSCRIPTION\": \"⭕️Unlink Subscription\",\n    \"BUY_SUBSCRIPTION\": \"💳Buy Subscription\",\n    \"BUY_PLAN\": \"💳Card\",\n    \"BUY_FROM_WALLET\": \"💰From wallet\",\n    \"SEND_SCREENSHOT\": \"✅I paid, send receipt\",\n    \"CANCEL\": \"❌Cancel\",\n    \"CONFIRM_PAYMENT\": \"✅Confirm Payment\",\n    \"LINK_SUBSCRIPTION\": \"🔗Link Subscription\",\n    \"MANUAL\": \"📚Manual\",\n    \"MANUAL_ANDROID\": \"Android Manual\",\n    \"MANUAL_IOS\": \"IOS Manual\",\n    \"MANUAL_WIN\": \"Windows Manual\",\n    \"MANUAL_MAC\": \"Mac Manual\",\n    \"MANUAL_LIN\": \"Linux Manual\",\n    \"SEND_TICKET\": \"📩Supporter\",\n    \"SEND_TICKET_TO_SUPPORT\": \"📩Send Message To Support\",\n    \"ANSWER\": \"Answer\",\n    \"TO_QR\": \"ً🖼QR\",\n    \"CONFIGS_LIST\": \"📝Configs\",\n    \"WALLET\": \"💰Wallet\",\n    \"INCREASE_WALLET_BALANCE\": \"💵Increase wallet balance\",\n    \"FREE_TEST\": \"🔥Free Test\",\n    \"RENEWAL_SUBSCRIPTION\": \"🔄Renewal Subscription\",\n    \"UPDATE_SUBSCRIPTION_INFO\": \"🔄Update Subscription Info\",\n    \"JOIN_CHANNEL\": \"📢Join Channel\",\n    \"FORCE_JOIN_CHANNEL_ACCEPTED\": \"✅I joined\",\n    \"SEND_MESSAGE\": \"Send Message\",\n    \"FAQ\": \"⁉FAQ\"\n  },\n  \"FA\": {\n    \"BACK\": \"🔙بازگشت\",\n    \"SUBSCRIPTION_STATUS\": \"📊وضعیت اشتراک\",\n    \"YES\": \"✅بله\",\n    \"NO\": \"❌خیر\",\n    \"CONFIGS_DIR\": \"کانفیگ مستقیم\",\n    \"CONFIGS_SUB_AUTO\": \"اشتراک خودکار\",\n    \"CONFIGS_SUB\": \"لینک اشتراک\",\n    \"CONFIGS_SUB_B64\": \"لینک اشتراک b64\",\n    \"CONFIGS_CLASH\": \"اشتراک Clash\",\n    \"CONFIGS_HIDDIFY\": \"اشتراک Hiddify\",\n    \"CONFIGS_SING_BOX\": \"Sing-box\",\n    \"CONFIGS_FULL_SING_BOX\": \"Full Sing-box\",\n    \"UNLINK_SUBSCRIPTION\": \"⭕جداسازی اشتراک\",\n    \"BUY_SUBSCRIPTION\": \"💳خرید اشتراک\",\n    \"BUY_PLAN\": \"💳کارت به کارت\",\n    \"BUY_FROM_WALLET\": \"💰پرداخت از کیف پول\",\n    \"SEND_SCREENSHOT\": \"✅پرداخت کردم، ارسال رسید\",\n    \"CANCEL\": \"❌لغو\",\n    \"CONFIRM_PAYMENT\": \"✅تایید پرداخت\",\n    \"LINK_SUBSCRIPTION\": \"🔗اتصال اشتراک\",\n    \"MANUAL\": \"📚راهنما\",\n    \"MANUAL_ANDROID\": \"راهنمای اندروید\",\n    \"MANUAL_IOS\": \"راهنمای IOS\",\n    \"MANUAL_WIN\": \"راهنمای ویندوز\",\n    \"MANUAL_MAC\": \"راهنمای مک\",\n    \"MANUAL_LIN\": \"راهنمای لینوکس\",\n    \"SEND_TICKET\": \"📩پشتیبانی\",\n    \"SEND_TICKET_TO_SUPPORT\": \"📤 ارسال پیام به پشتیبانی\",\n    \"ANSWER\": \"📤پاسخ\",\n    \"TO_QR\": \"ً🖼کیوآر\",\n    \"CONFIGS_LIST\": \"📝 کانفیگ ها\",\n    \"WALLET\": \"💰کیف پول\",\n    \"INCREASE_WALLET_BALANCE\": \"💵افزایش موجودی\",\n    \"FREE_TEST\": \"🔥تست رایگان\",\n    \"RENEWAL_SUBSCRIPTION\": \"♾ تمدید اشتراک\",\n    \"UPDATE_SUBSCRIPTION_INFO\": \"🔄 بروزرسانی اطلاعات\",\n    \"JOIN_CHANNEL\": \"📢عضویت در کانال\",\n    \"FORCE_JOIN_CHANNEL_ACCEPTED\": \"✅عضو شدم\",\n    \"SEND_MESSAGE\": \"📤ارسال پیام\",\n    \"FAQ\": \"⁉سوالات متداول\"\n  }\n}"
  },
  {
    "path": "UserBot/Json/commands.json",
    "content": "{\n    \"EN\": {\n        \"START\": \"start\"\n    },\n    \"FA\": {\n        \"START\": \"شروع\"\n    }\n}"
  },
  {
    "path": "UserBot/Json/messages.json",
    "content": "{\n    \"EN\": {\n        \"WELCOME\": \"Welcome to users bot\",\n        \"INFO_USER\": \"📄Your Subscription Info\",\n        \"SUBSCRIPTION_STATUS\": \"☑️Status:\",\n        \"ACTIVE_SUBSCRIPTION_STATUS\": \"🟢 Active\",\n        \"DEACTIVE_SUBSCRIPTION_STATUS\": \"🔴 Deactive\",\n        \"SERVER\": \"📡Server:\",\n        \"INFO_USAGE\": \"📊Usage:\",\n        \"INFO_REMAINING_DAYS\": \"⏳Remaining Days:\",\n        \"INFO_ID\": \"🔑UUID:\",\n        \"OF\": \"of\",\n        \"GB\": \"GB\",\n        \"DAY_EXPIRE\": \"Days\",\n        \"CONFIRM_SUBSCRIPTION_QUESTION\": \"Is this your subscription?\",\n        \"NAME\": \"Name:\",\n        \"CANCEL_SUBSCRIPTION\": \"Subscription not confirmed\",\n        \"SUBSCRIPTION_CONFIRMED\": \"Your subscription has been confirmed. Now you can get your subscription status.\",\n        \"WAIT\": \"Please wait...\",\n        \"UNKNOWN_ERROR\": \"Unknown error!\",\n        \"ENTER_SUBSCRIPTION_INFO\": \"Please enter your subscription info\\n One of the configs, uuid or subscription link\",\n        \"SUBSCRIPTION_INFO_NOT_FOUND\": \"Subscription info not found!\",\n        \"SUBSCRIPTION_UNLINKED\": \"Subscription unlinked!\",\n        \"USER_NOT_FOUND\": \"User not found!\",\n        \"USER_NAME\": \"👤Name:\",\n        \"PLANS_LIST\": \"📋Plans List:\",\n        \"SERVERS_LIST\": \"🖥Server List:\",\n        \"PLANS_NOT_FOUND\": \"Plans not found!\",\n        \"SERVERS_NOT_FOUND\": \"Servers not found!\",\n        \"PLAN_ADD_NAME\": \"Please enter your name:\",\n        \"SUBSCRIPTION_SUCCESS_ADDED\": \"Your subscription has been successfully added.\",\n        \"PLAN_INFO\": \"📄Plan Info:\",\n        \"PLAN_INFO_SIZE\": \"Size:\",\n        \"PLAN_INFO_DAYS\": \"Days:\",\n        \"PLAN_INFO_PRICE\": \"Price:\",\n        \"PLAN_INFO_DESC\": \"Description:\",\n        \"TOMAN\": \"T\",\n        \"RIAL\": \"R\",\n        \"REQUEST_SEND_SCREENSHOT\": \"Please send your payment receipt.\",\n        \"ERROR_TYPE_SEND_SCREENSHOT\": \"Please send your payment receipt as a photo!\",\n        \"REQUEST_SEND_NAME\": \"Please send your name.\",\n        \"NO_SUBSCRIPTION\": \"You have no subscription!\",\n        \"WAIT_FOR_ADMIN_CONFIRMATION\": \"✅Your subscription is waiting for confirmation by the admin.\\nPlease wait...\",\n        \"NEW_PAYMENT_RECEIVED\": \"New payment received\",\n        \"PAYMENT_ASK_TO_CONFIRM\": \"Do you want to confirm this payment?\",\n        \"REQUEST_SEND_TO_QR\": \"Please send your config or subscription link:\",\n        \"REQUEST_SEND_TO_QR_ERROR\": \"Please send your config or subscription!\",\n        \"USER_CONFIGS_LIST\": \"📋Your Configs:\",\n        \"USER_CONFIGS_NOT_FOUND\": \"Configs not found!\",\n        \"ERROR_CONFIG_NOT_FOUND\": \"Config not found!\",\n        \"ERROR_INVALID_COMMAND\": \"Invalid command!\",\n        \"ALREADY_SUBSCRIBED\": \"You are already subscribed!\",\n        \"ERROR_INVALID_NUMBER\": \"Invalid number!\",\n        \"CANCELED\": \"Cancelled!\",\n        \"SUBSCRIPTION_NOT_FOUND\": \"Subscription not found!\",\n        \"ZERO_BALANCE\": \"🔻Your wallet balance is zero\",\n        \"WALLET_INFO_PART_1\": \"🔻Your wallet balance is\",\n        \"WALLET_INFO_PART_2\": \"\",\n        \"INCREASE_WALLET_BALANCE_AMOUNT\": \"🔻Please enter the amount that you want to charge your wallet in Tomans\",\n        \"MINIMUM_DEPOSIT_AMOUNT\": \"🔻Please enter an amount more than\",\n        \"LACK_OF_WALLET_BALANCE\": \"❌Your wallet balance is not enough\\nplease top up your wallet\",\n        \"ORDER_ID\": \"Payment number:\",\n        \"PAYMENT_CONFIRMED\": \"✅Payment confirmed\",\n        \"ALREADY_RECEIVED_FREE\": \"You have already received your free test account!\",\n        \"GET_FREE_CONFIRMED\": \"✅Your free account has been successfully registered\",\n        \"SUCCESSFUL_RENEWAL\": \"✅Your subscription has been successfully renewed\",\n        \"REQUEST_START\": \"Please update the bot with /start command\",\n        \"CANCEL_INCREASE_WALLET_BALANCE\": \"❌Increase balance not confirmed\",\n        \"REQUEST_JOIN_CHANNEL\": \"Please join our channel to use the bot\",\n        \"ADMIN_NOTIFY_NEW_SUB\" : \"A new subscription was registered with the name of:\",\n        \"ADMIN_NOTIFY_CONFIRM\" : \"\",\n        \"ADMIN_NOTIFY_NEW_FREE_TEST\" : \"A new free tesst subscription was registered with the name of:\",\n        \"ADMIN_NOTIFY_NEW_RENEWAL\" : \"\",\n        \"ADMIN_NOTIFY_NEW_RENEWAL_2\" : \"subscription was extended\",\n        \"FREE_TEST_NOT_AVAILABLE\" : \"Free test is not available at the moment\",\n        \"REQUEST_SELECT_OS_MANUAL\": \"📥Please select your operating system:\",\n        \"MANUAL_ANDROID\": \"\\uD83D\\uDCE5Android:\\n<a href='https://play.google.com/store/apps/details?id=com.v2ray.ang'>V2RayNG</a>\\n<a href='https://play.google.com/store/apps/details?id=ang.hiddify.com'>HiddifyNG</a>\",\n        \"MANUAL_IOS\": \"\\uD83D\\uDCE5iOS:\\n<a href='https://apps.apple.com/us/app/streisand/id6450534064'>Streisand</a>\\n<a href='https://apps.apple.com/us/app/foxray/id6448898396'>Foxray</a>\\n<a href='https://apps.apple.com/us/app/v2box-v2ray-client/id6446814690'>V2box</a>\",\n        \"MANUAL_WIN\": \"\\uD83D\\uDCE5Windows:\\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\\n<a href='https://github.com/2dust/v2rayN/releases'>V2rayN</a>\\n<a href='https://github.com/hiddify/HiddifyN/releases'>HiddifyN</a>\",\n        \"MANUAL_LIN\": \"📥Linux:<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\",\n        \"MANUAL_MAC\": \"📥Mac:<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\",\n        \"MANUAL_HDR\": \"⭕Connection Guide\",\n        \"WELCOME_TO_ADMIN\": \"Users bot has been successfully launched.\\nPlease send /start command to start working.\",\n        \"BUY_SUBSCRIPTION_CLOSED\": \"Buy subscription is not available at the moment.\",\n        \"RENEWAL_SUBSCRIPTION_CLOSED\": \"Renewal subscription is not available at the moment.\",\n        \"INFO_USER_NAME\": \"⬖ User:\",\n        \"INFO_USER_USERNAME\": \"⬖ Username:\",\n        \"INFO_USER_NUM_ID\": \"⬖ User ID:\",\n        \"ANSWER_TO_ADMIN\": \"Please submit your answer:\",\n        \"MESSAGE_SENDED\": \"Message Sended\",\n        \"NOT_SET\":\"Not set\",\n        \"JOIN_CHANNEL_SUCCESSFUL\":\"Join channel successful\",\n        \"SEND_TICKET_TO_ADMIN\": \"Please submit your question:\",\n        \"SEND_TICKET_TO_ADMIN_RESPONSE\": \"✅Your message has been sent to support\\n⏳We will respond as soon as possible.\",\n        \"SEND_TICKET_TO_ADMIN_TEMPLATE\":\"Do you have any questions?\\nContact us.\",\n        \"NEW_TICKET_RECEIVED\": \"📩New ticket received\",\n        \"TICKET_TEXT\": \"📄Ticket text:\",\n        \"SERVER_IS_FULL\": \"⛔️The capacity of the selected server is full\\nPlease select another server\\nWe will try to increase the capacity of the servers as soon as possible\",\n        \"BANNED_USER\": \"⛔️You are banned from using the bot\"\n    },\n    \"FA\": {\n        \"WELCOME\": \"به ربات کاربران خوش آمدید\",\n        \"INFO_USER\": \"📄اطلاعات اشتراک شما\",\n        \"SUBSCRIPTION_STATUS\": \"❔وضعیت:\",\n        \"ACTIVE_SUBSCRIPTION_STATUS\": \"🟢 فعال\",\n        \"DEACTIVE_SUBSCRIPTION_STATUS\": \"🔴 غیر فعال\",\n        \"SERVER\": \"📡سرور:\",\n        \"INFO_USAGE\": \"📊میزان استفاده:\",\n        \"INFO_REMAINING_DAYS\": \"⏳زمان باقی مانده:\",\n        \"INFO_ID\": \"🔑شناسه:\",\n        \"OF\": \"از\",\n        \"GB\": \"گیگ\",\n        \"DAY_EXPIRE\": \"روز\",\n        \"CONFIRM_SUBSCRIPTION_QUESTION\": \"آیا این اشتراک شماست؟\",\n        \"NAME\": \"نام:\",\n        \"CANCEL_SUBSCRIPTION\": \"❌اشتراک تایید نشد\",\n        \"SUBSCRIPTION_CONFIRMED\": \"✅اشتراک شما تایید شد. حالا میتوانید وضعیت اشتراک خود را دریافت کنید.\",\n        \"WAIT\": \"لطفا صبر کنید...\",\n        \"UNKNOWN_ERROR\": \"❌خطای ناشناخته!\",\n        \"ENTER_SUBSCRIPTION_INFO\": \"لطفا اطلاعات اشتراک خود را وارد کنید.\\nیکی از کانفیگ ها، uuid یا لینک اشتراک⬇️\",\n        \"SUBSCRIPTION_INFO_NOT_FOUND\": \"❌اطلاعات اشتراک یافت نشد!\",\n        \"USER_NOT_FOUND\": \"❌کاربر یافت نشد.\",\n        \"SUBSCRIPTION_UNLINKED\": \"✅اشتراک از ربات جداسازی شد\",\n        \"USER_NAME\": \"👤نام:\",\n        \"PLANS_LIST\": \"📋پلن های موجود\",\n        \"SERVERS_LIST\": \"📡لیست سرورها\",\n        \"PLANS_NOT_FOUND\": \"❌پلنی یافت نشد!\",\n        \"SERVERS_NOT_FOUND\": \"❌سروری یافت نشد!\",\n        \"PLAN_ADD_NAME\": \"لطفا نام خود را وارد کنید:\",\n        \"SUBSCRIPTION_SUCCESS_ADDED\": \"✅اشتراک شما با موفقیت اضافه شد.\",\n        \"PLAN_INFO\": \"📋اطلاعات پلن انتخاب شده\",\n        \"PLAN_INFO_SIZE\": \"📊حجم:\",\n        \"PLAN_INFO_PRICE\": \"💰قیمت:\",\n        \"PLAN_INFO_DAYS\": \"📆زمان:\",\n        \"PLAN_INFO_DESC\": \"✏️توضیحات:\",\n        \"TOMAN\": \"تومان\",\n        \"RIAL\": \"ریال\",\n        \"REQUEST_SEND_SCREENSHOT\": \"⬇️لطفا رسید پرداخت خود را در زیر این پیام ارسال کنید:\",\n        \"ERROR_TYPE_SEND_SCREENSHOT\": \"⬇️لطفا رسید پرداخت خود را به صورت عکس ارسال کنید:\",\n        \"REQUEST_SEND_NAME\": \"⬇️لطفا نام خود را ارسال کنید:\",\n        \"NO_SUBSCRIPTION\": \"❌شما هیچ اشتراکی ندارید!\",\n        \"WAIT_FOR_ADMIN_CONFIRMATION\": \"✅تراکنش شما در انتظار تایید توسط ادمین است.\\nلطفا صبر کنید.\",\n        \"NEW_PAYMENT_RECEIVED\": \"تراکنش جدیدی ثبت شد\",\n        \"PAYMENT_ASK_TO_CONFIRM\": \"آیا شما این تراکنش را تایید میکنید؟\",\n        \"REQUEST_SEND_TO_QR\": \"لطفا کانفیگ یا لینک اشتراک خود را ارسال کنید:\",\n        \"REQUEST_SEND_TO_QR_ERROR\": \"متن ارسالی معتبر نیست\\nلطفا کانفیگ یا لینک اشتراک خود را به صورت متنی ارسال کنید!\",\n        \"USER_CONFIGS_LIST\": \"📋لیست کانفیگ های شما\",\n        \"USER_CONFIGS_NOT_FOUND\": \"❌کانفیگی یافت نشد!\",\n        \"ERROR_CONFIG_NOT_FOUND\": \"❌کانفیگ یافت نشد!\",\n        \"ERROR_INVALID_COMMAND\": \"❌دستور نامعتبر!\",\n        \"ALREADY_SUBSCRIBED\": \"❌اشتراک شما قبلا اضافه شده است.\",\n        \"ERROR_INVALID_NUMBER\": \"❌لطفا مقداری عددی وارد کنید!\",\n        \"CANCELED\": \"❌لغو شد\",\n        \"SUBSCRIPTION_NOT_FOUND\": \"❌شما اشتراک فعالی ندارید!\",\n        \"ZERO_BALANCE\": \"🔻موجودی کیف پول شما صفر می‌باشد\",\n        \"WALLET_INFO_PART_1\": \"🔻موجودی کیف پول شما\",\n        \"WALLET_INFO_PART_2\": \"تومان می‌باشد\",\n        \"INCREASE_WALLET_BALANCE_AMOUNT\": \"🔻لطفا مبلغی که قصد شارژ حساب خود دارید را به تومان وارد کنید\",\n        \"MINIMUM_DEPOSIT_AMOUNT\": \"❗حداقل مبلغ شارژ حساب\",\n        \"LACK_OF_WALLET_BALANCE\": \"❌موجودی کیف پول شما کافی نیست\\n⬇️لطفا از طریق دکمه زیر کیف پول خود را شارژ کنید و سپس پرداخت را انجام دهید\",\n        \"ORDER_ID\": \"شناسه تراکنش\",\n        \"PAYMENT_CONFIRMED\": \"تراکنش شما تایید شد\\n از طریق دکمه [📊وضعیت اشتراک] میتوانید به اطلاعات اشتراک خود دسترسی داشته باشید.\",\n        \"ALREADY_RECEIVED_FREE\": \"شما قبلا اکانت تست رایگان خود را دریافت نموده‌اید!\",\n        \"GET_FREE_CONFIRMED\": \"✅اکانت تست رایگان شما با موفقیت ثبت شد\\n از طریق دکمه [📊وضعیت اشتراک] میتوانید به اطلاعات اشتراک خود دسترسی داشته باشید.\",\n        \"SUCCESSFUL_RENEWAL\": \"✅تمدید اشتراک شما با موفقیت انجام شد\",\n        \"REQUEST_START\": \"لطفا ربات را با دستور /start شروع کنید\",\n        \"CANCEL_INCREASE_WALLET_BALANCE\": \"❌افزایش موجودی لغو شد\",\n        \"REQUEST_JOIN_CHANNEL\": \"لطفا برای استفاده از ربات ابتدا در کانال ما عضو شوید\",\n        \"ADMIN_NOTIFY_NEW_SUB\" : \"👤اشتراک جدیدی با نام\",\n        \"ADMIN_NOTIFY_CONFIRM\" : \"ثبت شد\",\n        \"ADMIN_NOTIFY_NEW_FREE_TEST\" : \"اشتراک تست رایگان جدیدی با نام\",\n        \"ADMIN_NOTIFY_NEW_RENEWAL_2\" : \"تمدید شد\",\n        \"ADMIN_NOTIFY_NEW_RENEWAL\" : \"اشتراک\",\n        \"FREE_TEST_NOT_AVAILABLE\" : \"اکانت تست رایگان در حال حاضر در دسترس نمی‌باشد\",\n        \"REQUEST_SELECT_OS_MANUAL\": \"📥لطفا سیستم عامل خود را انتخاب کنید:\",\n        \"MANUAL_ANDROID\": \"\\uD83D\\uDCE5Android:\\n<a href='https://play.google.com/store/apps/details?id=com.v2ray.ang'>V2RayNG</a>\\n<a href='https://play.google.com/store/apps/details?id=ang.hiddify.com'>HiddifyNG</a>\",\n        \"MANUAL_IOS\": \"\\uD83D\\uDCE5iOS:\\n<a href='https://apps.apple.com/us/app/streisand/id6450534064'>Streisand</a>\\n<a href='https://apps.apple.com/us/app/foxray/id6448898396'>Foxray</a>\\n<a href='https://apps.apple.com/us/app/v2box-v2ray-client/id6446814690'>V2box</a>\",\n        \"MANUAL_WIN\": \"\\uD83D\\uDCE5Windows:\\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\\n<a href='https://github.com/2dust/v2rayN/releases'>V2rayN</a>\\n<a href='https://github.com/hiddify/HiddifyN/releases'>HiddifyN</a>\",\n        \"MANUAL_LIN\": \"📥Linux:\\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\",\n        \"MANUAL_MAC\": \"📥Mac:\\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\",\n        \"MANUAL_HDR\": \"لطفا سیستم عامل خود را انتخاب کنید\",\n        \"WELCOME_TO_ADMIN\": \"ربات کاربران هیدی بات با موفقیت راه‌اندازی شد.\\nبرای شروع کار، دستور /start را ارسال کنید.\",\n        \"BUY_SUBSCRIPTION_CLOSED\": \"در حال حاضر امکان خرید اشتراک وجود ندارد.\",\n        \"RENEWAL_SUBSCRIPTION_CLOSED\": \"در حال حاضر امکان تمدید اشتراک وجود ندارد.\",\n        \"INFO_USER_NAME\": \"⬖ کاربر:\",\n        \"INFO_USER_USERNAME\": \"⬖ نام کاربری:\",\n        \"INFO_USER_NUM_ID\": \"⬖ شناسه کاربر:\",\n        \"ANSWER_TO_ADMIN\": \"لطفا پاسخ خود را ارسال کنید:\",\n        \"MESSAGE_SENDED\": \"پیام ارسال شد\",\n        \"NOT_SET\": \"تنظیم نشده\",\n        \"JOIN_CHANNEL_SUCCESSFUL\": \"✅عضویت شما در کانال با موفقیت انجام شد\",\n        \"SEND_TICKET_TO_ADMIN\": \"📞لطفا سوال یا موضوع مورد بحث را در قالب یک پیام کامل و جامع ارسال کنید:\",\n        \"SEND_TICKET_TO_ADMIN_RESPONSE\": \"✅ پیام شما با موفقیت برای پشتیبانی ارسال شد\\n⏳ما در سریع ترین زمان ممکن پاسخگو خواهیم بود.\",\n        \"SEND_TICKET_TO_ADMIN_TEMPLATE\":\"نیاز به پشتیبانی دارید؟\\nبا ما در ارتباط باشید.\",\n        \"NEW_TICKET_RECEIVED\": \"📩تیکت جدیدی دریافت شد\",\n        \"TICKET_TEXT\": \"📄متن تیکت:\",\n        \"SERVER_IS_FULL\": \"⛔️ظرفیت سرور انتخاب شده تکمیل شده\\nلطفا سرور دیگری انتخاب کنید\\nسعی ما بر این است که در اسرع وقت ظرفیت سرورها را افزایش دهیم\",\n        \"BANNED_USER\": \"⛔️شما از استفاده از ربات محروم شده‌اید\"\n    }\n}"
  },
  {
    "path": "UserBot/bot.py",
    "content": "import datetime\nimport random\n\nimport telebot\nfrom telebot.types import Message, CallbackQuery\nfrom config import *\nfrom AdminBot.templates import configs_template\nfrom UserBot.markups import *\nfrom UserBot.templates import *\nfrom UserBot.content import *\n\nimport Utils.utils as utils\nfrom Shared.common import admin_bot\nfrom Database.dbManager import USERS_DB\nfrom Utils import api\n\n# *********************************** Configuration Bot ***********************************\nbot = telebot.TeleBot(CLIENT_TOKEN, parse_mode=\"HTML\")\nbot.remove_webhook()\nadmin_bot = admin_bot()\nBASE_URL = f\"{urlparse(PANEL_URL).scheme}://{urlparse(PANEL_URL).netloc}\"\nselected_server_id = 0\n\n# *********************************** Helper Functions ***********************************\n# Check if message is digit\ndef is_it_digit(message: Message,allow_float=False, response=MESSAGES['ERROR_INVALID_NUMBER'], markup=main_menu_keyboard_markup()):\n    if not message.text:\n        bot.send_message(message.chat.id, response, reply_markup=markup)\n        return False\n    try:\n        value = float(message.text) if allow_float else int(message.text)\n        return True\n    except ValueError:\n        bot.send_message(message.chat.id, response, reply_markup=markup)\n        return False\n\n\n# Check if message is cancel\ndef is_it_cancel(message: Message, response=MESSAGES['CANCELED']):\n    if message.text == KEY_MARKUP['CANCEL']:\n        bot.send_message(message.chat.id, response, reply_markup=main_menu_keyboard_markup())\n        return True\n    return False\n\n\n# Check if message is command\ndef is_it_command(message: Message):\n    if message.text.startswith(\"/\"):\n        return True\n    return False\n\n\n# Check is it UUID, Config or Subscription Link\ndef type_of_subscription(text):\n    if text.startswith(\"vmess://\"):\n        config = text.replace(\"vmess://\", \"\")\n        config = utils.base64decoder(config)\n        if not config:\n            return False\n        uuid = config['id']\n    else:\n        uuid = utils.extract_uuid_from_config(text)\n    return uuid\n\n# check is user banned\ndef is_user_banned(user_id):\n    user = USERS_DB.find_user(telegram_id=user_id)\n    if user:\n        user = user[0]\n        if user['banned']:\n            bot.send_message(user_id, MESSAGES['BANNED_USER'], reply_markup=main_menu_keyboard_markup())\n            return True\n    return False\n# *********************************** Next-Step Handlers ***********************************\n# ----------------------------------- Buy Plan Area -----------------------------------\ncharge_wallet = {}\nrenew_subscription_dict = {}\n\n\ndef user_channel_status(user_id):\n    try:\n        settings = utils.all_configs_settings()\n        if settings['channel_id']:\n            user = bot.get_chat_member(settings['channel_id'], user_id)\n            return user.status in ['member', 'administrator', 'creator']\n        else:\n            return True\n    except telebot.apihelper.ApiException as e:\n        logging.error(\"ApiException: %s\" % e)\n        return False\n\n\ndef is_user_in_channel(user_id):\n    settings = all_configs_settings()\n    if settings['force_join_channel'] == 1:\n        if not settings['channel_id']:\n            return True\n        if not user_channel_status(user_id):\n            bot.send_message(user_id, MESSAGES['REQUEST_JOIN_CHANNEL'],\n                             reply_markup=force_join_channel_markup(settings['channel_id']))\n            return False\n    return True\n\n# Next Step Buy From Wallet - Confirm\ndef buy_from_wallet_confirm(message: Message, plan):\n    if not plan:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n    if not wallet:\n        # Wallet not created\n        bot.send_message(message.chat.id, MESSAGES['LACK_OF_WALLET_BALANCE'],\n                         reply_markup=wallet_info_markup())\n    if wallet:\n        wallet = wallet[0]\n        if plan['price'] > wallet['balance']:\n            bot.send_message(message.chat.id, MESSAGES['LACK_OF_WALLET_BALANCE'],\n                             reply_markup=wallet_info_specific_markup(plan['price'] - wallet['balance']))\n            return\n        else:\n            bot.delete_message(message.chat.id, message.message_id)\n            bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_NAME'], reply_markup=cancel_markup())\n            bot.register_next_step_handler(message, next_step_send_name_for_buy_from_wallet, plan)\n\n\ndef renewal_from_wallet_confirm(message: Message):\n    if not renew_subscription_dict:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    if not renew_subscription_dict[message.chat.id]:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    if not renew_subscription_dict[message.chat.id]['plan_id'] or not renew_subscription_dict[message.chat.id][\n        'uuid']:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    uuid = renew_subscription_dict[message.chat.id]['uuid']\n    plan_id = renew_subscription_dict[message.chat.id]['plan_id']\n\n    wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n    if not wallet:\n        status = USERS_DB.add_wallet(telegram_id=message.chat.id)\n        if not status:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n\n    wallet = wallet[0]\n    plan_info = USERS_DB.find_plan(id=plan_id)\n    if not plan_info:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    plan_info = plan_info[0]\n    if plan_info['price'] > wallet['balance']:\n        bot.send_message(message.chat.id, MESSAGES['LACK_OF_WALLET_BALANCE'],reply_markup=wallet_info_specific_markup(plan_info['price'] - wallet['balance']))\n        del renew_subscription_dict[message.chat.id]\n        return\n\n    server_id = plan_info['server_id']\n    server = USERS_DB.find_server(id=server_id)\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    server = server[0]\n    URL = server['url'] + API_PATH\n    user = api.find(URL, uuid=uuid)\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    user_info = utils.users_to_dict([user])\n    if not user_info:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    user_info_process = utils.dict_process(URL, user_info)\n    user_info = user_info[0]\n\n    if not user_info_process:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    user_info_process = user_info_process[0]\n    new_balance = int(wallet['balance']) - int(plan_info['price'])\n    edit_wallet = USERS_DB.edit_wallet(message.chat.id, balance=new_balance)\n    if not edit_wallet:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    last_reset_time = datetime.datetime.now().strftime(\"%Y-%m-%d\")    \n    sub = utils.find_order_subscription_by_uuid(uuid) \n    if not sub:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return   \n    settings = utils.all_configs_settings()\n    #Default renewal mode\n    if settings['renewal_method'] == 1:\n        if user_info_process['remaining_day'] <= 0 or user_info_process['usage']['remaining_usage_GB'] <= 0:\n            new_usage_limit = plan_info['size_gb']\n            new_package_days = plan_info['days']\n            current_usage_GB = 0\n            edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit, package_days=new_package_days,start_date=last_reset_time, current_usage_GB=current_usage_GB,comment=f\"HidyBot:{sub['id']}\")\n\n        else:\n            new_usage_limit = user_info['usage_limit_GB'] + plan_info['size_gb']\n            new_package_days = plan_info['days'] + (user_info['package_days'] - user_info_process['remaining_day'])\n            edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit, package_days=new_package_days,last_reset_time=last_reset_time,comment=f\"HidyBot:{sub['id']}\")\n\n\n    #advance renewal mode        \n    elif settings['renewal_method'] == 2:\n            new_usage_limit = plan_info['size_gb']\n            new_package_days = plan_info['days']\n            current_usage_GB = 0\n            edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit, start_date=last_reset_time, package_days=new_package_days, current_usage_GB=current_usage_GB,comment=f\"HidyBot:{sub['id']}\")\n\n    \n    #Fair renewal mode\n    elif settings['renewal_method'] == 3:\n        if user_info_process['remaining_day'] <= 0 or user_info_process['usage']['remaining_usage_GB'] <= 0:\n            new_usage_limit = plan_info['size_gb']\n            new_package_days = plan_info['days']\n            current_usage_GB = 0\n            edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit, package_days=new_package_days,start_date=last_reset_time, current_usage_GB=current_usage_GB,comment=f\"HidyBot:{sub['id']}\")\n        else:\n            print(user_info)\n            new_usage_limit = user_info['usage_limit_GB'] + plan_info['size_gb']\n            new_package_days = plan_info['days'] + user_info['package_days']\n            edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit,package_days=new_package_days,last_reset_time=last_reset_time,comment=f\"HidyBot:{sub['id']}\")\n\n            \n\n    if not edit_status:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    # Add New Order\n    order_id = random.randint(1000000, 9999999)\n    created_at = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n    status = USERS_DB.add_order(order_id, message.chat.id,user_info_process['name'], plan_id, created_at)\n    if not status:\n        bot.send_message(message.chat.id,\n                         f\"{MESSAGES['UNKNOWN_ERROR']}\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    # edit_status = ADMIN_DB.edit_user(uuid=uuid, usage_limit_GB=new_usage_limit, package_days=new_package_days)\n    # edit_status = api.update(URL, uuid=uuid, usage_limit_GB=new_usage_limit, package_days=new_package_days)\n    # if not edit_status:\n    #     bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n    #                      reply_markup=main_menu_keyboard_markup())\n    #     return\n\n    bot.send_message(message.chat.id, MESSAGES['SUCCESSFUL_RENEWAL'], reply_markup=main_menu_keyboard_markup())\n    update_info_subscription(message, uuid)\n    BASE_URL = urlparse(server['url']).scheme + \"://\" + urlparse(server['url']).netloc\n    link = f\"{BASE_URL}/{urlparse(server['url']).path.split('/')[1]}/{uuid}/\"\n    user_name = f\"<a href='{link}'> {user_info_process['name']} </a>\"\n    bot_users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if bot_users:\n        bot_user = bot_users[0]\n    for ADMIN in ADMINS_ID:\n        admin_bot.send_message(ADMIN,\n                               f\"\"\"{MESSAGES['ADMIN_NOTIFY_NEW_RENEWAL']} {user_name} {MESSAGES['ADMIN_NOTIFY_NEW_RENEWAL_2']}\n{MESSAGES['SERVER']}<a href='{server['url']}/admin'> {server['title']} </a>\n{MESSAGES['INFO_ID']} <code>{sub['id']}</code>\"\"\", reply_markup=notify_to_admin_markup(bot_user))\n\n\n# Next Step Buy Plan - Send Screenshot\n\ndef next_step_send_screenshot(message, charge_wallet):\n    if is_it_cancel(message):\n        return\n    if not charge_wallet:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    if message.content_type != 'photo':\n        bot.send_message(message.chat.id, MESSAGES['ERROR_TYPE_SEND_SCREENSHOT'], reply_markup=cancel_markup())\n        bot.register_next_step_handler(message, next_step_send_screenshot, charge_wallet)\n        return\n\n    file_info = bot.get_file(message.photo[-1].file_id)\n    downloaded_file = bot.download_file(file_info.file_path)\n    file_name = f\"{message.chat.id}-{charge_wallet['id']}.jpg\"\n    path_recp = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', file_name)\n    if not os.path.exists(os.path.join(os.getcwd(), 'UserBot', 'Receiptions')):\n        os.makedirs(os.path.join(os.getcwd(), 'UserBot', 'Receiptions'))\n    with open(path_recp, 'wb') as new_file:\n        new_file.write(downloaded_file)\n\n    created_at = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n    payment_method = \"Card\"\n\n    status = USERS_DB.add_payment(charge_wallet['id'], message.chat.id,\n                                  charge_wallet['amount'], payment_method, file_name, created_at)\n    if status:\n        payment = USERS_DB.find_payment(id=charge_wallet['id'])\n        if not payment:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        payment = payment[0]\n        user_data = USERS_DB.find_user(telegram_id=message.chat.id)\n        if not user_data:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        user_data = user_data[0]\n        for ADMIN in ADMINS_ID:\n            admin_bot.send_photo(ADMIN, open(path_recp, 'rb'),\n                                 caption=payment_received_template(payment,user_data),\n                                 reply_markup=confirm_payment_by_admin(charge_wallet['id']))\n        bot.send_message(message.chat.id, MESSAGES['WAIT_FOR_ADMIN_CONFIRMATION'],\n                         reply_markup=main_menu_keyboard_markup())\n    else:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        \n# Next Step Payment - Send Answer\ndef next_step_answer_to_admin(message, admin_id):\n    if is_it_cancel(message):\n        return\n    bot_users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if bot_users:\n        bot_user = bot_users[0]\n    admin_bot.send_message(int(admin_id), f\"{MESSAGES['NEW_TICKET_RECEIVED']}\\n{MESSAGES['TICKET_TEXT']} {message.text}\",\n                           reply_markup=answer_to_user_markup(bot_user,message.chat.id))\n    bot.send_message(message.chat.id, MESSAGES['SEND_TICKET_TO_ADMIN_RESPONSE'],\n                         reply_markup=main_menu_keyboard_markup())\n\n# Next Step Payment - Send Ticket To Admin\ndef next_step_send_ticket_to_admin(message):\n    if is_it_cancel(message):\n        return\n    bot_users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if bot_users:\n        bot_user = bot_users[0]\n    for ADMIN in ADMINS_ID:\n        admin_bot.send_message(ADMIN, f\"{MESSAGES['NEW_TICKET_RECEIVED']}\\n{MESSAGES['TICKET_TEXT']} {message.text}\",\n                               reply_markup=answer_to_user_markup(bot_user,message.chat.id))\n        bot.send_message(message.chat.id, MESSAGES['SEND_TICKET_TO_ADMIN_RESPONSE'],\n                            reply_markup=main_menu_keyboard_markup())\n\n# ----------------------------------- Buy From Wallet Area -----------------------------------\n# Next Step Buy From Wallet - Send Name\ndef next_step_send_name_for_buy_from_wallet(message: Message, plan):\n    if is_it_cancel(message):\n        return\n\n    if not plan:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    name = message.text\n    while is_it_command(message):\n        message = bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_NAME'])\n        bot.register_next_step_handler(message, next_step_send_name_for_buy_from_wallet, plan)\n        return\n    created_at = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n    paid_amount = plan['price']\n\n    order_id = random.randint(1000000, 9999999)\n    server_id = plan['server_id']\n    server = USERS_DB.find_server(id=server_id)\n    if not server:\n        bot.send_message(message.chat.id, f\"{MESSAGES['UNKNOWN_ERROR']}:Server Not Found\",\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    server = server[0]\n    URL = server['url'] + API_PATH\n\n    # value = ADMIN_DB.add_default_user(name, plan['days'], plan['size_gb'],)\n    sub_id = random.randint(1000000, 9999999)\n    value = api.insert(URL, name=name, usage_limit_GB=plan['size_gb'], package_days=plan['days'],comment=f\"HidyBot:{sub_id}\")\n    if not value:\n        bot.send_message(message.chat.id,\n                         f\"{MESSAGES['UNKNOWN_ERROR']}:Create User Error\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    add_sub_status = USERS_DB.add_order_subscription(sub_id, order_id, value, server_id)\n    if not add_sub_status:\n        bot.send_message(message.chat.id,\n                         f\"{MESSAGES['UNKNOWN_ERROR']}:Add Subscription Error\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    status = USERS_DB.add_order(order_id, message.chat.id,name, plan['id'], created_at)\n    if not status:\n        bot.send_message(message.chat.id,\n                         f\"{MESSAGES['UNKNOWN_ERROR']}:Add Order Error\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n    if wallet:\n        wallet = wallet[0]\n        wallet_balance = int(wallet['balance']) - int(paid_amount)\n        user_info = USERS_DB.edit_wallet(message.chat.id, balance=wallet_balance)\n        if not user_info:\n            bot.send_message(message.chat.id,\n                             f\"{MESSAGES['UNKNOWN_ERROR']}:Edit Wallet Balance Error\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                             reply_markup=main_menu_keyboard_markup())\n            return\n    bot.send_message(message.chat.id,\n                     f\"{MESSAGES['PAYMENT_CONFIRMED']}\\n{MESSAGES['ORDER_ID']} {order_id}\",\n                     reply_markup=main_menu_keyboard_markup())\n    \n    user_info = api.find(URL, value)\n    user_info = utils.users_to_dict([user_info])\n    user_info = utils.dict_process(URL, user_info)\n    user_info = user_info[0]\n    api_user_data = user_info_template(sub_id, server, user_info, MESSAGES['INFO_USER'])\n    bot.send_message(message.chat.id, api_user_data,\n                                 reply_markup=user_info_markup(user_info['uuid']))\n    \n    BASE_URL = urlparse(server['url']).scheme + \"://\" + urlparse(server['url']).netloc\n    link = f\"{BASE_URL}/{urlparse(server['url']).path.split('/')[1]}/{value}/\"\n    user_name = f\"<a href='{link}'> {name} </a>\"\n    bot_users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if bot_users:\n        bot_user = bot_users[0]\n    for ADMIN in ADMINS_ID:\n        admin_bot.send_message(ADMIN,\n                               f\"\"\"{MESSAGES['ADMIN_NOTIFY_NEW_SUB']} {user_name} {MESSAGES['ADMIN_NOTIFY_CONFIRM']}\n{MESSAGES['SERVER']}<a href='{server['url']}/admin'> {server['title']} </a>\n{MESSAGES['INFO_ID']} <code>{sub_id}</code>\"\"\", reply_markup=notify_to_admin_markup(bot_user))\n\n\n# ----------------------------------- Get Free Test Area -----------------------------------\n# Next Step Get Free Test - Send Name\ndef next_step_send_name_for_get_free_test(message: Message, server_id):\n    if is_it_cancel(message):\n        return\n    name = message.text\n    while is_it_command(message):\n        message = bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_NAME'])\n        bot.register_next_step_handler(message, next_step_send_name_for_get_free_test)\n        return\n\n    settings = utils.all_configs_settings()\n    test_user_comment = \"HidyBot:FreeTest\"\n    server = USERS_DB.find_server(id=server_id)\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    server = server[0]\n    URL = server['url'] + API_PATH\n    # uuid = ADMIN_DB.add_default_user(name, test_user_days, test_user_size_gb, int(PANEL_ADMIN_ID), test_user_comment)\n    uuid = api.insert(URL, name=name, usage_limit_GB=settings['test_sub_size_gb'], package_days=settings['test_sub_days'],\n                      comment=test_user_comment)\n    if not uuid:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    non_order_id = random.randint(10000000, 99999999)\n    non_order_status = USERS_DB.add_non_order_subscription(non_order_id, message.chat.id, uuid, server_id)\n    if not non_order_status:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    edit_user_status = USERS_DB.edit_user(message.chat.id, test_subscription=True)\n    if not edit_user_status:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    bot.send_message(message.chat.id, MESSAGES['GET_FREE_CONFIRMED'],\n                     reply_markup=main_menu_keyboard_markup())\n    user_info = api.find(URL, uuid)\n    user_info = utils.users_to_dict([user_info])\n    user_info = utils.dict_process(URL, user_info)\n    user_info = user_info[0]\n    api_user_data = user_info_template(non_order_id, server, user_info, MESSAGES['INFO_USER'])\n    bot.send_message(message.chat.id, api_user_data,\n                                 reply_markup=user_info_markup(user_info['uuid']))\n    BASE_URL = urlparse(server['url']).scheme + \"://\" + urlparse(server['url']).netloc\n    link = f\"{BASE_URL}/{urlparse(server['url']).path.split('/')[1]}/{uuid}/\"\n    user_name = f\"<a href='{link}'> {name} </a>\"\n    bot_users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if bot_users:\n        bot_user = bot_users[0]\n    for ADMIN in ADMINS_ID:\n        admin_bot.send_message(ADMIN,\n                               f\"\"\"{MESSAGES['ADMIN_NOTIFY_NEW_FREE_TEST']} {user_name} {MESSAGES['ADMIN_NOTIFY_CONFIRM']}\n{MESSAGES['SERVER']}<a href='{server['url']}/admin'> {server['title']} </a>\n{MESSAGES['INFO_ID']} <code>{non_order_id}</code>\"\"\", reply_markup=notify_to_admin_markup(bot_user))\n\n\n# ----------------------------------- To QR Area -----------------------------------\n# Next Step QR - QR Code\ndef next_step_to_qr(message: Message):\n    if is_it_cancel(message):\n        return\n    if not message.text:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    is_it_valid = utils.is_it_config_or_sub(message.text)\n    if is_it_valid:\n        qr_code = utils.txt_to_qr(message.text)\n        if qr_code:\n            bot.send_photo(message.chat.id, qr_code, reply_markup=main_menu_keyboard_markup())\n    else:\n        bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_TO_QR_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n\n\n# ----------------------------------- Link Subscription Area -----------------------------------\n# Next Step Link Subscription to bot\ndef next_step_link_subscription(message: Message):\n    if not message.text:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    if is_it_cancel(message):\n        return\n    uuid = utils.is_it_config_or_sub(message.text)\n    if uuid:\n        # check is it already subscribed\n        is_it_subscribed = utils.is_it_subscription_by_uuid_and_telegram_id(uuid, message.chat.id)\n        if is_it_subscribed:\n            bot.send_message(message.chat.id, MESSAGES['ALREADY_SUBSCRIBED'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        non_sub_id = random.randint(10000000, 99999999)\n        servers = USERS_DB.select_servers()\n        if not servers:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'], reply_markup=main_menu_keyboard_markup())\n            return\n        for server in servers:\n            users_list = api.find(server['url'] + API_PATH, uuid)\n            if users_list:\n                server_id = server['id']\n                break\n        status = USERS_DB.add_non_order_subscription(non_sub_id, message.chat.id, uuid, server_id)\n        if status:\n            bot.send_message(message.chat.id, MESSAGES['SUBSCRIPTION_CONFIRMED'],\n                             reply_markup=main_menu_keyboard_markup())\n        else:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n    else:\n        bot.send_message(message.chat.id, MESSAGES['SUBSCRIPTION_INFO_NOT_FOUND'],\n                         reply_markup=main_menu_keyboard_markup())\n\n\n# ----------------------------------- wallet balance Area -----------------------------------\n# Next Step increase wallet balance - Send amount\ndef next_step_increase_wallet_balance(message):\n    if is_it_cancel(message):\n        return\n    if not is_it_digit(message, markup=cancel_markup()):\n        bot.register_next_step_handler(message, next_step_increase_wallet_balance)\n        return\n    minimum_deposit_amount = utils.all_configs_settings()\n    minimum_deposit_amount = minimum_deposit_amount['min_deposit_amount']\n    amount = utils.toman_to_rial(message.text)\n    if amount < minimum_deposit_amount:\n        bot.send_message(message.chat.id,\n                         f\"{MESSAGES['INCREASE_WALLET_BALANCE_AMOUNT']}\\n{MESSAGES['MINIMUM_DEPOSIT_AMOUNT']}: \"\n                         f\"{rial_to_toman(minimum_deposit_amount)} {MESSAGES['TOMAN']}\", reply_markup=cancel_markup())\n        bot.register_next_step_handler(message, next_step_increase_wallet_balance)\n        return\n    settings = utils.all_configs_settings()\n    if not settings:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n\n    charge_wallet['amount'] = str(amount)\n    if settings['three_random_num_price'] == 1:\n        charge_wallet['amount'] = utils.replace_last_three_with_random(str(amount))\n\n    charge_wallet['id'] = random.randint(1000000, 9999999)\n    # Send 0 to identify wallet balance charge\n    bot.send_message(message.chat.id,\n                     owner_info_template(settings['card_number'], settings['card_holder'], charge_wallet['amount']),\n                     reply_markup=send_screenshot_markup(plan_id=charge_wallet['id']))\n\ndef increase_wallet_balance_specific(message,amount):\n    settings = utils.all_configs_settings()\n    user = USERS_DB.find_user(telegram_id=message.chat.id)\n    if user:\n        wallet_status = USERS_DB.find_wallet(telegram_id=message.chat.id)\n        if not wallet_status:\n            status = USERS_DB.add_wallet(telegram_id=message.chat.id)\n            if not status:\n                bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n                return\n    charge_wallet['amount'] = str(amount)\n    if settings['three_random_num_price'] == 1:\n        charge_wallet['amount'] = utils.replace_last_three_with_random(str(amount))\n\n    charge_wallet['id'] = random.randint(1000000, 9999999)\n\n    # Send 0 to identify wallet balance charge\n    bot.send_message(message.chat.id,\n                     owner_info_template(settings['card_number'], settings['card_holder'], charge_wallet['amount']),\n                     reply_markup=send_screenshot_markup(plan_id=charge_wallet['id']))\n    \n\n\ndef update_info_subscription(message: Message, uuid,markup=None):\n    value = uuid\n    sub = utils.find_order_subscription_by_uuid(value)\n    if not sub:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    if not markup:\n        if sub.get('telegram_id', None):\n            # Non-Order Subscription markup\n            mrkup = user_info_non_sub_markup(sub['uuid'])\n        else:\n            # Ordered Subscription markup\n            mrkup = user_info_markup(sub['uuid'])\n    else:\n        mrkup = markup\n    server_id = sub['server_id']\n    server = USERS_DB.find_server(id=server_id)\n    if not server:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    server = server[0]\n    URL = server['url'] + API_PATH\n    user = api.find(URL, uuid=sub['uuid'])\n    if not user:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                         reply_markup=main_menu_keyboard_markup())\n        return\n    user = utils.dict_process(URL, utils.users_to_dict([user]))[0]\n    try:\n        bot.edit_message_text(chat_id=message.chat.id, message_id=message.message_id,\n                              text=user_info_template(sub['id'], server, user, MESSAGES['INFO_USER']),\n                              reply_markup=mrkup)\n    except:\n        pass\n\n\n# *********************************** Callback Query Area ***********************************\n@bot.callback_query_handler(func=lambda call: True)\ndef callback_query(call: CallbackQuery):\n    bot.answer_callback_query(call.id, MESSAGES['WAIT'])\n    bot.clear_step_handler(call.message)\n    if is_user_banned(call.message.chat.id):\n        return\n    # Split Callback Data to Key(Command) and UUID\n    data = call.data.split(':')\n    key = data[0]\n    value = data[1]\n\n    global selected_server_id\n    # ----------------------------------- Link Subscription Area -----------------------------------\n    # Confirm Link Subscription\n    if key == 'force_join_status':\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n        join_status = is_user_in_channel(call.message.chat.id)\n\n        if not join_status:\n            return\n        else:\n            bot.send_message(call.message.chat.id, MESSAGES['JOIN_CHANNEL_SUCCESSFUL'])\n            \n    elif key == 'confirm_subscription':\n        edit_status = USERS_DB.add_non_order_subscription(call.message.chat.id, value, )\n        if edit_status:\n            bot.delete_message(call.message.chat.id, call.message.message_id)\n            bot.send_message(call.message.chat.id, MESSAGES['SUBSCRIPTION_CONFIRMED'],\n                             reply_markup=main_menu_keyboard_markup())\n        else:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n    # Reject Link Subscription\n    elif key == 'cancel_subscription':\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n        bot.send_message(call.message.chat.id, MESSAGES['CANCEL_SUBSCRIPTION'],\n                         reply_markup=main_menu_keyboard_markup())\n\n    # ----------------------------------- Buy Plan Area -----------------------------------\n    elif key == 'server_selected':\n        if value == 'False':\n            bot.send_message(call.message.chat.id, MESSAGES['SERVER_IS_FULL'], reply_markup=main_menu_keyboard_markup())\n            return\n        selected_server_id = int(value)\n        plans = USERS_DB.find_plan(server_id=int(value))\n        if not plans:\n            bot.send_message(call.message.chat.id, MESSAGES['PLANS_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n            return\n        plan_markup = plans_list_markup(plans)\n        if not plan_markup:\n            bot.send_message(call.message.chat.id, MESSAGES['PLANS_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n            return\n        bot.edit_message_text(MESSAGES['PLANS_LIST'], call.message.chat.id, call.message.message_id,\n                                    reply_markup=plan_markup)\n        \n    elif key == 'free_test_server_selected':\n        if value == 'False':\n            bot.send_message(call.message.chat.id, MESSAGES['SERVER_IS_FULL'], reply_markup=main_menu_keyboard_markup())\n            return\n        users = USERS_DB.find_user(telegram_id=call.message.chat.id)\n        if users:\n            user = users[0]\n            if user['test_subscription']:\n                bot.send_message(call.message.chat.id, MESSAGES['ALREADY_RECEIVED_FREE'],\n                                reply_markup=main_menu_keyboard_markup())\n                return\n            bot.delete_message(call.message.chat.id, call.message.message_id)\n            bot.send_message(call.message.chat.id, MESSAGES['REQUEST_SEND_NAME'], reply_markup=cancel_markup())\n            bot.register_next_step_handler(call.message, next_step_send_name_for_get_free_test, value)\n    # Send Asked Plan Info\n    elif key == 'plan_selected':\n        plan = USERS_DB.find_plan(id=value)[0]\n        if not plan:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,\n                              text=plan_info_template(plan),\n                              reply_markup=confirm_buy_plan_markup(plan['id']))\n\n    # Confirm To Buy From Wallet\n    elif key == 'confirm_buy_from_wallet':\n        plan = USERS_DB.find_plan(id=value)[0]\n        buy_from_wallet_confirm(call.message, plan)\n    elif key == 'confirm_renewal_from_wallet':\n        plan = USERS_DB.find_plan(id=value)[0]\n        renewal_from_wallet_confirm(call.message)\n\n    # Ask To Send Screenshot\n    elif key == 'send_screenshot':\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n        bot.send_message(call.message.chat.id, MESSAGES['REQUEST_SEND_SCREENSHOT'])\n        bot.register_next_step_handler(call.message, next_step_send_screenshot, charge_wallet)\n\n    #Answer to Admin After send Screenshot\n    elif key == 'answer_to_admin':\n        #bot.delete_message(call.message.chat.id,call.message.message_id)\n        bot.send_message(call.message.chat.id, MESSAGES['ANSWER_TO_ADMIN'],\n                        reply_markup=cancel_markup())\n        bot.register_next_step_handler(call.message, next_step_answer_to_admin, value)\n\n    #Send Ticket to Admin \n    elif key == 'send_ticket_to_support':\n        bot.delete_message(call.message.chat.id,call.message.message_id)\n        bot.send_message(call.message.chat.id, MESSAGES['SEND_TICKET_TO_ADMIN'],\n                        reply_markup=cancel_markup())\n        bot.register_next_step_handler(call.message, next_step_send_ticket_to_admin)\n\n    # ----------------------------------- User Subscriptions Info Area -----------------------------------\n    # Unlink non-order subscription\n    elif key == 'unlink_subscription':\n        delete_status = USERS_DB.delete_non_order_subscription(uuid=value)\n        if delete_status:\n            bot.delete_message(call.message.chat.id, call.message.message_id)\n            bot.send_message(call.message.chat.id, MESSAGES['SUBSCRIPTION_UNLINKED'],\n                             reply_markup=main_menu_keyboard_markup())\n        else:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n\n    elif key == 'update_info_subscription':\n        update_info_subscription(call.message, value)\n\n    # ----------------------------------- wallet Area -----------------------------------\n    # INCREASE WALLET BALANCE\n    elif key == 'increase_wallet_balance':\n        bot.send_message(call.message.chat.id, MESSAGES['INCREASE_WALLET_BALANCE_AMOUNT'], reply_markup=cancel_markup())\n\n        bot.register_next_step_handler(call.message, next_step_increase_wallet_balance)\n    elif key == 'increase_wallet_balance_specific':\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n        increase_wallet_balance_specific(call.message,value)\n    elif key == 'renewal_subscription':\n        settings = utils.all_configs_settings()\n        if not settings['renewal_subscription_status']:\n            bot.send_message(call.message.chat.id, MESSAGES['RENEWAL_SUBSCRIPTION_CLOSED'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        servers = USERS_DB.select_servers()\n        server_id = 0\n        user= []\n        URL = \"url\"\n        if servers:\n            for server in servers:\n                user = api.find(server['url'] + API_PATH, value)\n                if user:\n                    selected_server_id = server['id']\n                    URL = server['url'] + API_PATH\n                    break\n        if not user:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        user_info = utils.users_to_dict([user])\n        if not user_info:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n\n        user_info_process = utils.dict_process(URL, user_info)\n        if not user_info_process:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        user_info_process = user_info_process[0]\n        if settings['renewal_method'] == 2:\n            if user_info_process['remaining_day'] > settings['advanced_renewal_days'] and user_info_process['usage']['remaining_usage_GB'] > settings['advanced_renewal_usage']:\n                bot.send_message(call.message.chat.id, renewal_unvalable_template(settings),\n                                 reply_markup=main_menu_keyboard_markup())\n                return\n        \n\n        renew_subscription_dict[call.message.chat.id] = {\n            'uuid': None,\n            'plan_id': None,\n        }\n        plans = USERS_DB.find_plan(server_id=selected_server_id)\n        if not plans:\n            bot.send_message(call.message.chat.id, MESSAGES['PLANS_NOT_FOUND'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        renew_subscription_dict[call.message.chat.id]['uuid'] = value\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=plans_list_markup(plans, renewal=True,uuid=user_info_process['uuid']))\n\n    elif key == 'renewal_plan_selected':\n        plan = USERS_DB.find_plan(id=value)[0]\n        if not plan:\n            bot.send_message(call.message.chat.id, MESSAGES['PLANS_NOT_FOUND'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        renew_subscription_dict[call.message.chat.id]['plan_id'] = plan['id']\n        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,\n                              text=plan_info_template(plan),\n                              reply_markup=confirm_buy_plan_markup(plan['id'], renewal=True,uuid=renew_subscription_dict[call.message.chat.id]['uuid']))\n\n    elif key == 'cancel_increase_wallet_balance':\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n        bot.send_message(call.message.chat.id, MESSAGES['CANCEL_INCREASE_WALLET_BALANCE'],\n                         reply_markup=main_menu_keyboard_markup())\n    # ----------------------------------- User Configs Area -----------------------------------\n    # User Configs - Main Menu\n    elif key == 'configs_list':\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=sub_url_user_list_markup(value))\n    # User Configs - Direct Link\n    elif key == 'conf_dir':\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=sub_user_list_markup(value,configs))\n        \n    # User Configs - Vless Configs Callback\n    elif key == \"conf_dir_vless\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['vless']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = configs_template(configs['vless'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=main_menu_keyboard_markup())\n    # User Configs - VMess Configs Callback\n    elif key == \"conf_dir_vmess\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['vmess']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = configs_template(configs['vmess'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=main_menu_keyboard_markup())\n    # User Configs - Trojan Configs Callback\n    elif key == \"conf_dir_trojan\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        configs = utils.sub_parse(sub['sub_link'])\n        if not configs:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        if not configs['trojan']:\n            bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])\n            return\n        msgs = configs_template(configs['trojan'])\n        for message in msgs:\n            if message:\n                bot.send_message(call.message.chat.id, f\"{message}\",\n                                 reply_markup=main_menu_keyboard_markup())\n\n    # User Configs - Subscription Configs Callback\n    elif key == \"conf_sub_url\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB']}\\n<code>{sub['sub_link']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n    # User Configs - Base64 Subscription Configs Callback\n    elif key == \"conf_sub_url_b64\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link_b64'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB_B64']}\\n<code>{sub['sub_link_b64']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n    # User Configs - Subscription Configs For Clash Callback\n    elif key == \"conf_clash\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['clash_configs'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_CLASH']}\\n<code>{sub['clash_configs']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n    # User Configs - Subscription Configs For Hiddify Callback\n    elif key == \"conf_hiddify\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['hiddify_configs'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_HIDDIFY']}\\n<code>{sub['hiddify_configs']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_auto\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sub_link_auto'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SUB_AUTO']}\\n<code>{sub['sub_link_auto']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_sing_box\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sing_box'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_SING_BOX']}\\n<code>{sub['sing_box']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n\n    elif key == \"conf_sub_full_sing_box\":\n        sub = utils.sub_links(value)\n        if not sub:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        qr_code = utils.txt_to_qr(sub['sing_box_full'])\n        if not qr_code:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n            return\n        bot.send_photo(\n            call.message.chat.id,\n            photo=qr_code,\n            caption=f\"{KEY_MARKUP['CONFIGS_FULL_SING_BOX']}\\n<code>{sub['sing_box_full']}</code>\",\n            reply_markup=main_menu_keyboard_markup()\n        )\n\n    # manual\n    elif key == \"msg_manual\":\n        settings = utils.all_configs_settings()\n        android_msg = settings['msg_manual_android'] if settings['msg_manual_android'] else MESSAGES['MANUAL_ANDROID']\n        ios_msg = settings['msg_manual_ios'] if settings['msg_manual_ios'] else MESSAGES['MANUAL_IOS']\n        win_msg = settings['msg_manual_windows'] if settings['msg_manual_windows'] else MESSAGES['MANUAL_WIN']\n        mac_msg = settings['msg_manual_mac'] if settings['msg_manual_mac'] else MESSAGES['MANUAL_MAC']\n        linux_msg = settings['msg_manual_linux'] if settings['msg_manual_linux'] else MESSAGES['MANUAL_LIN']\n        if value == 'android':\n            bot.send_message(call.message.chat.id, android_msg, reply_markup=main_menu_keyboard_markup())\n        elif value == 'ios':\n            bot.send_message(call.message.chat.id, ios_msg, reply_markup=main_menu_keyboard_markup())\n        elif value == 'win':\n            bot.send_message(call.message.chat.id, win_msg, reply_markup=main_menu_keyboard_markup())\n        elif value == 'mac':\n            bot.send_message(call.message.chat.id, mac_msg, reply_markup=main_menu_keyboard_markup())\n        elif value == 'lin':\n            bot.send_message(call.message.chat.id, linux_msg, reply_markup=main_menu_keyboard_markup())\n\n\n\n\n\n    # ----------------------------------- Back Area -----------------------------------\n    # Back To User Menu\n    elif key == \"back_to_user_panel\":\n        bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n                                      reply_markup=user_info_markup(value))\n        \n\n    # Back To Plans\n    elif key == \"back_to_plans\":\n        plans = USERS_DB.find_plan(server_id=selected_server_id)\n        if not plans:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,\n                              text=MESSAGES['PLANS_LIST'], reply_markup=plans_list_markup(plans))\n\n    # Back To Renewal Plans\n    elif key == \"back_to_renewal_plans\":\n        plans = USERS_DB.find_plan(server_id=selected_server_id)\n        if not plans:\n            bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        # bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,\n        #                               reply_markup=plans_list_markup(plans, renewal=True,uuid=value))\n        update_info_subscription(call.message, value,plans_list_markup(plans, renewal=True,uuid=value))\n    \n    elif key == \"back_to_servers\":\n        servers = USERS_DB.select_servers()\n        server_list = []\n        if not servers:\n            bot.send_message(message.chat.id, MESSAGES['SERVERS_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n            return\n        for server in servers:\n            user_index = 0\n            #if server['status']:\n            users_list = api.select(server['url'] + API_PATH)\n            if users_list:\n                user_index = len(users_list)\n            if server['user_limit'] > user_index:\n                server_list.append([server,True])\n            else:\n                server_list.append([server,False])\n                \n        # bad request telbot api\n        # bot.edit_message_text(chat_id=message.chat.id, message_id=msg_wait.message_id,\n        #                                   text= MESSAGES['SERVERS_LIST'], reply_markup=servers_list_markup(server_list))\n        #bot.delete_message(message.chat.id, msg_wait.message_id)\n        bot.edit_message_text(reply_markup=servers_list_markup(server_list), chat_id=call.message.chat.id, message_id=call.message.message_id,\n                                      text=MESSAGES['SERVERS_LIST'])\n        \n\n    # Delete Message\n    elif key == \"del_msg\":\n        bot.delete_message(call.message.chat.id, call.message.message_id)\n\n    # Invalid Command\n    else:\n        bot.answer_callback_query(call.id, MESSAGES['ERROR_INVALID_COMMAND'])\n\n\n# *********************************** Message Handler Area ***********************************\n# Bot Start Message Handler\n@bot.message_handler(commands=['start'])\ndef start_bot(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    settings = utils.all_configs_settings()\n\n    MESSAGES['WELCOME'] = MESSAGES['WELCOME'] if not settings['msg_user_start'] else settings['msg_user_start']\n    \n    if USERS_DB.find_user(telegram_id=message.chat.id):\n        edit_name= USERS_DB.edit_user(telegram_id=message.chat.id,full_name=message.from_user.full_name)\n        edit_username = USERS_DB.edit_user(telegram_id=message.chat.id,username=message.from_user.username)\n        bot.send_message(message.chat.id, MESSAGES['WELCOME'], reply_markup=main_menu_keyboard_markup())\n    else:\n        created_at = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n        status = USERS_DB.add_user(telegram_id=message.chat.id,username=message.from_user.username, full_name=message.from_user.full_name, created_at=created_at)\n        if not status:\n            bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        wallet_status = USERS_DB.find_wallet(telegram_id=message.chat.id)\n        if not wallet_status:\n            status = USERS_DB.add_wallet(telegram_id=message.chat.id)\n            if not status:\n                bot.send_message(message.chat.id, f\"{MESSAGES['UNKNOWN_ERROR']}:Wallet\",\n                                 reply_markup=main_menu_keyboard_markup())\n                return\n            bot.send_message(message.chat.id, MESSAGES['WELCOME'], reply_markup=main_menu_keyboard_markup())\n\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n\n\n# If user is not in users table, request /start\n@bot.message_handler(func=lambda message: not USERS_DB.find_user(telegram_id=message.chat.id))\ndef not_in_users_table(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['REQUEST_START'], reply_markup=main_menu_keyboard_markup())\n\n\n# User Subscription Status Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SUBSCRIPTION_STATUS'])\ndef subscription_status(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    non_order_subs = utils.non_order_user_info(message.chat.id)\n    order_subs = utils.order_user_info(message.chat.id)\n\n    if not non_order_subs and not order_subs:\n        bot.send_message(message.chat.id, MESSAGES['SUBSCRIPTION_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n        return\n\n    if non_order_subs:\n        for non_order_sub in non_order_subs:\n            if non_order_sub:\n                server_id = non_order_sub['server_id']\n                server = USERS_DB.find_server(id=server_id)\n                if not server:\n                    bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                                    reply_markup=main_menu_keyboard_markup())\n                    return\n                server = server[0]\n                api_user_data = user_info_template(non_order_sub['sub_id'], server, non_order_sub, MESSAGES['INFO_USER'])\n                bot.send_message(message.chat.id, api_user_data,\n                                 reply_markup=user_info_non_sub_markup(non_order_sub['uuid']))\n    if order_subs:\n        for order_sub in order_subs:\n            if order_sub:\n                server_id = order_sub['server_id']\n                server = USERS_DB.find_server(id=server_id)\n                if not server:\n                    bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'],\n                                    reply_markup=main_menu_keyboard_markup())\n                    return\n                server = server[0]\n                api_user_data = user_info_template(order_sub['sub_id'], server, order_sub, MESSAGES['INFO_USER'])\n                bot.send_message(message.chat.id, api_user_data,\n                                 reply_markup=user_info_markup(order_sub['uuid']))\n\n\n# User Buy Subscription Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['BUY_SUBSCRIPTION'])\ndef buy_subscription(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    settings = utils.all_configs_settings()\n    if not settings['buy_subscription_status']:\n        bot.send_message(message.chat.id, MESSAGES['BUY_SUBSCRIPTION_CLOSED'], reply_markup=main_menu_keyboard_markup())\n        return\n    wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n    if not wallet:\n        create_wallet_status = USERS_DB.add_wallet(message.chat.id)\n        if not create_wallet_status: \n            bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])\n            return\n        wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n    #msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=main_menu_keyboard_markup())\n    servers = USERS_DB.select_servers()\n    server_list = []\n    if not servers:\n        bot.send_message(message.chat.id, MESSAGES['SERVERS_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n        return\n    for server in servers:\n        user_index = 0\n        #if server['status']:\n        users_list = api.select(server['url'] + API_PATH)\n        if users_list:\n            user_index = len(users_list)\n        if server['user_limit'] > user_index:\n            server_list.append([server,True])\n        else:\n            server_list.append([server,False])\n    # bad request telbot api\n    # bot.edit_message_text(chat_id=message.chat.id, message_id=msg_wait.message_id,\n    #                                   text= MESSAGES['SERVERS_LIST'], reply_markup=servers_list_markup(server_list))\n    #bot.delete_message(message.chat.id, msg_wait.message_id)\n    bot.send_message(message.chat.id, MESSAGES['SERVERS_LIST'], reply_markup=servers_list_markup(server_list))\n\n\n# Config To QR Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['TO_QR'])\ndef to_qr(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_TO_QR'], reply_markup=cancel_markup())\n    bot.register_next_step_handler(message, next_step_to_qr)\n\n\n# Help Guide Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['MANUAL'])\ndef help_guide(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['MANUAL_HDR'],\n                     reply_markup=users_bot_management_settings_panel_manual_markup())\n    \n# Help Guide Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['FAQ'])\ndef faq(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    settings = utils.all_configs_settings()\n    faq_msg = settings['msg_faq'] if settings['msg_faq'] else MESSAGES['UNKNOWN_ERROR']\n    bot.send_message(message.chat.id, faq_msg, reply_markup=main_menu_keyboard_markup())\n\n\n# Ticket To Support Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SEND_TICKET'])\ndef send_ticket(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['SEND_TICKET_TO_ADMIN_TEMPLATE'], reply_markup=send_ticket_to_admin())\n\n\n# Link Subscription Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['LINK_SUBSCRIPTION'])\ndef link_subscription(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['ENTER_SUBSCRIPTION_INFO'], reply_markup=cancel_markup())\n    bot.register_next_step_handler(message, next_step_link_subscription)\n\n\n# User Buy Subscription Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['WALLET'])\ndef wallet_balance(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    user = USERS_DB.find_user(telegram_id=message.chat.id)\n    if user:\n        wallet_status = USERS_DB.find_wallet(telegram_id=message.chat.id)\n        if not wallet_status:\n            status = USERS_DB.add_wallet(telegram_id=message.chat.id)\n            if not status:\n                bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n                return\n\n        wallet = USERS_DB.find_wallet(telegram_id=message.chat.id)\n        wallet = wallet[0]\n        telegram_user_data = wallet_info_template(wallet['balance'])\n\n        bot.send_message(message.chat.id, telegram_user_data,\n                         reply_markup=wallet_info_markup())\n    else:\n        bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])\n\n\n# User Buy Subscription Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['FREE_TEST'])\ndef free_test(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    settings = utils.all_configs_settings()\n    if not settings['test_subscription']:\n        bot.send_message(message.chat.id, MESSAGES['FREE_TEST_NOT_AVAILABLE'], reply_markup=main_menu_keyboard_markup())\n        return\n    users = USERS_DB.find_user(telegram_id=message.chat.id)\n    if users:\n        user = users[0]\n        if user['test_subscription']:\n            bot.send_message(message.chat.id, MESSAGES['ALREADY_RECEIVED_FREE'],\n                             reply_markup=main_menu_keyboard_markup())\n            return\n        else:\n            # bot.send_message(message.chat.id, MESSAGES['REQUEST_SEND_NAME'], reply_markup=cancel_markup())\n            # bot.register_next_step_handler(message, next_step_send_name_for_get_free_test)\n            msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'])\n            servers = USERS_DB.select_servers()\n            server_list = []\n            if not servers:\n                bot.send_message(message.chat.id, MESSAGES['SERVERS_NOT_FOUND'], reply_markup=main_menu_keyboard_markup())\n                return\n            for server in servers:\n                user_index = 0\n                #if server['status']:\n                users_list = api.select(server['url'] + API_PATH)\n                if users_list:\n                    user_index = len(users_list)\n                if server['user_limit'] > user_index:\n                    server_list.append([server,True])\n                else:\n                    server_list.append([server,False])\n            # bad request telbot api\n            # bot.edit_message_text(chat_id=message.chat.id, message_id=msg_wait.message_id,\n            #                                   text= MESSAGES['SERVERS_LIST'], reply_markup=servers_list_markup(server_list))\n            bot.delete_message(message.chat.id, msg_wait.message_id)\n            bot.send_message(message.chat.id, MESSAGES['SERVERS_LIST'], reply_markup=servers_list_markup(server_list, True))\n\n\n\n# Cancel Message Handler\n@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['CANCEL'])\ndef cancel(message: Message):\n    if is_user_banned(message.chat.id):\n        return\n    join_status = is_user_in_channel(message.chat.id)\n    if not join_status:\n        return\n    bot.send_message(message.chat.id, MESSAGES['CANCELED'], reply_markup=main_menu_keyboard_markup())\n\n\n# *********************************** Main Area ***********************************\ndef start():\n    # Bot Start Commands\n    try:\n        bot.set_my_commands([\n            telebot.types.BotCommand(\"/start\", BOT_COMMANDS['START']),\n        ])\n    except telebot.apihelper.ApiTelegramException as e:\n        if e.result.status_code == 401:\n            logging.error(\"Invalid Telegram Bot Token!\")\n            exit(1)\n    # Welcome to Admin\n    for admin in ADMINS_ID:\n        try:\n            bot.send_message(admin, MESSAGES['WELCOME_TO_ADMIN'])\n        except Exception as e:\n            logging.warning(f\"Error in send message to admin {admin}: {e}\")\n    bot.enable_save_next_step_handlers()\n    bot.load_next_step_handlers()\n    bot.infinity_polling()\n"
  },
  {
    "path": "UserBot/content.py",
    "content": "import os\nimport json\nfrom config import LANG\nfrom Utils.utils import all_configs_settings\n\nFOLDER = \"Json\"\nMSG_FILE = \"messages.json\"\nBTN_FILE = \"buttons.json\"\nCMD_FILE = \"commands.json\"\n\nsettings = all_configs_settings()\n\nwith open(os.path.join(os.path.dirname(__file__), FOLDER, MSG_FILE), encoding='utf-8') as f:\n    MESSAGES = json.load(f)\nMESSAGES = MESSAGES[LANG]\nif settings['msg_user_start']:\n    MESSAGES['WELCOME'] = settings['msg_user_start']\n\nwith open(os.path.join(os.path.dirname(__file__), FOLDER, BTN_FILE), encoding='utf-8') as f:\n    KEY_MARKUP = json.load(f)\nKEY_MARKUP = KEY_MARKUP[LANG]\n\nwith open(os.path.join(os.path.dirname(__file__), FOLDER, CMD_FILE), encoding='utf-8') as f:\n    BOT_COMMANDS = json.load(f)\nBOT_COMMANDS = BOT_COMMANDS[LANG]\n"
  },
  {
    "path": "UserBot/markups.py",
    "content": "# Description: This file contains all the reply and inline keyboard markups used in the bot.\nfrom telebot import types\nfrom telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton\nfrom UserBot.content import KEY_MARKUP, MESSAGES\nfrom UserBot.content import MESSAGES\nfrom Utils.utils import rial_to_toman,all_configs_settings\nfrom Utils.api import *\n\n# Main Menu Reply Keyboard Markup\ndef main_menu_keyboard_markup():\n    markup = ReplyKeyboardMarkup(row_width=3, resize_keyboard=True)\n    markup.add(KeyboardButton(KEY_MARKUP['SUBSCRIPTION_STATUS']))\n    markup.add(KeyboardButton(KEY_MARKUP['LINK_SUBSCRIPTION']), KeyboardButton(KEY_MARKUP['BUY_SUBSCRIPTION']))\n    markup.add(KeyboardButton(KEY_MARKUP['FREE_TEST']), KeyboardButton(KEY_MARKUP['WALLET']))\n    # KeyboardButton(KEY_MARKUP['TO_QR']),\n    settings = all_configs_settings()\n    if settings['msg_faq']:\n        markup.add(KeyboardButton(KEY_MARKUP['SEND_TICKET']),\n                   KeyboardButton(KEY_MARKUP['MANUAL']), KeyboardButton(KEY_MARKUP['FAQ']))\n    else:\n        markup.add(KeyboardButton(KEY_MARKUP['SEND_TICKET']),\n                   KeyboardButton(KEY_MARKUP['MANUAL']))\n    return markup\n\n\ndef user_info_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_LIST'], callback_data=f\"configs_list:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['RENEWAL_SUBSCRIPTION'], callback_data=f\"renewal_subscription:{uuid}\"))\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['UPDATE_SUBSCRIPTION_INFO'], callback_data=f\"update_info_subscription:{uuid}\"))\n    return markup\n\n\n# Subscription URL Inline Keyboard Markup\ndef sub_url_user_list_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    settings = all_configs_settings()\n    if settings['visible_conf_dir']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_DIR'], callback_data=f\"conf_dir:{uuid}\"))\n    if settings['visible_conf_sub_auto']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_AUTO'], callback_data=f\"conf_sub_auto:{uuid}\"))\n    if settings['visible_conf_sub_url']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB'], callback_data=f\"conf_sub_url:{uuid}\"))\n    if settings['visible_conf_sub_url_b64']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_B64'], callback_data=f\"conf_sub_url_b64:{uuid}\"))\n    if settings['visible_conf_clash']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_CLASH'], callback_data=f\"conf_clash:{uuid}\"))\n    if settings['visible_conf_hiddify']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_HIDDIFY'], callback_data=f\"conf_hiddify:{uuid}\"))\n    if settings['visible_conf_sub_sing_box']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SING_BOX'], callback_data=f\"conf_sub_sing_box:{uuid}\"))\n    if settings['visible_conf_sub_full_sing_box']:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_FULL_SING_BOX'],\n                                        callback_data=f\"conf_sub_full_sing_box:{uuid}\"))\n\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n\n    return markup\n\n# Subscription Configs Inline Keyboard Markup\ndef sub_user_list_markup(uuid,configs):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    if configs['vless']:\n        markup.add(InlineKeyboardButton('Vless', callback_data=f\"conf_dir_vless:{uuid}\"))\n    if configs['vmess']:\n        markup.add(InlineKeyboardButton('Vmess', callback_data=f\"conf_dir_vmess:{uuid}\"))\n    if configs['trojan']:\n        markup.add(InlineKeyboardButton('Trojan', callback_data=f\"conf_dir_trojan:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n    # markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n    # markup.add(InlineKeyboardButton('Vmess', callback_data=f\"conf_dir_vmess:{uuid}\"))\n    # markup.add(InlineKeyboardButton('Trojan', callback_data=f\"conf_dir_trojan:{uuid}\"))\n\n    return markup\n\ndef user_info_non_sub_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 2\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_LIST'], callback_data=f\"configs_list:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['RENEWAL_SUBSCRIPTION'], callback_data=f\"renewal_subscription:{uuid}\"))\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['UPDATE_SUBSCRIPTION_INFO'], callback_data=f\"update_info_subscription:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['UNLINK_SUBSCRIPTION'], callback_data=f\"unlink_subscription:{uuid}\"))\n    return markup\n\n\ndef confirm_subscription_markup(uuid):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['YES'], callback_data=f\"confirm_subscription:{uuid}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f\"cancel_subscription:{uuid}\"))\n    return markup\n\n\ndef confirm_buy_plan_markup(plan_id, renewal=False,uuid=None):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    callback = \"confirm_buy_from_wallet\" if not renewal else \"confirm_renewal_from_wallet\"\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BUY_FROM_WALLET'], callback_data=f\"{callback}:{plan_id}\"))\n    if renewal:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_renewal_plans:{uuid}\"))\n    else:\n        markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_plans:None\"))\n    return markup\n\n\ndef send_screenshot_markup(plan_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_SCREENSHOT'], callback_data=f\"send_screenshot:{plan_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['CANCEL'], callback_data=f\"cancel_increase_wallet_balance:{plan_id}\"))\n    return markup\n\n\ndef plans_list_markup(plans, renewal=False,uuid=None):\n    markup = InlineKeyboardMarkup(row_width=1)\n    callback = \"renewal_plan_selected\" if renewal else \"plan_selected\"\n    keys = []\n    for plan in plans:\n        if plan['status']:\n            keys.append(InlineKeyboardButton(\n                f\"{plan['size_gb']}{MESSAGES['GB']} | {plan['days']}{MESSAGES['DAY_EXPIRE']} | {rial_to_toman(plan['price'])} {MESSAGES['TOMAN']}\",\n                callback_data=f\"{callback}:{plan['id']}\"))\n    if len(keys) == 0:\n        return None\n    if renewal:\n        keys.append(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_user_panel:{uuid}\"))\n    else:\n        keys.append(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"back_to_servers:None\"))\n    markup.add(*keys)\n    return markup\n\n\n# Server List - Server List - Inline Keyboard Markup\ndef servers_list_markup(servers, free_test=False):\n    markup = InlineKeyboardMarkup(row_width=1)\n    callback = \"free_test_server_selected\" if free_test else \"server_selected\"\n    keys = []\n    if servers:\n        for server in servers:\n            server_title = server[0]['title'] if server[1] else f\"{server[0]['title']}⛔️\"\n            callback_2 = f\"{server[0]['id']}\" if server[1] else \"False\"\n            keys.append(InlineKeyboardButton(f\"{server_title}\",\n                                             callback_data=f\"{callback}:{callback_2}\"))\n        keys.append(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"del_msg:None\"))\n    if len(keys) == 0:\n        return None\n    markup.add(*keys)\n    return markup\n\ndef confirm_payment_by_admin(order_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['CONFIRM_PAYMENT'], callback_data=f\"confirm_payment_by_admin:{order_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f\"cancel_payment_by_admin:{order_id}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_MESSAGE'], callback_data=f\"send_message_by_admin:{order_id}\"))\n    return markup\n\ndef notify_to_admin_markup(user):\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(f\"{name}\", callback_data=f\"bot_user_info:{user['telegram_id']}\"))\n    return markup\n\ndef send_ticket_to_admin():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['SEND_TICKET_TO_SUPPORT'], callback_data=f\"send_ticket_to_support:None\"))\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['CANCEL'], callback_data=f\"del_msg:None\"))\n    \n    return markup\n\ndef answer_to_user_markup(user,user_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n    markup.add(InlineKeyboardButton(f\"{name}\", callback_data=f\"bot_user_info:{user['telegram_id']}\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['ANSWER'], callback_data=f\"users_bot_send_message_by_admin:{user_id}\"))\n    return markup\n\ndef cancel_markup():\n    markup = ReplyKeyboardMarkup(row_width=3, resize_keyboard=True)\n    markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))\n    return markup\n\n\ndef wallet_info_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['INCREASE_WALLET_BALANCE'], callback_data=f\"increase_wallet_balance:wallet\"))\n    return markup\n\ndef wallet_info_specific_markup(amount):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['INCREASE_WALLET_BALANCE'], callback_data=f\"increase_wallet_balance_specific:{amount}\"))\n    return markup\n\ndef force_join_channel_markup(channel_id):\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    channel_id = channel_id.replace(\"@\", \"\")\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['JOIN_CHANNEL'], url=f\"https://t.me/{channel_id}\",)\n    )\n    markup.add(\n        InlineKeyboardButton(KEY_MARKUP['FORCE_JOIN_CHANNEL_ACCEPTED'], callback_data=f\"force_join_status:None\")\n    )\n    return markup\n\n\ndef users_bot_management_settings_panel_manual_markup():\n    markup = InlineKeyboardMarkup()\n    markup.row_width = 1\n    markup.add(InlineKeyboardButton(KEY_MARKUP['MANUAL_ANDROID'],\n                                    callback_data=f\"msg_manual:android\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['MANUAL_IOS'],\n                                    callback_data=f\"msg_manual:ios\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['MANUAL_WIN'],\n                                    callback_data=f\"msg_manual:win\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['MANUAL_MAC'],\n                                    callback_data=f\"msg_manual:mac\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['MANUAL_LIN'],\n                                    callback_data=f\"msg_manual:lin\"))\n    markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f\"del_msg:None\"))\n    return markup"
  },
  {
    "path": "UserBot/templates.py",
    "content": "# Description: This file contains all the templates used in the bot.\nfrom config import LANG\nfrom UserBot.content import MESSAGES\nfrom Utils.utils import rial_to_toman, toman_to_rial,all_configs_settings\nfrom Database.dbManager import USERS_DB\n# User Subscription Info Template\ndef user_info_template(sub_id, server, usr, header=\"\"):\n    settings = USERS_DB.find_bool_config(key='visible_hiddify_hyperlink')\n    if settings:\n        settings = settings[0]\n        if settings['value']:\n            user_name = f\"<a href='{usr['link']}'> {usr['name']} </a>\"\n        else:\n            user_name = usr['name']\n    else:\n        user_name = usr['name']\n    # if usr['enable'] == 1:\n    #     status = MESSAGES['ACTIVE_SUBSCRIPTION_STATUS']\n    # else:\n    #     status = MESSAGES['DEACTIVE_SUBSCRIPTION_STATUS']\n    return f\"\"\"\n{header}\n\n{MESSAGES['USER_NAME']} {user_name}\n{MESSAGES['SERVER']} {server['title']}\n{MESSAGES['INFO_USAGE']} {usr['usage']['current_usage_GB']} {MESSAGES['OF']} {usr['usage']['usage_limit_GB']} {MESSAGES['GB']}\n{MESSAGES['INFO_REMAINING_DAYS']} {usr['remaining_day']} {MESSAGES['DAY_EXPIRE']}\n{MESSAGES['INFO_ID']} <code>{sub_id}</code>\n\"\"\"\n# {MESSAGES['SUBSCRIPTION_STATUS']} {status}\n\n# Wallet Info Template\ndef wallet_info_template(balance):\n    if balance == 0:\n        return MESSAGES['ZERO_BALANCE']\n    else:\n        return f\"\"\"\n         {MESSAGES['WALLET_INFO_PART_1']} {rial_to_toman(balance)} {MESSAGES['WALLET_INFO_PART_2']}\n         \"\"\"\n\n\n# Plan Info Template\ndef plan_info_template(plan, header=\"\"):\n    msg = f\"\"\"\n{header}\n{MESSAGES['PLAN_INFO']}\n\n{MESSAGES['PLAN_INFO_SIZE']} {plan['size_gb']} {MESSAGES['GB']}\n{MESSAGES['PLAN_INFO_DAYS']} {plan['days']} {MESSAGES['DAY_EXPIRE']}\n{MESSAGES['PLAN_INFO_PRICE']} {rial_to_toman(plan['price'])} {MESSAGES['TOMAN']}\n\"\"\"\n    if plan['description']:\n        msg += f\"\"\"{MESSAGES['PLAN_INFO_DESC']} {plan['description']}\"\"\"\n    return msg\n    \n\n# Owner Info Template (For Payment)\ndef owner_info_template(card_number, card_holder_name, price, header=\"\"):\n    card_number = card_number if card_number else \"-\"\n    card_holder_name = card_holder_name if card_holder_name else \"-\"\n\n    if LANG == 'FA':\n        return f\"\"\"\n{header}\n\n💰لطفا دقیقا مبلغ: <code>{price}</code> {MESSAGES['RIAL']}\n💴معادل: {rial_to_toman(price)} {MESSAGES['TOMAN']}\n💳را به شماره کارت: <code>{card_number}</code>\n👤به نام <b>{card_holder_name}</b> واریز کنید.\n\n❗️بعد از واریز مبلغ، اسکرین شات از تراکنش را برای ما ارسال کنید.\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\n{header}\n\n💰Please pay exactly: <code>{price}</code> {MESSAGES['TOMAN']}\n💳To card number: <code>{card_number}</code>\nCard owner <b>{card_holder_name}</b>\n\n❗️After paying the amount, send us a screenshot of the transaction.\n\"\"\"\n\n\n# Payment Received Template - Send to Admin\ndef payment_received_template(payment,user, header=\"\", footer=\"\"):\n    username = f\"@{user['username']}\" if user['username'] else MESSAGES['NOT_SET']\n    name = user['full_name'] if user['full_name'] else user['telegram_id']\n\n\n    if LANG == 'FA':\n        return f\"\"\"\n{header}\n\nشناسه تراکنش: <code>{payment['id']}</code>\nمبلغ تراکنش: <b>{rial_to_toman(payment['payment_amount'])}</b> {MESSAGES['TOMAN']}\n{MESSAGES['INFO_USER_NAME']} <b>{name}</b>\n{MESSAGES['INFO_USER_USERNAME']} {username}\n{MESSAGES['INFO_USER_NUM_ID']} {user['telegram_id']}\n---------------------\n⬇️درخواست افزایش موجودی کیف پول⬇️\n\n{footer}\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\n{header}\n\nPayment number: <b>{payment['id']}</b>\nPaid amount: <b>{payment['payment_amount']}</b> {MESSAGES['TOMAN']}\n{MESSAGES['INFO_USER_NAME']} <b>{name}</b>\n{MESSAGES['INFO_USER_USERNAME']} {username}\n{MESSAGES['INFO_USER_NUM_ID']} {user['telegram_id']}\n---------------------\n⬇️Request to increase wallet balance⬇️\n\n\"\"\"\n\n\n# Help Guide Template\ndef connection_help_template(header=\"\"):\n    if LANG == 'FA':\n        return f\"\"\"\n{header}\n\n⭕️ نرم افزار های مورد نیاز برای اتصال به کانفیگ\n    \n📥اندروید:\n<a href='https://play.google.com/store/apps/details?id=com.v2ray.ang'>V2RayNG</a>\n<a href='https://play.google.com/store/apps/details?id=ang.hiddify.com'>HiddifyNG</a>\n\n📥آی او اس:\n<a href='https://apps.apple.com/us/app/streisand/id6450534064'>Streisand</a>\n<a href='https://apps.apple.com/us/app/foxray/id6448898396'>Foxray</a>\n<a href='https://apps.apple.com/us/app/v2box-v2ray-client/id6446814690'>V2box</a>\n\n📥ویندوز:\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\n<a href='https://github.com/2dust/v2rayN/releases'>V2rayN</a>\n<a href='https://github.com/hiddify/HiddifyN/releases'>HiddifyN</a>\n\n📥مک و لینوکس:\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\n\"\"\"\n\n    elif LANG == 'EN':\n        return f\"\"\"\n{header}\n\n⭕️Required software for connecting to config\n\n📥Android:\n<a href='https://play.google.com/store/apps/details?id=com.v2ray.ang'>V2RayNG</a>\n<a href='https://play.google.com/store/apps/details?id=ang.hiddify.com'>HiddifyNG</a>\n\n📥iOS:\n<a href='https://apps.apple.com/us/app/streisand/id6450534064'>Streisand</a>\n<a href='https://apps.apple.com/us/app/foxray/id6448898396'>Foxray</a>\n<a href='https://apps.apple.com/us/app/v2box-v2ray-client/id6446814690'>V2box</a>\n\n📥Windows:\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\n<a href='https://github.com/2dust/v2rayN/releases'>V2rayN</a>\n<a href='https://github.com/hiddify/HiddifyN/releases'>HiddifyN</a>\n\n📥Mac and Linux:\n<a href='https://github.com/MatsuriDayo/nekoray/releases'>Nekoray</a>\n\"\"\"\n\n\n# Support Info Template\n# def support_template(owner_info, header=\"\"):\n#     username = None\n#     owner_info = all_configs_settings()\n#     if owner_info:\n#         username = owner_info['support_username'] if owner_info['support_username'] else \"-\"\n#     else:\n#         username = \"-\"\n\n#     if LANG == 'FA':\n#         return f\"\"\"\n# {header}\n\n# 📞پشتیبانی: {username}\n# \"\"\"\n\n#     elif LANG == 'EN':\n#         return f\"\"\"\n# {header}\n\n# 📞Supporter: {username}\n# \"\"\"\n\n\n# Alert Package Days Template\ndef package_days_expire_soon_template(sub_id, remaining_days):\n    if LANG == 'FA':\n        return f\"\"\"\nتنها {remaining_days} روز تا اتمام اعتبار پکیج شما باقی مانده است.\nلطفا برای تمدید پکیج اقدام کنید.\nشناسه پکیج شما: <code>{sub_id}</code>\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\nOnly {remaining_days} days left until your package expires.\nPlease purchase a new package.\nYour package ID: <code>{sub_id}</code>\n\"\"\"\n\n\n# Alert Package Size Template\ndef package_size_end_soon_template(sub_id, remaining_size):\n    if LANG == 'FA':\n        return f\"\"\"\nتنها {remaining_size} گیگابایت تا اتمام اعتبار پکیج شما باقی مانده است.\nلطفا برای تمدید پکیج اقدام کنید.\n\nشناسه پکیج شما: <code>{sub_id}</code>\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\nOnly {remaining_size} GB left until your package expires.\nPlease renewal package.\nYour package ID: <code>{sub_id}</code>\n\"\"\"\n\ndef renewal_unvalable_template(settings):\n    if LANG == 'FA':\n        return f\"\"\"\n🛑در حال حاضر شما امکان تمدید اشتراک خود را ندارید.\nجهت تمدید اشتراک باید یکی از شروط زیر برقرار باشد:\n1- کمتر از {settings['advanced_renewal_days']} روز تا اتمام اشتراک شما باقی مانده باشد.\n2- حجم باقی مانده اشتراک شما کمتر از {settings['advanced_renewal_usage']} گیگابایت باشد.\n\"\"\"\n    elif LANG == 'EN':\n        return f\"\"\"\n🛑You cannot renew your subscription at this time.\nTo renew your subscription, one of the following conditions must be met:\n1- Less than {settings['advanced_renewal_days']} days left until your subscription expires.\n2- The remaining volume of your subscription is less than {settings['advanced_renewal_usage']} GB.\n\"\"\"\n"
  },
  {
    "path": "Utils/api.py",
    "content": "# from config import *\n# from Utils.utils import *\nimport json\nimport logging\nfrom urllib.parse import urlparse\nimport datetime\nimport requests\nfrom config import API_PATH\nimport Utils\n\n\n# Document: https://github.com/hiddify/hiddify-config/discussions/3209\n# It not in uses now, but it will be used in the future.\n\n\n\ndef select(url, endpoint=\"/user/\"):\n    try:\n        response = requests.get(url + endpoint)\n        res = Utils.utils.dict_process(url, Utils.utils.users_to_dict(response.json()))\n        return res\n    except Exception as e:\n        logging.error(\"API error: %s\" % e)\n        return None\n\ndef find(url, uuid, endpoint=\"/user/\"):\n    try:\n        response = requests.get(url + endpoint, data={\"uuid\": uuid})\n        jr = response.json()\n        if len(jr) != 1:\n            # Search for uuid\n            for user in jr:\n                if user['uuid'] == uuid:\n                    return user\n            return None\n        return jr[0]\n    except Exception as e:\n        logging.error(\"API error: %s\" % e)\n        return None\n\ndef insert(url, name, usage_limit_GB, package_days, last_reset_time=None, added_by_uuid=None, mode=\"no_reset\",\n            last_online=\"1-01-01 00:00:00\", telegram_id=None,\n            comment=None, current_usage_GB=0, start_date=None, endpoint=\"/user/\"):\n    import uuid\n    uuid = str(uuid.uuid4())\n    # last_online = '1-01-01 00:00:00'\n    # expiry_time = (datetime.datetime.now() + datetime.timedelta(days=180)).strftime(\"%Y-%m-%d\")\n    # start_date = None\n    # current_usage_GB = 0\n    added_by_uuid = urlparse(url).path.split('/')[2]\n    last_reset_time = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n\n    data = {\n        \"uuid\": uuid,\n        \"name\": name,\n        \"usage_limit_GB\": usage_limit_GB,\n        \"package_days\": package_days,\n        \"added_by_uuid\": added_by_uuid,\n        \"last_reset_time\": last_reset_time,\n        \"mode\": mode,\n        \"last_online\": last_online,\n        \"telegram_id\": telegram_id,\n        \"comment\": comment,\n        \"current_usage_GB\": current_usage_GB,\n        \"start_date\": start_date\n    }\n    jdata = json.dumps(data)\n    try:\n        response = requests.post(url + endpoint, data=jdata, headers={'Content-Type': 'application/json'})\n        return uuid\n    except Exception as e:\n        logging.error(\"API error: %s\" % e)\n        return None\n\ndef update(url, uuid, endpoint=\"/user/\", **kwargs, ):\n    try:\n        # use api.insert to update, replace new data with old data\n        user = find(url, uuid)\n        if not user:\n            return None\n        for key in kwargs:\n            user[key] = kwargs[key]\n        response = requests.post(url + endpoint, data=json.dumps(user),\n                                    headers={'Content-Type': 'application/json'})\n        return uuid\n    except Exception as e:\n        logging.error(\"API error: %s\" % e)\n        return None\n\n"
  },
  {
    "path": "Utils/serverInfo.py",
    "content": "# Thanks to https://github.com/m-mjd/hiddybot_info_severs\nimport sqlite3\nfrom urllib.parse import urlparse\nimport requests\nfrom Database.dbManager import USERS_DB\n\n\ndef scrape_data_from_json_url(url):\n    try:\n        response = requests.get(url)\n        response.raise_for_status()\n\n        # Parse JSON data\n        json_data = response.json()\n\n        # Extract information from JSON using the shared function\n        extracted_data = json_template(json_data)\n\n        return extracted_data\n\n    except requests.exceptions.RequestException as e:\n        print(f\"Error: {e}\")\n        return None\n\n\ndef json_template(data):\n    system_stats = data.get('stats', {}).get('system', {})\n    top5_stats = data.get('stats', {}).get('top5', {})\n    usage_history = data.get('usage_history', {})\n    bytes_recv = system_stats.get('bytes_recv')\n    bytes_recv_cumulative = system_stats.get('bytes_recv_cumulative')\n    bytes_sent = system_stats.get('bytes_sent')\n    bytes_sent_cumulative = system_stats.get('bytes_sent_cumulative')\n    cpu_percent = system_stats.get('cpu_percent')\n    number_of_cores = system_stats.get('num_cpus')\n    disk_total = system_stats.get('disk_total')\n    disk_used = system_stats.get('disk_used')\n    ram_total = system_stats.get('ram_total')\n    ram_used = system_stats.get('ram_used')\n    total_upload_server = system_stats.get('net_sent_cumulative_GB')\n    total_download_server = system_stats.get('net_total_cumulative_GB')\n    hiddify_used = system_stats.get('hiddify_used')\n    load_avg_15min = system_stats.get('load_avg_15min')\n    load_avg_1min = system_stats.get('load_avg_1min')\n    load_avg_5min = system_stats.get('load_avg_5min')\n    total_connections = system_stats.get('total_connections')\n    total_unique_ips = system_stats.get('total_unique_ips')\n    cpu_top5 = top5_stats.get('cpu', [])\n    memory_top5 = top5_stats.get('memory', [])\n    ram_top5 = top5_stats.get('ram', [])\n    online_last_24h = usage_history.get('h24', {}).get('online')\n    usage_last_24h = usage_history.get('h24', {}).get('usage')\n    online_last_30_days = usage_history.get('last_30_days', {}).get('online')\n    usage_last_30_days = usage_history.get('last_30_days', {}).get('usage')\n    online_last_5min = usage_history.get('m5', {}).get('online')\n    usage_last_5min = usage_history.get('m5', {}).get('usage')\n    online_today = usage_history.get('today', {}).get('online')\n    usage_today = usage_history.get('today', {}).get('usage')\n    online_total = usage_history.get('total', {}).get('online')\n    usage_total = usage_history.get('total', {}).get('usage')\n    total_users = usage_history.get('total', {}).get('users')\n    online_yesterday = usage_history.get('yesterday', {}).get('online')\n    usage_yesterday = usage_history.get('yesterday', {}).get('usage')\n\n    return {\n        'bytes_recv': bytes_recv,\n        'bytes_recv_cumulative': bytes_recv_cumulative,\n        'bytes_sent': bytes_sent,\n        'bytes_sent_cumulative': bytes_sent_cumulative,\n        'cpu_percent': cpu_percent,\n        'number_of_cores': number_of_cores,\n        'disk_total': disk_total,\n        'disk_used': disk_used,\n        'ram_total': ram_total,\n        'ram_used': ram_used,\n        'total_upload_server': total_upload_server,\n        'total_download_server': total_download_server,\n        'hiddify_used': hiddify_used,\n        'load_avg_15min': load_avg_15min,\n        'load_avg_1min': load_avg_1min,\n        'load_avg_5min': load_avg_5min,\n        'total_connections': total_connections,\n        'total_unique_ips': total_unique_ips,\n        'cpu_top5': cpu_top5,\n        'memory_top5': memory_top5,\n        'ram_top5': ram_top5,\n        'online_last_24h': online_last_24h,\n        'usage_last_24h': usage_last_24h,\n        'online_last_30_days': online_last_30_days,\n        'usage_last_30_days': usage_last_30_days,\n        'online_last_5min': online_last_5min,\n        'usage_last_5min': usage_last_5min,\n        'online_today': online_today,\n        'usage_today': usage_today,\n        'online_total': online_total,\n        'usage_total': usage_total,\n        'total_users': total_users,\n        'online_yesterday': online_yesterday,\n        'usage_yesterday': usage_yesterday,\n    }\n\n\n\ndef server_status_template(result, server_name):\n    lline = (32 * \"-\")\n    \n    bytes_recv = result.get('bytes_recv', 'N/A')\n    bytes_recv_cumulative = result.get('bytes_recv_cumulative', 'N/A')\n    bytes_sent = result.get('bytes_sent', 'N/A')\n    bytes_sent_cumulative = result.get('bytes_sent_cumulative', 'N/A')\n    cpu_percent = result.get('cpu_percent', 'N/A')\n    number_of_cores = result.get('number_of_cores', 'N/A')\n    disk_total = result.get('disk_total', 'N/A')\n    disk_used = result.get('disk_used', 'N/A')\n    ram_total = result.get('ram_total', 'N/A')\n    ram_used = result.get('ram_used', 'N/A')\n    total_upload_server = result.get('total_upload_server', 'N/A')\n    total_download_server = result.get('total_download_server', 'N/A')\n    online_last_24h = result.get('online_last_24h', 'N/A')\n    usage_last_24h = result.get('usage_last_24h', 'N/A')\n    usage_last_24h = f\"{usage_last_24h / (1024 ** 3):.2f} GB\" if usage_last_24h != 'N/A' else 'N/A'\n    online_last_30_days = result.get('online_last_30_days', 'N/A')\n    usage_last_30_days = result.get('usage_last_30_days', 'N/A')\n    usage_last_30_days = f\"{usage_last_30_days / (1024 ** 3):.2f} GB\" if usage_last_30_days != 'N/A' else 'N/A'\n    online_last_5min = result.get('online_last_5min', 'N/A')\n    usage_last_5min = result.get('usage_last_5min', 'N/A')\n    online_today = result.get('online_today', 'N/A')\n    usage_today = result.get('usage_today', 'N/A')\n    usage_today = f\"{usage_today / (1024 ** 3):.2f} GB\" if usage_today != 'N/A' else 'N/A'\n    online_total = result.get('online_total', 'N/A')\n    usage_total = result.get('usage_total', 'N/A')\n    usage_total = f\"{usage_total / (1024 ** 3):.2f} GB\" if usage_total != 'N/A' else 'N/A'\n    total_users = result.get('total_users', 'N/A')\n    online_yesterday = result.get('online_yesterday', 'N/A')\n    usage_yesterday = result.get('usage_yesterday', 'N/A')\n    hiddify_used = result.get('hiddify_used', 'N/A')\n    load_avg_15min = result.get('load_avg_15min', 'N/A')\n    load_avg_1min = result.get('load_avg_1min', 'N/A')\n    load_avg_5min = result.get('load_avg_5min', 'N/A')\n    total_connections = result.get('total_connections', 'N/A')\n    total_unique_ips = result.get('total_unique_ips', 'N/A')\n    cpu_top5 = result.get('cpu_top5', 'N/A')\n    memory_top5 = result.get('memory_top5', 'N/A')\n    ram_top5 = result.get('ram_top5', 'N/A')\n    # Calculate percentage for RAM and Disk\n    ram_percent = (ram_used / ram_total) * \\\n        100 if ram_total != 'N/A' and ram_total != 0 else 'N/A'\n    disk_percent = (disk_used / disk_total) * \\\n        100 if disk_total != 'N/A' and disk_total != 0 else 'N/A'\n    # Format bytes with appropriate units\n    formatted_bytes_recv = f\"{bytes_recv / (1024 ** 2):.2f} MB\" if bytes_recv != 'N/A' else 'N/A'\n    formatted_bytes_sent = f\"{bytes_sent / (1024 ** 2):.2f} MB\" if bytes_sent != 'N/A' else 'N/A'\n    # Add information for all servers\n    return f\"<b>Server: {server_name}</b>\\n{lline}\\n\" \\\n                       f\"<b>SYSTEM INFO</b>\\n\"\\\n                       f\"CPU: {cpu_percent}% - {number_of_cores} CORE\\n\" \\\n                       f\"RAM: {ram_used:.2f} GB / {ram_total:.2f} GB ({ram_percent:.2f}%)\\n\" \\\n                       f\"DISK: {disk_used:.2f} GB / {disk_total:.2f} GB  ({disk_percent:.2f}%)\\n\\n\" \\\n                       f\"<b>NETWORK INFO</b>\\n\"\\\n                       f\"Total Users: {total_users} User\\n\" \\\n                       f\"Usage (Today): {usage_today}\\n\" \\\n                       f\"Online (Now): {online_last_5min} User\\n\" \\\n                       f\"Now Network Received: {formatted_bytes_recv}\\n\" \\\n                       f\"Now Network Sent: {formatted_bytes_sent}\\n\" \\\n                       f\"Online (Today): {online_today} User\\n\" \\\n                       f\"Online(30 Days): {online_last_30_days} User\\n\" \\\n                       f\"Usage(30 Days): {usage_last_30_days}\\n\"\\\n                       f\"Total Download (Server): {total_download_server:.2f} GB\\n\" \\\n                       f\"Total Upload (Server): {total_upload_server:.2f} GB\\n\" \\\n\ndef get_server_status(server_row):\n    server_name = server_row['title']\n    server_url = server_row['url']\n    data = scrape_data_from_json_url(f\"{server_url}/admin/get_data/\")\n    if not data:\n        return False\n    txt = server_status_template(data, server_name)\n    return txt\n    "
  },
  {
    "path": "Utils/utils.py",
    "content": "# Description: API for connecting to the panel\nimport json\nimport logging\nimport os\nimport random\nimport string\nfrom io import BytesIO\nimport re\nfrom datetime import datetime\nfrom urllib.parse import urlparse\nfrom Database.dbManager import USERS_DB\nimport psutil\nimport qrcode\nimport requests\nfrom config import PANEL_URL, BACKUP_LOC, CLIENT_TOKEN, USERS_DB_LOC,RECEIPTIONS_LOC,BOT_BACKUP_LOC, API_PATH,LOG_DIR\nimport AdminBot.templates\nfrom Utils import api\nfrom version import __version__\nimport zipfile\nimport shutil\n# Global variables\n# Make Session for requests\nsession = requests.session()\n# Base panel URL - example: https://panel.example.com\nBASE_URL = urlparse(PANEL_URL).scheme + \"://\" + urlparse(PANEL_URL).netloc\n\n\n# Users directory in panel\n# USERS_DIR = \"/admin/user/\"\n\n\n# Get request - return request object\ndef get_request(url):\n    logging.info(f\"GET Request to {privacy_friendly_logging_request(url)}\")\n    global session\n    try:\n        req = session.get(url)\n        logging.info(f\"GET Request to {privacy_friendly_logging_request(url)} - Status Code: {req.status_code}\")\n        return req\n    except requests.exceptions.ConnectionError as e:\n        logging.exception(f\"Connection Exception: {e}\")\n        return False\n    except requests.exceptions.Timeout as e:\n        logging.exception(f\"Timeout Exception: {e}\")\n        return False\n    except requests.exceptions.RequestException as e:\n        logging.exception(f\"General Connection Exception: {e}\")\n        return False\n    except Exception as e:\n        logging.exception(f\"General Exception: {e}\")\n        return False\n\n\n# Post request - return request object\ndef post_request(url, data):\n    logging.info(f\"POST Request to {privacy_friendly_logging_request(url)} - Data: {data}\")\n    global session\n    try:\n        req = session.post(url, data=data)\n        return req\n    except requests.exceptions.ConnectionError as e:\n        logging.exception(f\"Connection Exception: {e}\")\n        return False\n    except requests.exceptions.Timeout as e:\n        logging.exception(f\"Timeout Exception: {e}\")\n        return False\n    except requests.exceptions.RequestException as e:\n        logging.exception(f\"General Connection Exception: {e}\")\n        return False\n    except Exception as e:\n        logging.exception(f\"General Exception: {e}\")\n        return False\n\n\ndef users_to_dict(users_dict):\n    if not users_dict:\n        return False\n    users_array = []\n    for user in users_dict:\n        users_array.append({'uuid': user['uuid'], 'name': user['name'], 'last_online': user['last_online'],\n                            'expiry_time': None,\n                            'usage_limit_GB': user['usage_limit_GB'], 'package_days': user['package_days'],\n                            'mode': user['mode'],\n                            'monthly': None, 'start_date': user['start_date'],\n                            'current_usage_GB': user['current_usage_GB'],\n                            'last_reset_time': user['last_reset_time'], 'comment': user['comment'],\n                            'telegram_id': user['telegram_id'],\n                            'added_by': user['added_by_uuid'], 'max_ips': None, 'enable': None})\n    return users_array\n\n\n# Change telegram user data format\ndef Telegram_users_to_dict(Tel_users_dict):\n    if not Tel_users_dict:\n        return False\n    users_array = []\n    for user in Tel_users_dict:\n        users_array.append({'id': user[0], 'telegram_id': user[1], 'created_at': user[3], })\n    return users_array\n\n\n# Calculate remaining days\ndef calculate_remaining_days(start_date, package_days):\n    import datetime\n    import pytz\n\n    datetime_iran = datetime.datetime.now(pytz.timezone('Asia/Tehran'))\n    datetime_iran = datetime_iran.replace(tzinfo=None)\n    if start_date is None:\n        return package_days\n    start_date = datetime.datetime.strptime(start_date, \"%Y-%m-%d\")\n    # remaining_days = package_days - (datetime.datetime.now() - start_date).days\n    remaining_days = package_days - (datetime_iran - start_date).days + 1\n    if remaining_days < 0:\n        return 0\n    return remaining_days\n\n\n# Calculate remaining usage\ndef calculate_remaining_usage(usage_limit_GB, current_usage_GB):\n    remaining_usage = usage_limit_GB - current_usage_GB\n    return round(remaining_usage, 2)\n\n\n# Calculate last online time\ndef calculate_remaining_last_online(last_online_date_time):\n    import datetime\n    if last_online_date_time == \"0001-01-01 00:00:00.000000\" or last_online_date_time == \"1-01-01 00:00:00\":\n        return AdminBot.content.MESSAGES['NEVER']\n    # last_online_date_time = datetime.datetime.strptime(last_online_date_time, \"%Y-%m-%d %H:%M:%S.%f\")\n    last_online_date_time = datetime.datetime.strptime(last_online_date_time, \"%Y-%m-%d %H:%M:%S\")\n    last_online_time = (datetime.datetime.now() - last_online_date_time)\n    last_online = AdminBot.templates.last_online_time_template(last_online_time)\n    return last_online\n\n\n# Process users data - return list of users\ndef dict_process(url, users_dict, sub_id=None, server_id=None):\n    BASE_URL = urlparse(url,).scheme + \"://\" + urlparse(url,).netloc\n    logging.info(f\"Parse users page\")\n    if not users_dict:\n        return False\n    users_list = []\n    for user in users_dict:\n        users_list.append({\n            \"name\": user['name'],\n            \"usage\": {\n                'usage_limit_GB': round(user['usage_limit_GB'], 2),\n                'current_usage_GB': round(user['current_usage_GB'], 2),\n                'remaining_usage_GB': calculate_remaining_usage(user['usage_limit_GB'], user['current_usage_GB'])\n            },\n            \"remaining_day\": calculate_remaining_days(user['start_date'], user['package_days']),\n            \"comment\": user['comment'],\n            \"last_connection\": calculate_remaining_last_online(user['last_online']) if user['last_online'] else None,\n            \"uuid\": user['uuid'],\n            \"link\": f\"{BASE_URL}/{urlparse(url).path.split('/')[1]}/{user['uuid']}/\",\n            \"mode\": user['mode'],\n            \"enable\": user['enable'],\n            \"sub_id\": sub_id,\n            \"server_id\": server_id\n        })\n\n    return users_list\n\n\n# Get single user info - return dict of user info\ndef user_info(url, uuid):\n    logging.info(f\"Get info of user single user - {uuid}\")\n    lu = api.select(url)\n    if not lu:\n        return False\n    for user in lu:\n        if user['uuid'] == uuid:\n            return user\n    return False\n\n\n# Get sub links - return dict of sub links\ndef sub_links(uuid, url= None):\n    if not url:\n        non_order_users = USERS_DB.find_non_order_subscription(uuid=uuid)\n        order_users = USERS_DB.find_order_subscription(uuid=uuid)\n        if order_users:\n            order_user = order_users[0]\n            servers = USERS_DB.find_server(id=order_user['server_id'])\n            if servers:\n                server = servers[0]\n                url = server['url']\n        elif non_order_users:\n            non_order_user = non_order_users[0]\n            servers = USERS_DB.find_server(id=non_order_user['server_id'])\n            if servers:\n                server = servers[0]\n                url = server['url']\n        # else:\n        #     servers = USERS_DB.select_servers()\n        #     if servers:\n        #         for server in servers:\n        #             users_list = api.find(server['url'] + API_PATH, uuid)\n        #             if users_list:\n        #                 url = server['url']\n        #                 break\n    BASE_URL = urlparse(url).scheme + \"://\" + urlparse(url).netloc\n    logging.info(f\"Get sub links of user - {uuid}\")\n    sub = {}\n    PANEL_DIR = urlparse(url).path.split('/')\n    # Clash open app: clash://install-config?url=\n    # Hidden open app: clashmeta://install-config?url=\n    sub['clash_configs'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/clash/all.yml\"\n    sub['hiddify_configs'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/clash/meta/all.yml\"\n    sub['sub_link'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/all.txt\"\n    sub['sub_link_b64'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/all.txt?base64=True\"\n    # Add in v8.0 Hiddify\n    sub['sub_link_auto'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/sub/?asn=unknown\"\n    sub['sing_box_full'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/full-singbox.json?asn=unknown\"\n    sub['sing_box'] = f\"{BASE_URL}/{PANEL_DIR[1]}/{uuid}/singbox.json?asn=unknown\"\n    return sub\n\n\n# Parse sub links\ndef sub_parse(sub):\n    logging.info(f\"Parse sub links\")\n    res = get_request(sub)\n    if not res or res.status_code != 200:\n        return False\n\n    urls = re.findall(r'(vless:\\/\\/[^\\n]+)|(vmess:\\/\\/[^\\n]+)|(trojan:\\/\\/[^\\n]+)', res.text)\n\n    config_links = {\n        'vless': [],\n        'vmess': [],\n        'trojan': []\n    }\n    for url in urls:\n        if url[0]:\n            match = re.search(r'#(.+)$', url[0])\n            if match:\n                vless_title = match.group(1).replace(\"%20\", \" \")\n                config_links['vless'].append([url[0], vless_title])\n        elif url[1]:\n            config = url[1].replace(\"vmess://\", \"\")\n            config_parsed = base64decoder(config)\n            if config_parsed:\n                vmess_title = config_parsed['ps'].replace(\"%20\", \" \")\n                config_links['vmess'].append([url[1], vmess_title])\n        elif url[2]:\n            match = re.search(r'#(.+)$', url[2])\n            if match:\n                trojan_title = match.group(1).replace(\"%20\", \" \")\n                trojan_sni = re.search(r'sni=([^&]+)', url[2])\n                if trojan_sni:\n                    if trojan_sni.group(1) == \"fake_ip_for_sub_link\":\n                        continue\n                config_links['trojan'].append([url[2], match.group(1)])\n        \n    return config_links\n\n\n# Backup panel\ndef backup_panel(url):\n    logging.info(f\"Backup panel\")\n    BASE_URL = urlparse(url,).scheme + \"://\" + urlparse(url,).netloc\n    dir_panel = urlparse(url).path.split('/')\n    backup_url = f\"{BASE_URL}/{dir_panel[1]}/{dir_panel[2]}/admin/backup/backupfile/\"\n\n    backup_req = get_request(backup_url)\n    if not backup_req or backup_req.status_code != 200:\n        return False\n\n    now = datetime.now()\n    dt_string = now.strftime(\"%d-%m-%Y_%H-%M-%S\")\n\n    file_name = f\"Backup_{urlparse(url,).netloc}_{dt_string}.json\"\n\n    file_name = os.path.join(BACKUP_LOC, file_name)\n    if not os.path.exists(BACKUP_LOC):\n        os.makedirs(BACKUP_LOC)\n    with open(file_name, 'w+') as f:\n        f.write(backup_req.text)\n    return file_name\n\n# zip an array of files\ndef zip_files(files, zip_file_name,path=None):\n    if path:\n        zip_file_name = os.path.join(path, zip_file_name)\n    with zipfile.ZipFile(zip_file_name, 'w', zipfile.ZIP_DEFLATED) as zip_file:\n        for file in files:\n            # Get the base name of the file (i.e. the file name without the parent folders)\n            base_name = os.path.basename(file)\n            # Write the file to the zip archive with the base name as the arcname\n            zip_file.write(file, arcname=base_name)\n    return zip_file_name\n\n# full backup\ndef full_backup():\n    files = []\n    servers = USERS_DB.select_servers()\n    for server in servers:\n        file_name = backup_panel(server['url'])\n        if file_name:\n            files.append(file_name)\n    backup_bot = backup_json_bot()\n    if backup_bot:\n        files.append(backup_bot)\n    if files:\n        now = datetime.now()\n        dt_string = now.strftime(\"%d-%m-%Y_%H-%M-%S\")\n        zip_title = f\"Backup_{dt_string}.zip\"\n        zip_file_name = zip_files(files, zip_title,path=BACKUP_LOC)\n        if zip_file_name:\n            return zip_file_name\n    return False\n\n# Extract UUID from config\ndef extract_uuid_from_config(config):\n    logging.info(f\"Extract UUID from config\")\n    uuid_pattern = r\"([0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})\"\n    match = re.search(uuid_pattern, config)\n\n    if match:\n        uuid = match.group(1)\n        return uuid\n    else:\n        return None\n\n\n# System status\ndef system_status():\n    cpu_usage = psutil.cpu_percent()\n    ram_usage = psutil.virtual_memory().percent\n    disk_usage = psutil.disk_usage('/').percent\n    return {\n        'cpu': cpu_usage,\n        'ram': ram_usage,\n        'disk': disk_usage\n    }\n\n\n# Search user by name\ndef search_user_by_name(url, name):\n    # users = dict_process(users_to_dict(ADMIN_DB.select_users()))\n    users = api.select(url)\n    if not users:\n        return False\n    res = []\n    for user in users:\n        if name.lower() in user['name'].lower():\n            res.append(user)\n    if res:\n        return res\n    return False\n\n\n# Search user by uuid\ndef search_user_by_uuid(url, uuid):\n    # users = dict_process(users_to_dict(ADMIN_DB.select_users()))\n    users = api.select(url)\n    if not users:\n        return False\n    for user in users:\n        if user['uuid'] == uuid:\n            return user\n    return False\n\n\n# Base64 decoder\ndef base64decoder(s):\n    import base64\n    try:\n        conf = base64.b64decode(s).decode(\"utf-8\")\n        conf = json.loads(conf)\n    except Exception as e:\n        conf = False\n\n    return conf\n\n\n# Search user by config\ndef search_user_by_config(url, config):\n    if config.startswith(\"vmess://\"):\n        config = config.replace(\"vmess://\", \"\")\n        config = base64decoder(config)\n        if config:\n            uuid = config['id']\n            user = search_user_by_uuid(url, uuid)\n            if user:\n                return user\n    uuid = extract_uuid_from_config(config)\n    if uuid:\n        user = search_user_by_uuid(url, uuid)\n        if user:\n            return user\n    return False\n\n\n# Check text is it config or sub\ndef is_it_config_or_sub(config):\n    if config.startswith(\"vmess://\"):\n        config = config.replace(\"vmess://\", \"\")\n        config = base64decoder(config)\n        if config:\n            return config['id']\n    uuid = extract_uuid_from_config(config)\n    if uuid:\n        return uuid\n\n\n# Users bot add plan\ndef users_bot_add_plan(size, days, price, server_id,description=None):\n    if not CLIENT_TOKEN:\n        return False\n    # randon 4 digit number\n    plan_id = random.randint(10000, 99999)\n    plan_status = USERS_DB.add_plan(plan_id, size, days, price, server_id,description=description)\n    if not plan_status:\n        return False\n    return True\n\n#--------------------------Server area ----------------------------\n# add server\ndef add_server(url, user_limit, title=None, description=None, status=True, default_server=False):\n    # randon 5 digit number\n    #server_id = random.randint(10000, 99999)\n    server_status = USERS_DB.add_server(url, user_limit, title, description, status, default_server)\n    if not server_status:\n        return False\n    return True\n\n\n# Check user is expired\ndef is_user_expired(user):\n    if user['remaining_day'] == 0:\n        return True\n    return False\n\n\n# Expired users list\ndef expired_users_list(users):\n    expired_users = []\n    for user in users:\n        if is_user_expired(user):\n            expired_users.append(user)\n    return expired_users\n\n\n# Text to QR code\ndef txt_to_qr(txt):\n    qr = qrcode.QRCode(\n        version=1,\n        error_correction=qrcode.constants.ERROR_CORRECT_L,\n        box_size=10,\n        border=1,\n    )\n    qr.add_data(txt)\n    qr.make(fit=True, )\n    img_qr = qr.make_image(fill_color=\"black\", back_color=\"white\")\n    stream = BytesIO()\n    img_qr.save(stream)\n    img = stream.getvalue()\n\n    return img\n\n\n# List of users who not ordered from bot (Link Subscription)\ndef non_order_user_info(telegram_id):\n    users_list = []\n    non_ordered_subscriptions = USERS_DB.find_non_order_subscription(telegram_id=telegram_id)\n    if non_ordered_subscriptions:\n        for subscription in non_ordered_subscriptions:\n            server_id = subscription['server_id']\n            server = USERS_DB.find_server(id=server_id)\n            if server:\n                server = server[0]\n                #if server['status']:\n                URL = server['url'] + API_PATH\n                non_order_user = api.find(URL, subscription['uuid'])\n                if non_order_user:\n                    non_order_user = users_to_dict([non_order_user])\n                    non_order_user = dict_process(URL, non_order_user, subscription['id'],server_id)\n                    if non_order_user:\n                        non_order_user = non_order_user[0]\n                        users_list.append(non_order_user)\n    return users_list\n\n\n# List of users who ordered from bot and made payment\ndef order_user_info(telegram_id):\n    users_list = []\n    orders = USERS_DB.find_order(telegram_id=telegram_id)\n    if orders:\n        for order in orders:\n            ordered_subscriptions = USERS_DB.find_order_subscription(order_id=order['id'])\n            if ordered_subscriptions:\n                for subscription in ordered_subscriptions:\n                    server_id = subscription['server_id']\n                    server = USERS_DB.find_server(id=server_id)\n                    if server:\n                        server = server[0]\n                        #if server['status']:\n                        URL = server['url'] + API_PATH\n                        order_user = api.find(URL, subscription['uuid'])\n                        if order_user:\n                            order_user = users_to_dict([order_user])\n                            order_user = dict_process(URL, order_user, subscription['id'], server_id)\n                            if order_user:\n                                order_user = order_user[0]\n                                users_list.append(order_user)\n    return users_list\n\n\n\n# Replace last three characters of a string with random numbers (For Payment)\ndef replace_last_three_with_random(input_string):\n    if len(input_string) <= 3:\n        return input_string  # Not enough characters to replace\n    input_string = int(input_string)\n    input_string += random.randint(1000, 9999)\n    return str(input_string)\n    # random_numbers = ''.join(random.choice(string.digits) for _ in range(3))\n    # modified_string = input_string[:-3] + random_numbers\n    # return modified_string\n\n\n# Privacy-friendly logging - replace your panel url with panel.private.com\ndef privacy_friendly_logging_request(url):\n    url = urlparse(url)\n    url = url.scheme + \"://\" + \"panel.private.com\" + url.path\n    return url\n\n\ndef all_configs_settings():\n    bool_configs = USERS_DB.select_bool_config()\n    int_configs = USERS_DB.select_int_config()\n    str_configs = USERS_DB.select_str_config()\n\n    # all configs to one dict\n    all_configs = {}\n    for config in bool_configs:\n        all_configs[config['key']] = config['value']\n    for config in int_configs:\n        all_configs[config['key']] = config['value']\n    for config in str_configs:\n        all_configs[config['key']] = config['value']\n    return all_configs\n\n\ndef find_order_subscription_by_uuid(uuid):\n    order_subscription = USERS_DB.find_order_subscription(uuid=uuid)\n    non_order_subscription = USERS_DB.find_non_order_subscription(uuid=uuid)\n    if order_subscription:\n        return order_subscription[0]\n    elif non_order_subscription:\n        return non_order_subscription[0]\n    else:\n        return False\n    \ndef is_it_subscription_by_uuid_and_telegram_id(uuid, telegram_id):\n    subs = []\n    flag = False\n    orders = USERS_DB.find_order(telegram_id=telegram_id)\n    if orders:\n        for order in orders:\n            ordered_subscriptions = USERS_DB.find_order_subscription(order_id=order['id'])\n            if ordered_subscriptions:\n                for subscription in ordered_subscriptions:\n                    if subscription['uuid'] == uuid:\n                        flag = True\n                        subs.append(subscription)\n                        break\n            if flag == True:\n                break \n    \n    non_order_subscriptions = USERS_DB.find_non_order_subscription(telegram_id=telegram_id)\n    if non_order_subscriptions:\n        for subscription in non_order_subscriptions:\n            if subscription['uuid'] == uuid:\n                subs.append(subscription)\n                break\n    if subs:\n        return True\n    else:\n        return False\n\n\ndef toman_to_rial(toman):\n    return int(toman) * 10\n\n\ndef rial_to_toman(rial):\n    return \"{:,.0f}\".format(int(int(rial) / 10))\n\n\ndef backup_json_bot():\n    back_dir = BOT_BACKUP_LOC\n    if not os.path.exists(back_dir):\n        os.makedirs(back_dir)\n    bk_json_data = USERS_DB.backup_to_json(back_dir)\n    if not bk_json_data:\n        return False\n    bk_json_data['version'] = __version__\n    now = datetime.now()\n    dt_string = now.strftime(\"%d-%m-%Y_%H-%M-%S\")\n    bk_json_file = os.path.join(back_dir, f\"Backup_Bot_{dt_string}.json\")\n    with open(bk_json_file, 'w+') as f:\n        json.dump(bk_json_data, f, indent=4)\n    zip_file = os.path.join(back_dir, f\"Backup_Bot_{dt_string}.zip\")\n    with zipfile.ZipFile(zip_file, 'w') as zip:\n        zip.write(bk_json_file,os.path.basename(bk_json_file))\n        zip.write(USERS_DB_LOC,os.path.basename(USERS_DB_LOC))\n        for file in os.listdir(RECEIPTIONS_LOC):\n            zip.write(os.path.join(RECEIPTIONS_LOC, file),os.path.join(os.path.basename(RECEIPTIONS_LOC),file))\n    os.remove(bk_json_file)\n    return zip_file\n\n\ndef restore_json_bot(file):\n    extract_path = os.path.join(BOT_BACKUP_LOC, \"tmp\", os.path.basename(file).replace(\".zip\", \"\"))\n    if not os.path.exists(file):\n        return False\n    if not file.endswith(\".zip\"):\n        return False\n    try:\n        if not os.path.exists(extract_path):\n            os.makedirs(extract_path)\n    except Exception as e:\n        logging.exception(f\"Exception: {e}\")\n        return False\n    try:\n        with zipfile.ZipFile(file, 'r') as outer_zip:\n            # Iterate through all entries in the outer zip\n            for entry in outer_zip.namelist():\n                # Check if the entry is a zip file\n                if entry.lower().endswith('.zip'):\n                    nested_zip_filename = entry\n                    # Extract the nested zip file\n                    with outer_zip.open(nested_zip_filename) as nested_zip_file:\n                        # Save the nested zip file to a temporary location\n                        nested_zip_path = os.path.join(extract_path, nested_zip_filename)\n                        with open(nested_zip_path, 'wb') as f:\n                            f.write(nested_zip_file.read())\n\n                        # Extract contents of the nested zip file\n                        with zipfile.ZipFile(nested_zip_path, 'r') as nested_zip:\n                            # Check if the JSON file exists\n                            # select json file\n                            json_filename = None\n                            for file in nested_zip.namelist():\n                                if file.endswith('.json'):\n                                    json_filename = file\n                                    break\n                            if json_filename in nested_zip.namelist():\n                                nested_zip.extractall(extract_path)\n                else:\n                            json_filename = None\n                            for file in outer_zip.namelist():\n                                if file.endswith('.json'):\n                                    json_filename = file\n                                    break\n                            if json_filename in outer_zip.namelist():\n                                outer_zip.extractall(extract_path)\n    except Exception as e:\n        logging.exception(f\"Exception: {e}\")\n        return False\n                \n            \n    bk_json_file = os.path.join(extract_path, os.path.basename(json_filename))\n    # with open(bk_json_file, 'r') as f:\n    #     bk_json_data = json.load(f)\n    status_db = USERS_DB.restore_from_json(bk_json_file)\n    if not status_db:\n        return False\n    if not os.path.exists(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC))):\n        os.mkdir(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC)))\n    # move reception files\n    for file in os.listdir(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC))):\n        try:\n            os.rename(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC), file),\n                    os.path.join(RECEIPTIONS_LOC, file))\n        except Exception as e:\n            logging.exception(f\"Exception: {e}\")\n    try:\n        # # remove tmp folder\n        # os.remove(bk_json_file)\n        # # remove RECEIPTIONS all files\n        # for file in os.listdir(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC))):\n        #     os.remove(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC), file))\n        # os.rmdir(os.path.join(extract_path, os.path.basename(RECEIPTIONS_LOC)))\n        # # romove hidyBot.db\n        # os.remove(os.path.join(extract_path, os.path.basename(USERS_DB_LOC)))\n        shutil.rmtree(extract_path)\n    except Exception as e:\n        logging.exception(f\"Exception: {e}\")\n        return False\n    return True\n\n# Debug Data \ndef debug_data():\n    bk_json_data = USERS_DB.backup_to_json(BOT_BACKUP_LOC)\n    if not bk_json_data:\n        return False\n    \n    bk_json_data['version'] = __version__\n    \n    new_servers = []\n    for server in bk_json_data['servers']:\n        url = privacy_friendly_logging_request(server['url'])\n        server['url'] = url\n        new_servers.append(server)\n    bk_json_data['servers'] = new_servers\n    \n    bk_json_data['str_config'] = [x for x in bk_json_data['str_config'] if x['key'] not in ['bot_token_admin','bot_token_client']]\n    \n    now = datetime.now()\n    dt_string = now.strftime(\"%d-%m-%Y_%H-%M-%S\")\n    bk_json_file = os.path.join(BOT_BACKUP_LOC, f\"DB_Data_{dt_string}.json\")\n    with open(bk_json_file, 'w+') as f:\n        json.dump(bk_json_data, f, indent=4)\n    zip_file = os.path.join(BOT_BACKUP_LOC, f\"Debug_Data_{dt_string}.zip\")\n    with zipfile.ZipFile(zip_file, 'w') as zip:\n        zip.write(bk_json_file,os.path.basename(bk_json_file))\n        if os.path.exists(os.path.join(os.getcwd(),\"bot.log\")):\n            # only send last 1000 lines of log\n            with open(os.path.join(os.getcwd(),\"bot.log\"), 'r') as f:\n                lines = f.readlines()\n                lines = lines[-1000:]\n                with open(os.path.join(os.getcwd(),\"bot.log\"), 'w') as f:\n                    f.writelines(lines)\n            zip.write(\"bot.log\",os.path.basename(\"bot.log\"))\n        if os.path.exists(LOG_DIR):\n            for file in os.listdir(LOG_DIR):\n                zip.write(os.path.join(LOG_DIR, file),file)\n\n    os.remove(bk_json_file)\n    return zip_file\n    "
  },
  {
    "path": "config.py",
    "content": "# Description: Configuration file for the bot\nimport json\nimport logging\nimport os\nfrom urllib.parse import urlparse\nimport requests\nfrom termcolor import colored\n\n# import Utils.utils\nfrom version import __version__\n\n# PANEL_URL, API_PATH = None, None\n\n# Bypass proxy\nos.environ['no_proxy'] = '*'\n\nVERSION = __version__\n\nUSERS_DB_LOC = os.path.join(os.getcwd(), \"Database\", \"hidyBot.db\")\nLOG_DIR = os.path.join(os.getcwd(), \"Logs\")\nLOG_LOC = os.path.join(LOG_DIR, \"hidyBot.log\")\nBACKUP_LOC = os.path.join(os.getcwd(), \"Backup\")\nRECEIPTIONS_LOC = os.path.join(os.getcwd(), \"UserBot\", \"Receiptions\")\nBOT_BACKUP_LOC = os.path.join(os.getcwd(), \"Backup\", \"Bot\")\nAPI_PATH = \"/api/v1\"\nHIDY_BOT_ID = \"@HidyBotGroup\"\n\n# if directories not exists, create it\nif not os.path.exists(LOG_DIR):\n    os.mkdir(LOG_DIR)\nif not os.path.exists(BACKUP_LOC):\n    os.mkdir(BACKUP_LOC)\nif not os.path.exists(BOT_BACKUP_LOC):\n    os.mkdir(BOT_BACKUP_LOC)\nif not os.path.exists(RECEIPTIONS_LOC):\n    os.mkdir(RECEIPTIONS_LOC)\n\n# set logging  \nlogging.basicConfig(handlers=[logging.FileHandler(filename=LOG_LOC,\n                                                  encoding='utf-8', mode='w')],\n                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n                    level=logging.INFO)\n\n\ndef setup_users_db():\n    # global USERS_DB\n    try:\n        if not os.path.exists(USERS_DB_LOC):\n            logging.error(f\"Database file not found in {USERS_DB_LOC} directory!\")\n            with open(USERS_DB_LOC, \"w\") as f:\n                pass\n        # USERS_DB = Database.dbManager.UserDBManager(USERS_DB_LOC)\n    except Exception as e:\n        logging.error(f\"Error while connecting to database \\n Error:{e}\")\n        raise Exception(f\"Error while connecting to database \\nBe in touch with {HIDY_BOT_ID}\")\n    # return USERS_DB\n\n\nsetup_users_db()\nfrom Database.dbManager import UserDBManager\n\n\ndef load_config(db):\n    try:\n        config = db.select_str_config()\n        if not config:\n            db.set_default_configs()\n            config = db.select_str_config()\n        configs = {}\n        for conf in config:\n            configs[conf['key']] = conf['value']\n\n        return configs\n    except Exception as e:\n        logging.error(f\"Error while loading config \\n Error:{e}\")\n        raise Exception(f\"Error while loading config \\nBe in touch with {HIDY_BOT_ID}\")\n\n\ndef load_server_url(db):\n    try:\n        panel_url = db.select_servers()\n        if not panel_url:\n            return None\n        return panel_url[0]['url']\n    except Exception as e:\n        logging.error(f\"Error while loading panel_url \\n Error:{e}\")\n        raise Exception(f\"Error while loading panel_url \\nBe in touch with {HIDY_BOT_ID}\")\n\n\nADMINS_ID, TELEGRAM_TOKEN, CLIENT_TOKEN, PANEL_URL, LANG, PANEL_ADMIN_ID = None, None, None, None, None, None\n\n\ndef set_config_variables(configs, server_url):\n    if not conf['bot_admin_id'] and not conf['bot_token_admin'] and not conf['bot_lang'] or not server_url:\n        print(colored(\"Config is not set! , Please run config.py first\", \"red\"))\n        raise Exception(f\"Config is not set!\\nBe in touch with {HIDY_BOT_ID}\")\n\n    global ADMINS_ID, TELEGRAM_TOKEN, PANEL_URL, LANG, PANEL_ADMIN_ID, CLIENT_TOKEN\n    json_admin_ids = configs[\"bot_admin_id\"]\n    ADMINS_ID = json.loads(json_admin_ids)\n    TELEGRAM_TOKEN = configs[\"bot_token_admin\"]\n    try:\n        CLIENT_TOKEN = configs[\"bot_token_client\"]\n    except KeyError:\n        CLIENT_TOKEN = None\n\n    if CLIENT_TOKEN:\n        setup_users_db()\n    PANEL_URL = server_url\n    LANG = configs[\"bot_lang\"]\n    # PANEL_ADMIN_ID = ADMIN_DB.find_admins(uuid=urlparse(PANEL_URL).path.split('/')[2])\n    PANEL_ADMIN_ID = urlparse(PANEL_URL).path.split('/')[2]\n    if not PANEL_ADMIN_ID:\n        print(colored(\"Admin panel UUID is not valid!\", \"red\"))\n        raise Exception(f\"Admin panel UUID is not valid!\\nBe in touch with {HIDY_BOT_ID}\")\n    PANEL_ADMIN_ID = PANEL_ADMIN_ID[0][0]\n\n\ndef panel_url_validator(url):\n    if not (url.startswith(\"https://\") or url.startswith(\"http://\")):\n        print(colored(\"URL must start with http:// or https://\", \"red\"))\n        return False\n    if url.endswith(\"/\"):\n        url = url[:-1]\n    if url.endswith(\"admin\"):\n        url = url.replace(\"/admin\", \"\")\n    if url.endswith(\"admin/user\"):\n        url = url.replace(\"/admin/user\", \"\")\n    print(colored(\"Checking URL...\", \"yellow\"))\n    try:\n        request = requests.get(f\"{url}/admin/\")\n    except requests.exceptions.ConnectionError as e:\n        print(colored(\"URL is not valid! Error in connection\", \"red\"))\n        print(colored(f\"Error: {e}\", \"red\"))\n        return False\n    \n    if request.status_code != 200:\n        print(colored(\"URL is not valid!\", \"red\"))\n        print(colored(f\"Error: {request.status_code}\", \"red\"))\n        return False\n    elif request.status_code == 200:\n        print(colored(\"URL is valid!\", \"green\"))\n    return url\n\n\ndef bot_token_validator(token):\n    print(colored(\"Checking Bot Token...\", \"yellow\"))\n    try:\n        request = requests.get(f\"https://api.telegram.org/bot{token}/getMe\")\n    except requests.exceptions.ConnectionError:\n        print(colored(\"Bot Token is not valid! Error in connection\", \"red\"))\n        return False\n    if request.status_code != 200:\n        print(colored(\"Bot Token is not valid!\", \"red\"))\n        return False\n    elif request.status_code == 200:\n        print(colored(\"Bot Token is valid!\", \"green\"))\n        print(colored(\"Bot Username:\", \"green\"), \"@\"+request.json()['result']['username'])\n    return True\n\n\ndef set_by_user():\n    print()\n    print(\n        colored(\"Example: 123456789\\nIf you have more than one admin, split with comma(,)\\n[get it from @userinfobot]\",\n                \"yellow\"))\n    while True:\n        admin_id = input(\"[+] Enter Telegram Admin Number IDs: \")\n        admin_ids = admin_id.split(',')\n        admin_ids = [admin_id.strip() for admin_id in admin_ids]\n        if not all(admin_id.isdigit() for admin_id in admin_ids):\n            print(colored(\"Admin IDs must be numbers separated by commas!\", \"red\"))\n            continue\n        admin_ids = [int(admin_id) for admin_id in admin_ids]\n        break\n    print()\n    print(colored(\"Example: 123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ\\n[get it from @BotFather]\", \"yellow\"))\n    while True:\n        token = input(\"[+] Enter your Admin bot token: \")\n        if not token:\n            print(colored(\"Token is required\", \"red\"))\n            continue\n        if not bot_token_validator(token):\n            continue\n        break\n\n    print()\n    print(colored(\"You can use the bot as a userbot for your clients!\", \"yellow\"))\n    while True:\n        userbot = input(\"Do you want a  Bot for your users? (y/n): \").lower()\n        if userbot not in [\"y\", \"n\"]:\n            print(colored(\"Please enter y or n!\", \"red\"))\n            continue\n        break\n    if userbot == \"y\":\n        print()\n        print(colored(\"Example: 123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ\\n[get it from @BotFather]\", \"yellow\"))\n        while True:\n            client_token = input(\"[+] Enter your client (For Users) bot token: \")\n            if not client_token:\n                print(colored(\"Token is required!\", \"red\"))\n                continue\n            if client_token == token:\n                print(colored(\"Client token must be different from Admin token!\", \"red\"))\n                continue\n            if not bot_token_validator(client_token):\n                continue\n            break\n    else:\n        client_token = None\n    print()\n    print(colored(\n        \"Example: https://panel.example.com/7frgemkvtE0/78854985-68dp-425c-989b-7ap0c6kr9bd4\\n[exactly like this!]\",\n        \"yellow\"))\n    while True:\n        url = input(\"[+] Enter your panel URL:\")\n        if not url:\n            print(colored(\"URL is required!\", \"red\"))\n            continue\n        url = panel_url_validator(url)\n        if not url:\n            continue\n        break\n    print()\n    print(colored(\"Example: EN (default: FA)\\n[It is better that the language of the bot is the same as the panel]\",\n                  \"yellow\"))\n    while True:\n        lang = input(\"[+] Select your language (EN(English), FA(Persian)): \") or \"FA\"\n        if lang not in [\"EN\", \"FA\"]:\n            print(colored(\"Language must be EN or FA!\", \"red\"))\n            continue\n        break\n\n    return admin_ids, token, url, lang, client_token\n\n\ndef set_config_in_db(db, admin_ids, token, url, lang, client_token):\n    try:\n        # if str_config is not exists, create it\n        if not db.select_str_config():\n            db.add_str_config(\"bot_admin_id\", value=json.dumps(admin_ids))\n            db.add_str_config(\"bot_token_admin\", value=token)\n            db.add_str_config(\"bot_token_client\", value=client_token)\n            db.add_str_config(\"bot_lang\", value=lang)\n        else:\n            db.edit_str_config(\"bot_admin_id\", value=json.dumps(admin_ids))\n            db.edit_str_config(\"bot_token_admin\", value=token)\n            db.edit_str_config(\"bot_token_client\", value=client_token)\n            db.edit_str_config(\"bot_lang\", value=lang)\n        # if servers is not exists, create it\n        if not db.select_servers():\n            db.add_server(url, 2000, title=\"Main Server\", default_server=True)\n        else:\n            # find default server\n            default_servers = db.find_server(default_server=True)\n            if default_servers:\n                default_server_id = default_servers[0]['id']\n                default_server = default_servers[0]\n                if default_server['url'] != url:\n                    db.edit_server(default_server_id, url=url)\n            else:\n                db.add_server(url, 2000, title=\"Main Server\", default_server=True)\n    except Exception as e:\n        logging.error(f\"Error while inserting config to database \\n Error:{e}\")\n        raise Exception(f\"Error while inserting config to database \\nBe in touch with {HIDY_BOT_ID}\")\n\n\ndef print_current_conf(conf, server_url):\n    print()\n    print(colored(\"Current configration data:\", \"yellow\"))\n    print(f\"[+] Admin IDs: {conf['bot_admin_id']}\")\n    print(f\"[+] Admin Bot Token: {conf['bot_token_admin']}\")\n    print(f\"[+] Client Bot Token: {conf['bot_token_client']}\")\n    print(f\"[+] Panel URL: {server_url}\")\n    print(f\"[+] Language: {conf['bot_lang']}\")\n    print()\n\n\nif __name__ == '__main__':\n    db = UserDBManager(USERS_DB_LOC)\n    conf = load_config(db)\n    server_url = load_server_url(db)\n    if conf['bot_admin_id'] and conf['bot_token_admin'] and conf['bot_lang'] and server_url:\n        print(\"Config is already set!\")\n        print_current_conf(conf, server_url)\n        print(\"Do you want to change config? (y/n): \")\n        if input().lower() == \"y\":\n            admin_ids, token, url, lang, client_token = set_by_user()\n            set_config_in_db(db, admin_ids, token, url, lang, client_token)\n            conf = load_config(db)\n            server_url = load_server_url(db)\n            set_config_variables(conf, server_url)\n    else:\n        admin_ids, token, url, lang, client_token = set_by_user()\n        set_config_in_db(db, admin_ids, token, url, lang, client_token)\n        conf = load_config(db)\n        server_url = load_server_url(db)\n    set_config_variables(conf, server_url)\n    # close database connection\n    db.close()\n\ndb = UserDBManager(USERS_DB_LOC)\ndb.set_default_configs()\nconf = load_config(db)\nserver_url = load_server_url(db)\nset_config_variables(conf, server_url)\ndb.close()"
  },
  {
    "path": "crontab.py",
    "content": "# Crontab\nimport argparse\nfrom config import CLIENT_TOKEN\n\n# use argparse to get the arguments\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--backup\", action=\"store_true\", help=\"Backup the panel\")\n    parser.add_argument(\"--reminder\", action=\"store_true\", help=\"Send reminder to users\")\n    args = parser.parse_args()\n\n    # run the functions based on the arguments\n    if args.backup:\n        from Cronjob.backup import cron_backup\n        cron_backup()\n\n    elif args.reminder:\n        if CLIENT_TOKEN:\n            from Cronjob.reminder import cron_reminder\n            cron_reminder()\n\n\n# To run this file, use this command:\n# python3 crontab.py --backup\n# python3 crontab.py --reminder\n"
  },
  {
    "path": "hiddifyTelegramBot.py",
    "content": "from threading import Thread\nimport AdminBot.bot\nfrom config import CLIENT_TOKEN\n\n# Start the admin bot\nif __name__ == '__main__':\n    Thread(target=AdminBot.bot.start).start()\n    # Start the user bot if the client token is set\n    if CLIENT_TOKEN:\n        import UserBot.bot\n        Thread(target=UserBot.bot.start).start()\n\n"
  },
  {
    "path": "install.sh",
    "content": "#!/bin/bash\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nYELLOW='\\033[1;33m'\nRESET='\\033[0m' # Reset text color\n\nHIDY_BOT_ID=\"@HidyBotGroup\"\n# Function to display error messages and exit\nfunction display_error_and_exit() {\n  echo -e \"${RED}Error: $1${RESET}\"\n  echo -e \"${YELLOW}${HIDY_BOT_ID}${RESET}\"\n  exit 1\n}\n\ninstall_git_if_needed() {\n  if ! command -v git &>/dev/null; then\n    echo \"Git is not installed. Installing Git...\"\n\n    # Install Git based on the operating system (Linux)\n    if [ -f /etc/os-release ]; then\n      source /etc/os-release\n      if [ \"$ID\" == \"ubuntu\" ] || [ \"$ID\" == \"debian\" ]; then\n        sudo apt update\n        sudo apt install -y git\n      elif [ \"$ID\" == \"centos\" ] || [ \"$ID\" == \"rhel\" ]; then\n        sudo yum install -y git\n      fi\n    elif [ \"$(uname -s)\" == \"Darwin\" ]; then # macOS\n      brew install git\n    else\n      echo \"Unsupported operating system. Please install Git manually and try again.\"\n      exit 1\n    fi\n\n    if ! command -v git &>/dev/null; then\n      echo \"Failed to install Git. Please install Git manually and try again.\"\n      exit 1\n    fi\n\n    echo \"Git has been installed successfully.\"\n  fi\n}\n\n# Function to install Python 3 and pip if they are not already installed\ninstall_python3_and_pip_if_needed() {\n  if ! command -v python3 &>/dev/null || ! command -v pip &>/dev/null; then\n    echo \"Python 3 and pip are required. Installing Python 3 and pip...\"\n\n    # Install Python 3 and pip based on the operating system (Linux)\n    if [ -f /etc/os-release ]; then\n      source /etc/os-release\n      if [ \"$ID\" == \"ubuntu\" ] || [ \"$ID\" == \"debian\" ]; then\n        sudo apt update\n        sudo apt install -y python3 python3-pip\n      elif [ \"$ID\" == \"centos\" ] || [ \"$ID\" == \"rhel\" ]; then\n        sudo yum install -y python3 python3-pip\n      fi\n    elif [ \"$(uname -s)\" == \"Darwin\" ]; then # macOS\n      brew install python@3\n    else\n      echo \"Unsupported operating system. Please install Python 3 and pip manually and try again.\"\n      exit 1\n    fi\n\n    if ! command -v python3 &>/dev/null || ! command -v pip &>/dev/null; then\n      echo \"Failed to install Python 3 and pip. Please install Python 3 and pip manually and try again.\"\n      exit 1\n    fi\n\n    echo \"Python 3 and pip have been installed successfully.\"\n  fi\n}\necho -e \"${GREEN}Step 0: Checking requirements...${RESET}\"\ninstall_git_if_needed\ninstall_python3_and_pip_if_needed\n\n# Check if Git is installed\nif ! command -v git &>/dev/null; then\n  display_error_and_exit \"Git is not installed. Please install Git and try again.\"\nfi\n\n# Check if Python 3 and pip are installed\nif ! command -v python3 &>/dev/null || ! command -v pip &>/dev/null; then\n  display_error_and_exit \"Python 3 and pip are required. Please install them and try again.\"\nfi\n\necho -e \"${GREEN}Step 1: Cloning the repository and changing directory...${RESET}\"\n\nrepository_url=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot.git\"\ninstall_dir=\"/opt/Hiddify-Telegram-Bot\"\n\nbranch=\"main\"\n\nif [ \"$0\" == \"--pre-release\" ]; then\n    branch=\"pre-release\"\nfi\n\necho \"Selected branch: $branch\"\n\nif [ -d \"$install_dir\" ]; then\n  echo \"Directory $install_dir exists.\"\nelse\n  git clone -b \"$branch\" \"$repository_url\" \"$install_dir\" || display_error_and_exit \"Failed to clone the repository.\"\nfi\n\ncd \"$install_dir\" || display_error_and_exit \"Failed to change directory.\"\n\necho -e \"${GREEN}Step 2: Installing requirements...${RESET}\"\npip install -r requirements.txt || display_error_and_exit \"Failed to install requirements.\"\n\n\necho -e \"${GREEN}Step 3: Preparing ...${RESET}\"\nlogs_dir=\"$install_dir/Logs\"\nreceiptions_dir=\"$install_dir/UserBot/Receiptions\"\n\ncreate_directory_if_not_exists() {\n  if [ ! -d \"$1\" ]; then\n    echo \"Creating directory $1\"\n    mkdir -p \"$1\"\n  fi\n}\n\ncreate_directory_if_not_exists \"$logs_dir\"\ncreate_directory_if_not_exists \"$receiptions_dir\"\n\nchmod +x \"$install_dir/restart.sh\"\nchmod +x \"$install_dir/update.sh\"\n\necho -e \"${GREEN}Step 4: Running config.py to generate config.json...${RESET}\"\npython3 config.py || display_error_and_exit \"Failed to run config.py.\"\n\necho -e \"${GREEN}Step 5: Running the bot in the background...${RESET}\"\nnohup python3 hiddifyTelegramBot.py >>$install_dir/bot.log 2>&1 &\n\necho -e \"${GREEN}Step 6: Adding cron jobs...${RESET}\"\n\nadd_cron_job_if_not_exists() {\n  local cron_job=\"$1\"\n  local current_crontab\n\n  # Normalize the cron job formatting (remove extra spaces)\n  cron_job=$(echo \"$cron_job\" | sed -e 's/^[ \\t]*//' -e 's/[ \\t]*$//')\n\n  # Check if the cron job already exists in the current user's crontab\n  current_crontab=$(crontab -l 2>/dev/null || true)\n\n  if [[ -z \"$current_crontab\" ]]; then\n    # No existing crontab, so add the new cron job\n    (echo \"$cron_job\") | crontab -\n  elif ! (echo \"$current_crontab\" | grep -Fq \"$cron_job\"); then\n    # Cron job doesn't exist, so append it to the crontab\n    (echo \"$current_crontab\"; echo \"$cron_job\") | crontab -\n  fi\n}\n\n\n# Add cron job for reboot\nadd_cron_job_if_not_exists \"@reboot cd $install_dir && ./restart.sh\"\n\n# Add cron job to run every 6 hours\nadd_cron_job_if_not_exists \"0 */6 * * * cd $install_dir && python3 crontab.py --backup\"\n\n# Add cron job to run at 12:00 PM daily\nadd_cron_job_if_not_exists \"0 12 * * * cd $install_dir && python3 crontab.py --reminder\"\n\n\necho -e \"${GREEN}Waiting for a few seconds...${RESET}\"\nsleep 5\n\nif pgrep -f \"python3 hiddifyTelegramBot.py\" >/dev/null; then\n  echo -e \"${GREEN}The bot has been started successfully.${RESET}\"\n  echo -e \"${GREEN}Send [/start] in Telegram bot.${RESET}\"\nelse\n  display_error_and_exit \"Failed to start the bot. Please check for errors and try again.\"\nfi"
  },
  {
    "path": "requirements.txt",
    "content": "psutil==5.9.4\npyTelegramBotAPI==4.12.0\nrequests==2.30.0\ntermcolor==2.3.0\nqrcode==7.4.2\npytz==2023.3.post1\n"
  },
  {
    "path": "restart.sh",
    "content": "#!/bin/bash\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nRESET='\\033[0m' # Reset text color\ninstall_dir=\"/opt/Hiddify-Telegram-Bot\"\n\n# Function to display error messages and exit\nfunction display_error_and_exit() {\n  echo -e \"${RED}Error: $1${RESET}\"\n  exit 1\n}\n\n# Check if Python 3 is installed\nif ! command -v python3 &>/dev/null; then\n  display_error_and_exit \"Python 3 is required. Please install it and try again.\"\nfi\n\n# Stop the bot gracefully using SIGTERM (signal 15)\necho -e \"${GREEN}Stopping the bot gracefully...${RESET}\"\npkill -15 -f hiddifyTelegramBot.py\n\n# Wait for a few seconds to allow the bot to terminate\necho \"Please wait for 5 seconds ...\"\nsleep 5\n\n# Start the bot and redirect output to a log file\necho -e \"${GREEN}Starting the bot...${RESET}\"\n\n> $install_dir/bot.log\nnohup python3 /opt/Hiddify-Telegram-Bot/hiddifyTelegramBot.py >> /opt/Hiddify-Telegram-Bot/bot.log 2>&1 &\n\necho -e \"${GREEN}Bot has been restarted.${RESET}\"\n"
  },
  {
    "path": "uninstall.sh",
    "content": "#!/bin/bash\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nYELLOW='\\033[1;33m'\nRESET='\\033[0m' # Reset text color\n\nHIDY_BOT_ID=\"@HidyBotGroup\"\nINSTALL_DIR=\"/opt/Hiddify-Telegram-Bot\"\n\n# Function to display error messages and exit\nfunction display_error_and_exit() {\n  echo -e \"${RED}Error: $1${RESET}\"\n  echo -e \"${YELLOW}${HIDY_BOT_ID}${RESET}\"\n  exit 1\n}\n\necho -e \"${GREEN}Uninstalling the Hiddify-Telegram-Bot...${RESET}\"\n\n# Check if the installation directory exists\nif [ -d \"$INSTALL_DIR\" ]; then\n  # Stop the running bot if it's still running\n  if pgrep -f \"python3 hiddifyTelegramBot.py\" >/dev/null; then\n    echo -e \"${GREEN}Stopping the bot...${RESET}\"\n    pkill -9 -f \"hiddifyTelegramBot.py\"\n  fi\n\n  # Remove cron jobs\n  echo -e \"${GREEN}Removing cron jobs...${RESET}\"\n  crontab -l | grep -v \"$INSTALL_DIR\" | crontab -\n\n  # Remove the installation directory\n  echo -e \"${GREEN}Removing the installation directory...${RESET}\"\n  rm -rf \"$INSTALL_DIR\"\n\n  echo -e \"${GREEN}Uninstallation complete.${RESET}\"\nelse\n  display_error_and_exit \"The installation directory does not exist. Nothing to uninstall.\"\nfi\n"
  },
  {
    "path": "update.py",
    "content": "import json\nimport sqlite3\nimport argparse\nimport logging\nimport os\nUSERS_DB_LOC = os.path.join(os.getcwd(), \"Database\", \"hidyBot.db\")\n\nLOG_LOC = os.path.join(os.getcwd(), \"Logs\", \"update.log\")\nlogging.basicConfig(handlers=[logging.FileHandler(filename=LOG_LOC,\n                                                  encoding='utf-8', mode='w')],\n                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n                    level=logging.DEBUG)\n\ndef version():\n    parser = argparse.ArgumentParser(description='Update script')\n    # parser.add_argument(\"--update-v4-v5\", action=\"store_true\", help=\"Update database from version 4 to 5\")\n    parser.add_argument('--current-version', type=str, help='Current version')\n    parser.add_argument('--target-version', type=str, help='Target version')\n    args = parser.parse_args()\n    return args\n\ndef is_version_less(version1, version2):\n    v1_parts = list(map(int, version1.split('.')))\n    v2_parts = list(map(int, version2.split('.')))\n\n    for part1, part2 in zip(v1_parts, v2_parts):\n        if part1 < part2:\n            return True\n        elif part1 > part2:\n            return False\n\n    # If both versions are identical up to the available parts\n    return False\n\nconn = sqlite3.connect(USERS_DB_LOC)\n\n\ndef drop_columns_from_table(table_name, columns_to_drop):\n    try:\n        cur = conn.cursor()\n\n        # Create a list of column names to keep\n        columns_to_keep = [col for col in cur.execute(f\"PRAGMA table_info({table_name});\")]\n        columns_to_keep = [col[1] for col in columns_to_keep if col[1] not in columns_to_drop]\n\n        # Create a new table without the columns to be dropped\n        columns_to_keep_str = ', '.join(columns_to_keep)\n        cur.execute(f\"CREATE TABLE new_{table_name} AS SELECT {columns_to_keep_str} FROM {table_name};\")\n\n        # Drop the original table\n        cur.execute(f\"DROP TABLE {table_name};\")\n\n        # Rename the new table to the original table name\n        cur.execute(f\"ALTER TABLE new_{table_name} RENAME TO {table_name};\")\n\n        # Commit the changes to the database\n        conn.commit()\n\n        return True\n\n    except sqlite3.Error as e:\n        # Handle any database errors that may occur\n        logging.error(\"Database error: %s\" % e)\n        return False\n\n# main_version = __version__.split(\".\")[0]\n# print(\"main_version\", main_version)\n# logging.info(\"main_version %s\" % main_version)\n\ndef update_v4_v5():\n    print(\"Updating database from version v4 to v5\")\n    logging.info(\"Updating database from version 4 to 5\")\n    with sqlite3.connect(USERS_DB_LOC) as conn:\n        logging.info(\"Updating database from version 4 to 5\")\n        print(\"Updating database from version 4 to 5\")\n\n        # Changes in orders table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"DELETE FROM orders WHERE approved = 0\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n            \n        try:\n            cur = conn.cursor()\n            cur.execute(\"DELETE FROM orders WHERE approved IS NULL\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        drop_columns_from_table('orders', ['payment_image', 'payment_method', 'approved'])\n\n        try:\n            cur = conn.cursor()\n            cur.execute(\"DROP TABLE owner_info\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n\n        # Drop settings table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"DROP TABLE settings\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n\n        # Add test_subscription bool default 0 to users table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE users ADD COLUMN test_subscription BOOLEAN DEFAULT 0\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        \n        # image path to basename\n\n            \n        # move config.json to db\n        CONF_LOC = os.path.join(os.getcwd(), \"config.json\")\n        if os.path.exists(CONF_LOC):\n            with open(CONF_LOC, \"r\") as f:\n                config = json.load(f)\n                try:\n                    # if str_config is not exists, create it\n                    cur = conn.cursor()\n                    cur.execute(\"CREATE TABLE IF NOT EXISTS str_config (key TEXT PRIMARY KEY, value TEXT)\")\n                    admin_ids = config[\"admin_id\"]\n                    admin_ids = json.dumps(admin_ids)\n                    cur.execute(\"INSERT OR REPLACE INTO str_config VALUES (?, ?)\", (\"bot_admin_id\", admin_ids))\n                    cur.execute(\"INSERT OR REPLACE INTO str_config VALUES (?, ?)\", (\"bot_token_admin\", config[\"token\"]))\n                    cur.execute(\"INSERT OR REPLACE INTO str_config VALUES (?, ?)\",\n                                (\"bot_token_client\", config[\"client_token\"]))\n                    cur.execute(\"INSERT OR REPLACE INTO str_config VALUES (?, ?)\", (\"bot_lang\", config[\"lang\"]))\n                    conn.commit()\n\n                    # if servers is not exists, create it\n                    cur.execute(\n                        \"CREATE TABLE IF NOT EXISTS servers (id INTEGER PRIMARY KEY AUTOINCREMENT, url TEXT NOT NULL, title TEXT, description TEXT,default_server BOOLEAN NOT NULL DEFAULT 0)\")\n                    server_url = config[\"url\"]\n                    cur.execute(\"INSERT INTO servers VALUES (?,?,?,?,?)\", (None, server_url, None, None,True))\n\n                    conn.commit()\n                except sqlite3.Error as e:\n                    logging.error(\"Database error: %s\" % e)\n                    print(\"SQLite error:\", e)\n            os.remove(CONF_LOC)\ndef update_v5_1_0_to_v5_5_0():\n    print(\"Updating database from version v5.1.0 to v5.5.0\")\n    logging.info(\"Updating database from version v5.1.0 to v5.5.0\")\n    with sqlite3.connect(USERS_DB_LOC) as conn:\n        # add server_id to plans table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE plans ADD COLUMN server_id INTEGER\")\n            cur.execute(\"UPDATE plans SET server_id = 1\")\n            # set foreign key FOREIGN KEY (server_id) REFERENCES server (id)\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        # add server_id to order_subscriptions table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE order_subscriptions ADD COLUMN server_id INTEGER\")\n            cur.execute(\"UPDATE order_subscriptions SET server_id = 1\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        # add server_id to non_order_subscriptions table\n        try:\n            # check if server_id is exists\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE non_order_subscriptions ADD COLUMN server_id INTEGER\")\n            cur.execute(\"UPDATE non_order_subscriptions SET server_id = 1\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        # add user_limit, status to servers table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE servers ADD COLUMN user_limit INTEGER\")\n            cur.execute(\"ALTER TABLE servers ADD COLUMN status BOOLEAN DEFAULT 1\")\n            cur.execute(\"UPDATE servers SET user_limit = 2000\")\n            cur.execute(\"UPDATE servers SET title = Main Server\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        # add full_name,username to users table\n        try:\n            cur = conn.cursor()\n            cur.execute(\"ALTER TABLE users ADD COLUMN full_name TEXT NULL\")\n            cur.execute(\"ALTER TABLE users ADD COLUMN username TEXT NULL\")\n            conn.commit()\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n        \n        # remove user_name from payments table\n        drop_columns_from_table('payments', ['user_name']) \n\ndef update_v5_9_5_to_v6_1_0():\n    print(\"Updating database from version v5.9.5 to v6.1.0\")\n    logging.info(\"Updating database from version v5.9.5 to v6.1.0\")\n    with sqlite3.connect(USERS_DB_LOC) as conn:\n        # add server_id to plans table\n        try:\n            cur = conn.cursor()\n            # add banned column to users table\n            cur.execute(\"ALTER TABLE users ADD COLUMN banned BOOLEAN DEFAULT 0\")\n            cur.execute(\"UPDATE users SET banned = 0\")\n        except sqlite3.Error as e:\n            logging.error(\"Database error: %s\" % e)\n            print(\"SQLite error:\", e)\n            \n        \n        \n    \ndef update_by_version(current_version, target_version):\n    if is_version_less(current_version, target_version):\n        print(\"Updating started...\")\n        logging.info(\"Updating started...\")\n        # if current_version is less than 5, update to 5.0.0\n        if is_version_less(current_version, \"5.0.0\"):\n            update_v4_v5()\n        if is_version_less(current_version, \"5.5.0\"):\n            update_v5_1_0_to_v5_5_0()\n        if is_version_less(current_version, \"6.1.0\"):\n            update_v5_9_5_to_v6_1_0()\n        if is_version_less(current_version, \"6.1.1\"):\n            update_v5_9_5_to_v6_1_0()\n    else:\n        print(\"No update is needed\")\n        logging.info(\"No update is needed\")\n\n\nif __name__ == \"__main__\":\n    args = version()\n    if args.current_version and args.target_version:\n        current_version = args.current_version\n        target_version = args.target_version\n        if current_version.find(\"-pre\"):\n            current_version = current_version.split(\"-pre\")[0]\n        if target_version.find(\"-pre\"):\n            target_version = target_version.split(\"-pre\")[0]\n        print(f\"current-version: {current_version} -> target-version: {target_version}\")\n        logging.info(f\"current-version: {current_version} -> target-version: {target_version}\")\n        update_by_version(current_version, target_version)\n    else:\n        logging.info(\"No update is needed\")\n        print(\"No update is needed\")\n"
  },
  {
    "path": "update.sh",
    "content": "#!/bin/bash\n# shellcheck disable=SC2034\ntarget_version=\"6.1.5\"\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nYELLOW='\\033[0;33m'\nRESET='\\033[0m' # Reset text color\ninstall_dir=\"/opt/Hiddify-Telegram-Bot\"\n\n# Function to display colored messages\nfunction display_message() {\n  echo -e \"$1\"\n}\n\n# Function to gracefully stop the bot\nfunction stop_bot() {\n  display_message \"${GREEN}Stopping the bot gracefully...${RESET}\"\n  pkill -15 -f hiddifyTelegramBot.py\n}\n\nadd_cron_job_if_not_exists() {\n  local cron_job=\"$1\"\n  local current_crontab\n\n  # Normalize the cron job formatting (remove extra spaces)\n  cron_job=$(echo \"$cron_job\" | sed -e 's/^[ \\t]*//' -e 's/[ \\t]*$//')\n\n  # Check if the cron job already exists in the current user's crontab\n  current_crontab=$(crontab -l 2>/dev/null || true)\n\n  if [[ -z \"$current_crontab\" ]]; then\n    # No existing crontab, so add the new cron job\n    (echo \"$cron_job\") | crontab -\n  elif ! (echo \"$current_crontab\" | grep -Fq \"$cron_job\"); then\n    # Cron job doesn't exist, so append it to the crontab\n    (echo \"$current_crontab\"; echo \"$cron_job\") | crontab -\n  fi\n}\n\n# Function to reinstall the bot\nfunction reinstall_bot() {\n  display_message \"${YELLOW}This version is deprecated, and you need to reinstall the bot.${RESET}\"\n\n  # Ask for confirmation\n  read -r -p \"Do you want to reinstall the bot? [y/N] \" response\n  case \"$response\" in\n    [yY][eE][sS]|[yY])\n      display_message \"Reinstalling the bot...\"\n\n      # Change to the installation directory\n      cd /opt || {\n        display_message \"${RED}Failed to change directory to /opt.${RESET}\"\n        exit 1\n      }\n\n      # Remove the old bot\n      rm -rf /opt/Hiddify-Telegram-Bot\n\n      # Run the installation script\n      bash -c \"$(curl -Lfo- https://raw.githubusercontent.com/B3H1Z/Hiddify-Telegram-Bot/main/install.sh)\"\n\n      display_message \"${GREEN}Bot has been reinstalled.${RESET}\"\n      ;;\n    *)\n      display_message \"Bot has not been reinstalled.\"\n      ;;\n  esac\n}\n\n# current_version_first_part=$(echo \"current_version\" | cut -d '.' -f 1)\n# target_version_first_part=$(echo \"target_version\" | cut -d '.' -f 1)\n\n# if [ \"$current_version_first_part\" = \"4\" ] && [ \"$target_version_first_part\" = \"5\" ]; then\n#     echo \"Version is 4, running update.py to update to version 5.\"\n#     python3 /opt/Hiddify-Telegram-Bot/update.py --update-v4-v5\n#     echo \"Update.py has been run.\"\n# else\n#     echo \"Version is not 4.\"\n# fi\nbranch=\"main\"\n\nif [ \"$0\" == \"--pre-release\" ]; then\n    branch=\"pre-release\"\nfi\necho \"Selected branch: $branch\"\n\n# Function to update and restart the bot\nfunction update_bot() {\n  display_message \"${GREEN}Updating the bot...${RESET}\"\n  git stash\n  if git pull origin \"$branch\"; then\n    pip install -r requirements.txt || display_error_and_exit \"Failed to install requirements.\"\n    nohup python3 hiddifyTelegramBot.py >>bot.log 2>&1 &\n    display_message \"${GREEN}Bot has been updated and restarted.${RESET}\"\n  else\n    if git pull --rebase origin \"$branch\"; then\n      pip install -r requirements.txt || display_error_and_exit \"Failed to install requirements.\"\n      > $install_dir/bot.log\n      nohup python3 hiddifyTelegramBot.py >>bot.log 2>&1 &\n      display_message \"${GREEN}Bot has been updated and restarted.${RESET}\"\n    else\n      display_message \"${RED}Failed to update the bot. Check the Git repository for errors.${RESET}\"\n      exit 1\n    fi\n    display_message \"${RED}Failed to update the bot. Check the Git repository for errors.${RESET}\"\n    exit 1\n  fi\n}\n\n# get backup of Database/hidyBot.db\nfunction get_backup() {\n  display_message \"${GREEN}Getting backup of Database/hidyBot.db...${RESET}\"\n  if cp /opt/Hiddify-Telegram-Bot/Database/hidyBot.db /opt/Hiddify-Telegram-Bot/Database/hidyBot.db.bak; then\n    display_message \"${GREEN}Backup of Database/hidyBot.db has been taken.${RESET}\"\n  else\n    display_message \"${RED}Failed to get backup of Database/hidyBot.db.${RESET}\"\n  fi\n}\n\n# Stop the bot gracefully before proceeding\nstop_bot\n\n# Wait for a few seconds\ndisplay_message \"Please wait for 5 seconds ...\"\nsleep 5\n# If version.py does not exist, offer to reinstall the bot; otherwise, update it\nif [ ! -f /opt/Hiddify-Telegram-Bot/version.py ]; then\n  reinstall_bot\nelse\n\n  current_version=$(python3 /opt/Hiddify-Telegram-Bot/version.py --version)  \n  get_backup\n  update_bot\n\n  # Add cron job for reboot\n  add_cron_job_if_not_exists \"@reboot cd $install_dir && ./restart.sh\"\n\n  # Add cron job to run every 6 hours\n  add_cron_job_if_not_exists \"0 */6 * * * cd $install_dir && python3 crontab.py --backup\"\n\n  # Add cron job to run at 12:00 PM daily\n  add_cron_job_if_not_exists \"0 12 * * * cd $install_dir && python3 crontab.py --reminder\"\n\n  echo -e \"${YELLOW}Current version: $current_version${RESET}\"\n  echo -e \"${YELLOW}Target version: $target_version${RESET}\"\n  \n  if python3 /opt/Hiddify-Telegram-Bot/update.py --current-version \"$current_version\" --target-version \"$target_version\"; then\n      echo \"update.py has been run.\"\n  else\n      echo \"update.py has not been run.\"\n      exit 1\n  fi\n  \nfi\n"
  },
  {
    "path": "version.py",
    "content": "import argparse\n\n# Define the version number\n__version__ = \"6.1.5\"\n\n\n\ndef version():\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--version\", action=\"version\", version=f\"{__version__}\")\n    args = parser.parse_args()\n    return args\n\ndef is_version_less(version1, version2):\n    v1_parts = list(map(int, version1.split('.')))\n    v2_parts = list(map(int, version2.split('.')))\n\n    for part1, part2 in zip(v1_parts, v2_parts):\n        if part1 < part2:\n            return True\n        elif part1 > part2:\n            return False\n\n    # If both versions are identical up to the available parts\n    return False\n\nif __name__ == \"__main__\":\n    version()\n"
  }
]