Showing preview only (519K chars total). Download the full file or copy to clipboard to get everything.
Repository: B3H1Z/Hiddify-Telegram-Bot
Branch: main
Commit: f82165920b02
Files: 36
Total size: 488.9 KB
Directory structure:
gitextract_jrhoa15n/
├── .gitignore
├── AdminBot/
│ ├── Json/
│ │ ├── buttons.json
│ │ ├── commands.json
│ │ └── messages.json
│ ├── bot.py
│ ├── content.py
│ ├── markups.py
│ └── templates.py
├── Cronjob/
│ ├── backup.py
│ ├── backupBot.py
│ └── reminder.py
├── Database/
│ └── dbManager.py
├── LICENSE
├── README-FA.md
├── README.md
├── Shared/
│ └── common.py
├── UserBot/
│ ├── Json/
│ │ ├── buttons.json
│ │ ├── commands.json
│ │ └── messages.json
│ ├── bot.py
│ ├── content.py
│ ├── markups.py
│ └── templates.py
├── Utils/
│ ├── api.py
│ ├── serverInfo.py
│ └── utils.py
├── config.py
├── crontab.py
├── hiddifyTelegramBot.py
├── install.sh
├── requirements.txt
├── restart.sh
├── uninstall.sh
├── update.py
├── update.sh
└── version.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/Database/hidyBot.db
/Logs
/Backup
/UserBot/Receiptions
/.idea
/temp
/Utils/swapWallet.py
/.handler-saves
hiddifypanel.db
config.json
*.pyc
*.pyo!/qodana.yaml
qodana.yaml
check-host.py
.vscode/launch.json
Database/hidyBot1.db
================================================
FILE: AdminBot/Json/buttons.json
================================================
{
"EN": {
"CONFIRM": "✅Confirm",
"CANCEL": "❌Cancel",
"BOT_USERS_MANAGEMENT": "👤Bot Users Management",
"USERS_LIST": "👤Bot Users List",
"SEARCH_USERS_BOT": "🔍Search Bot Users",
"ORDERS_MANAGEMENT": "📗Orders Management",
"ORDERS_LIST": "📗Orders List",
"SEARCH_ORDERS": "🔍Search Orders",
"PAYMENT_MANAGEMENT": "💵Payment Management",
"APPROVED_PAYMENTS_LIST": "✅Approved Payment List",
"NON_APPROVED_PAYMENTS_LIST": "🚫Non Approved Payment List",
"PENDING_PAYMENT_LIST": "⏳Pending Payment List",
"CARD_PAYMENT_LIST": "💳Card Payment List",
"DIGITAL_PAYMENT_LIST": "💸Digital Payment List",
"SEARCH_PAYMENTS": "🔍Search Payment",
"USER_SUB_LIST": "📋Subscriptions List",
"EDIT_WALLET": "💳Edit Wallet",
"PAYMENTS_LIST": "💵Payment List",
"GIFT_LIST": "🎁Gift List",
"REFERRED_LIST": "🎗Referred List",
"USERS_SEARCH": "🔍Search User",
"ADD_USER": "➕Add User",
"SERVER_BACKUP": "📥Panel Backup",
"SERVER_STATUS": "📈Server Status",
"USERS_BOT_MANAGEMENT": "🤖Users Bot Management",
"NEXT_PAGE": "➡️",
"PREV_PAGE": "⬅️",
"CONFIGS_USER": "Configs",
"EDIT_USER": "Edit User",
"DELETE_USER": "Delete User",
"EDIT_NAME": "👤Edit Name",
"EDIT_USAGE": "📊Edit Usage",
"RESET_USAGE": "🔄Reset Usage",
"EDIT_DAYS": "📆Edit Days",
"RESET_DAYS": "🔄Reset Days",
"EDIT_COMMENT": "📝Edit Comment",
"UPDATE_MESSAGE": "🔄Update Message",
"BACK": "🔙Back",
"CONFIGS_DIR": "Configs",
"CONFIGS_SUB_AUTO": "Auto Subscription",
"CONFIGS_SUB": "Subscription Link",
"CONFIGS_SUB_B64": "Subscription Link b64",
"CONFIGS_CLASH": "Clash Subscription",
"CONFIGS_HIDDIFY": "Hiddify Subscription",
"CONFIGS_SING_BOX": "Sing-box",
"CONFIGS_FULL_SING_BOX": "Full Sing-box",
"SEARCH_USER_NAME": "Search by Name",
"SEARCH_USER_TELEGRAM_ID": "Search by Telegram ID",
"SEARCH_USER_UUID": "Search by UUID",
"SEARCH_USER_CONFIG": "Search by Config",
"SEARCH_EXPIRED_USERS": "Expired Users List",
"USERS_BOT_ADD_PLAN": "➕Add Plan",
"USERS_BOT_DEL_PLAN": "➖Delete Plan",
"USERS_BOT_OWNER_INFO": "👤Owner Info",
"USERS_BOT_OWNER_INFO_EDIT": "👤Edit Owner Info",
"USERS_BOT_ORDERS_STATUS": "📈Payment Status",
"USERS_BOT_SUB_STATUS": "📈Subscription Status",
"USERS_BOT_OWNER_INFO_EDIT_CARD_NAME": "Edit Card Holder Name",
"USERS_BOT_OWNER_INFO_EDIT_CARD_NUMBER": "Edit Card Number",
"USERS_BOT_OWNER_INFO_EDIT_USERNAME": "Edit Support Username",
"USERS_BOT_SEND_MESSAGE_TO_USERS": "📩Send Message to Users",
"USERS_BOT_SETTINGS": "⚙️Settings",
"USERS_BOT_SETTINGS_SHOW_HIDI_LINK": "User Page Hyperlink",
"USERS_BOT_SETTINGS_SHOW_THREE_RAND": "Random 3 Digit Price",
"USERS_BOT_SETTINGS_MIN_DEPO": "Minimum Deposit",
"USERS_BOT_SETTINGS_PNL_V8_FEATURES": "Panel V8 Features",
"USERS_BOT_SETTINGS_CHANNEL_ID": "Support Channel",
"USERS_BOT_SETTINGS_CHANNEL_ّFORCE_JOIN": "Force Join",
"USERS_BOT_SETTINGS_VISIBLE_SUBS": "Visible Subscriptions",
"USERS_BOT_SETTINGS_SET_WELCOME_MSG": "Welcome Message",
"USERS_BOT_SETTINGS_SET_FAQ_MSG": "ّFAQ",
"USERS_BOT_SETTINGS_SET_FAQ_MESSAGE": "Set FAQ",
"USERS_BOT_SETTINGS_HIDE_FAQ": "❌Hide FAQ",
"USERS_BOT_SETTINGS_TEST_SUB": "Test Subscription",
"USERS_BOT_SETTINGS_TEST_SUB_DAYS": "Test Subscription Days",
"USERS_BOT_SETTINGS_TEST_SUB_SIZE": "Test Subscription Size",
"USERS_BOT_SETTINGS_NOTIF_REMINDER": "Subscription Reminder",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE": "Usage Reminder",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS": "Days Reminder",
"USERS_BOT_SETTINGS_PANEL_AUTO_BACKUP": "Auto Backup",
"USERS_BOT_SETTINGS_BOT_AUTO_BACKUP": "Bot Auto Backup",
"USERS_BOT_SETTINGS_PANEL_MANUAL": "Manual",
"USERS_BOT_SETTINGS_PANEL_MANUAL_ANDROID": "Android Manual",
"USERS_BOT_SETTINGS_PANEL_MANUAL_IOS": "IOS Manual",
"USERS_BOT_SETTINGS_PANEL_MANUAL_WIN": "Windows Manual",
"USERS_BOT_SETTINGS_PANEL_MANUAL_MAC": "Mac Manual",
"USERS_BOT_SETTINGS_PANEL_MANUAL_LIN": "Linux Manual",
"USERS_BOT_SETTINGS_BACKUP_BOT": "Backup Bot",
"USERS_BOT_SETTINGS_RESTORE_BOT": "Restore Bot",
"USERS_BOT_SETTINGS_BUY_SUBSCRIPTION_STATUS": "Buy Subscription",
"USERS_BOT_SETTINGS_RENEWAL_SUBSCRIPTION_STATUS": "Renewal Subscription",
"USERS_BOT_SETTINGS_RENEWAL_METHOD": "Renewal Method",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_DEFAULT": "Default",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED": "Advanced",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_FAIRLY": "Fairly",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS": "Maximum Days for Renewal",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE": "Maximum Usage for Renewal",
"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT": "Reset free test limit",
"ABOUT_BOT": "ℹ️",
"TO_QR": "ً🖼QR",
"SUPPORT_GROUP": "Support Group",
"SERVERS_MANAGEMENT":"🖥Servers Management",
"ADD_SERVER": "➕Add Server",
"EDIT_SERVER": "Edit Server",
"DELETE_SERVER": "➖Delete Server",
"SERVER_LIST_OF_USERS": "👤Users List",
"SERVER_LIST_OF_PLANS": "Plans List",
"SERVER_EDIT_TITLE": "Edit title",
"SERVER_EDIT_USER_LIMIT": "Edit User Limit",
"SERVER_EDIT_URL": "Edit URL",
"CHANGE_STATUS_PAYMENT": "Change Payment Status",
"CONFIRM_PAYMENT": "✅Confirm Payment",
"NO": "❌No",
"YES": "✅Yes",
"ANSWER": "Answer",
"SEND_MESSAGE": "Send Message",
"DEBUG":"DEBUG",
"SKIP":"⏩Skip",
"RESET_TEST":"🔄Reset Test",
"BAN_USER":"🚫Ban User"
},
"FA": {
"CONFIRM": "✅تأیید",
"CANCEL": "❌لغو",
"BOT_USERS_MANAGEMENT": "👤مدیریت کاربران ربات",
"USERS_LIST": "👤لیست کاربران ربات",
"SEARCH_USERS_BOT": "🔍جستجوی کاربران ربات",
"ORDERS_MANAGEMENT": "📗مدیریت سفارشات",
"ORDERS_LIST": "📗لیست سفارشات",
"SEARCH_ORDERS": "🔍جستجوی سفارشات",
"PAYMENT_MANAGEMENT": "💵مدیریت تراکنشات",
"APPROVED_PAYMENTS_LIST": "✅لیست تراکنشات تایید شده",
"NON_APPROVED_PAYMENTS_LIST": "🚫لیست تراکنشات رد شده",
"PENDING_PAYMENT_LIST": "⏳لیست تراکنشات در انتظار",
"CARD_PAYMENT_LIST": "💳لیست تراکنشات کارت به کارت",
"DIGITAL_PAYMENT_LIST": "💸لیست تراکنشات دیجیتال",
"SEARCH_PAYMENTS": "🔍جستجوی تراکنش",
"USER_SUB_LIST": "📋لیست سرویسها",
"EDIT_WALLET": "💳ویرایش کیف پول",
"PAYMENTS_LIST": "💵لیست تراکنشات",
"GIFT_LIST": "🎁لیست هدایا",
"REFERRED_LIST": "🎗لیست معرفی شدهها",
"USERS_SEARCH": "🔍جستجوی کاربر",
"ADD_USER": "➕افزودن کاربر",
"SERVER_BACKUP": "📥دریافت بکاپ",
"SERVER_STATUS": "📈وضعیت سرور",
"USERS_BOT_MANAGEMENT": "🤖مدیریت ربات کاربران",
"NEXT_PAGE": "➡️",
"PREV_PAGE": "⬅️",
"CONFIGS_USER": "کانفیگ ها",
"EDIT_USER": "ویرایش کاربر",
"DELETE_USER": "حذف کاربر",
"EDIT_NAME": "👤ویرایش نام",
"EDIT_USAGE": "📊ویرایش حجم",
"RESET_USAGE": "🔄بازنشانی حجم",
"EDIT_DAYS": "📆ویرایش مدت",
"RESET_DAYS": "🔄بازنشانی مدت",
"EDIT_COMMENT": "📝ویرایش یادداشت",
"UPDATE_MESSAGE": "🔄بهروزرسانی پیام",
"BACK": "🔙بازگشت",
"CONFIGS_DIR": "کانفیگ مستقیم",
"CONFIGS_SUB_AUTO": "اشتراک خودکار",
"CONFIGS_SUB": "لینک اشتراک",
"CONFIGS_SUB_B64": "لینک اشتراک b64",
"CONFIGS_CLASH": "اشتراک Clash",
"CONFIGS_HIDDIFY": "اشتراک Hiddify",
"CONFIGS_SING_BOX": "Sing-box",
"CONFIGS_FULL_SING_BOX": "Full Sing-box",
"SEARCH_USER_NAME": "جستجو با نام",
"SEARCH_USER_TELEGRAM_ID": "جستجو با Telegram ID",
"SEARCH_USER_UUID": "جستجو با UUID",
"SEARCH_USER_CONFIG": "جستجو با کانفیگ",
"SEARCH_EXPIRED_USERS": "لیست کاربران منقضی",
"USERS_BOT_ADD_PLAN": "➕افزودن پلن",
"USERS_BOT_DEL_PLAN": "➖حذف پلن",
"USERS_BOT_OWNER_INFO": "👤اطلاعات مالک",
"USERS_BOT_OWNER_INFO_EDIT": "ویرایش اطلاعات مالک",
"USERS_BOT_ORDERS_STATUS": "📊پیگیری تراکنش",
"USERS_BOT_SUB_STATUS": "📊پیگیری اشتراک",
"USERS_BOT_OWNER_INFO_EDIT_USERNAME": "ویرایش نام کاربری پشتیبان",
"USERS_BOT_OWNER_INFO_EDIT_CARD_NUMBER": "ویرایش شماره کارت",
"USERS_BOT_OWNER_INFO_EDIT_CARD_NAME": "ویرایش نام صاحب کارت",
"USERS_BOT_SEND_MESSAGE_TO_USERS": "📩ارسال پیام همگانی",
"USERS_BOT_SETTINGS": "⚙️تنظیمات",
"USERS_BOT_SETTINGS_SHOW_HIDI_LINK": "هایپرلینک هیدیفای",
"USERS_BOT_SETTINGS_SHOW_THREE_RAND": "مشخصه تصادفی قیمت",
"USERS_BOT_SETTINGS_MIN_DEPO": "محدودیت حداقل تراکنش",
"USERS_BOT_SETTINGS_PNL_V8_FEATURES": "اشتراک های نسخه 8",
"USERS_BOT_SETTINGS_CHANNEL_ID": "تنظیم کانال پشتیبانی",
"USERS_BOT_SETTINGS_CHANNEL_ّFORCE_JOIN": "عضویت اجباری",
"USERS_BOT_SETTINGS_VISIBLE_SUBS": "وضعیت نمایش اشتراک ها",
"USERS_BOT_SETTINGS_SET_WELCOME_MSG": "پیام خوش آمدگویی",
"USERS_BOT_SETTINGS_SET_FAQ_MSG": "متن سوالات متداول",
"USERS_BOT_SETTINGS_SET_FAQ_MESSAGE": "تنظیم متن سوالات متداول",
"USERS_BOT_SETTINGS_HIDE_FAQ": "❌حذف سوالات متداول",
"USERS_BOT_SETTINGS_TEST_SUB": "مشخصات اشتراک تستی",
"USERS_BOT_SETTINGS_TEST_SUB_DAYS": "مدت اشتراک تستی",
"USERS_BOT_SETTINGS_TEST_SUB_SIZE": "حجم اشتراک تستی",
"USERS_BOT_SETTINGS_NOTIF_REMINDER": "یادآور وضعیت اشتراک",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE": "یادآور وضعیت مصرف",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS": "یادآور وضعیت زمان",
"USERS_BOT_SETTINGS_PANEL_AUTO_BACKUP": "ارسال خودکار بکاپ",
"USERS_BOT_SETTINGS_BOT_AUTO_BACKUP": "بکاپ خودکار ربات",
"USERS_BOT_SETTINGS_PANEL_MANUAL": "متن راهنما",
"USERS_BOT_SETTINGS_PANEL_MANUAL_ANDROID": "راهنمای اندروید",
"USERS_BOT_SETTINGS_PANEL_MANUAL_IOS": "راهنمای IOS",
"USERS_BOT_SETTINGS_PANEL_MANUAL_WIN": "راهنمای ویندوز",
"USERS_BOT_SETTINGS_PANEL_MANUAL_MAC": "راهنمای مک",
"USERS_BOT_SETTINGS_PANEL_MANUAL_LIN": "راهنمای لینوکس",
"USERS_BOT_SETTINGS_BACKUP_BOT": "پشتیبان گیری ربات",
"USERS_BOT_SETTINGS_RESTORE_BOT": "بازیابی ربات",
"USERS_BOT_SETTINGS_BUY_SUBSCRIPTION_STATUS": "خرید اشتراک",
"USERS_BOT_SETTINGS_RENEWAL_SUBSCRIPTION_STATUS": "تمدید اشتراک",
"USERS_BOT_SETTINGS_RENEWAL_METHOD": "شیوه تمدید",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_DEFAULT": "پیشفرض",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED": "پیشرفته",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_FAIRLY": "منصفانه",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS": "حداکثر زمان مجاز برای تمدید",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE": "حداکثر مصرف مجاز برای تمدید",
"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT": "بازنشانی تست رایگان",
"ABOUT_BOT": "ℹ️",
"TO_QR": "ً🖼کیوآر",
"SUPPORT_GROUP": "گروه پشتیبانی",
"SERVERS_MANAGEMENT":"🖥 مدیریت سرورها",
"ADD_SERVER": "➕افزودن سرور",
"EDIT_SERVER": "ویرایش سرور",
"DELETE_SERVER": "حذف سرور",
"SERVER_LIST_OF_USERS": "مدیریت کاربران",
"SERVER_LIST_OF_PLANS": "لیست پلنها",
"SERVER_EDIT_TITLE": "ویرایش عنوان",
"SERVER_EDIT_USER_LIMIT": "ویرایش محدودیت کاربر",
"SERVER_EDIT_URL": "ویرایش لینک",
"CHANGE_STATUS_PAYMENT": "تغییر وضعیت تراکنش",
"CONFIRM_PAYMENT": "✅تایید تراکنش",
"NO": "❌خیر",
"YES": "✅بله",
"ANSWER": "📤پاسخ",
"SEND_MESSAGE": "📤ارسال پیام",
"DEBUG":"DEBUG",
"SKIP":"⏩رد کردن",
"RESET_TEST":"🔄بازنشانی اشتراک تستی",
"BAN_USER":"🚫مسدود کردن کاربر"
}
}
================================================
FILE: AdminBot/Json/commands.json
================================================
{
"EN": {
"START": "start",
"DEBUG": "debug"
},
"FA": {
"START": "شروع",
"DEBUG": "اشکال زدایی"
}
}
================================================
FILE: AdminBot/Json/messages.json
================================================
{
"EN": {
"WELCOME": "Welcome to Hiddify Management Bot",
"ERROR_INVALID_NUMBER": "❌Only numbers are allowed!",
"ERROR_USER_NOT_FOUND": "❌User not found",
"ERROR_INVALID_COMMAND": "❌Invalid command",
"ERROR_UNKNOWN": "❌Unknown error",
"ERROR_CONFIG_NOT_FOUND": "❌Config not found",
"ERROR_PLAN_NOT_FOUND": "❌Plan not found",
"ERROR_SUB_NOT_FOUND": "❌Subscription not found",
"ERROR_CHANNEL_ID_NOT_SET": "❌Channel ID not set, please set it first.",
"SUCCESS_USER_DELETED": "✅User deleted",
"SUCCESS_USER_EDITED": "✅User edited",
"SUCCESS_USER_ADDED": "✅User added",
"SUCCESS_USER_USAGE_EDITED": "✅Usage limit edited to:",
"SUCCESS_USER_DAYS_EDITED": "✅Days edited to:",
"SUCCESS_USER_NAME_EDITED": "✅Name edited to:",
"SUCCESS_USER_COMMENT_EDITED": "✅Comment edited to:",
"SUCCESS_ADD_USER": "✅User added",
"SUCCESS_SEARCH_USER": "✅User found",
"SUCCESS_SEARCH_SUB": "✅Subscription found",
"SUCCESS_SEND_MSG_USERS": "✅Message sent to users",
"SUCCESS_REMOVED_SERVER": "✅Server removed",
"SUCCESS_RESET_FREE_TEST": "✅Free trial limit successfully reset",
"WAIT": "Please wait...",
"CANCELED": "❌Canceled",
"CANCEL_ADD_USER": "❌Add User Canceled",
"ADD_USER_NAME": "Please enter the name of the user: ",
"ADD_USER_COMMENT": "Please enter the comment of the user: ",
"ADD_USER_USAGE_LIMIT": "Please enter the usage limit of the user (GB): ",
"ADD_USER_DAYS": "Please enter the days of package: ",
"ENTER_NEW_USAGE_LIMIT": "Please enter new usage limit (GB): ",
"ENTER_NEW_DAYS": "Please enter new limit: ",
"ENTER_NEW_NAME": "Please enter new name: ",
"ENTER_NEW_COMMENT": "Please enter new comment: ",
"RESET_USAGE": "✅Usage limit reset",
"RESET_DAYS": "✅Days reset",
"ADD_USER_CONFIRM": "Please confirm the information:",
"ERROR_NOT_ADMIN": "❌You are not admin!",
"NEW_USER_INFO": "[New User Info]",
"EDITED_USER_INFO": "[User Info Updated]",
"EXPIRED_USERS_LIST": "[EXPIRED USERS LIST]",
"GB": "GB",
"DAY_EXPIRE": "Days",
"INFO_USAGE": "📊Usage:",
"OF": "of",
"INFO_REMAINING_DAYS": "📆Remaining Days:",
"INFO_LAST_CONNECTION": "📶Last Connection:",
"INFO_COMMENT": "📝Comment:",
"INFO_USER_NAME": "⬖ Name:",
"INFO_USER_USERNAME": "⬖ Username:",
"INFO_USER_NUM_ID": "⬖ Telegram ID:",
"HEADER_USERS_LIST": "⬖ Users List",
"HEADER_USERS_LIST_MSG": "ℹ️You can see the list of users and their information here.",
"NUM_USERS": "🟢Number of users: ",
"NUM_USERS_ONLINE": "🔵Online users: ",
"NUM_GET_FREE_USERS": "⬖ Number of received free test: ",
"NUM_ORDERED_USERS": "⬖ Number of users placed order: ",
"TOTAL_BALANCE_USERS": "⬖ Total balance of users' wallets: ",
"SEARCH_USER": "Please select the search method",
"SEARCH_USER_NAME": "Please enter the name of the user: ",
"SEARCH_USER_TELEGRAM_ID": "Please enter the Telegram ID of the user: ",
"SEARCH_USER_UUID": "Please enter the UUID of the user: ",
"SEARCH_USER_CONFIG": "Please enter one of the config of the user: ",
"SEARCH_RESULT": "[Search Result]",
"MONTH": "Months",
"WEEK": "Weeks",
"DAY": "Days",
"HOUR": "Hours",
"MINUTE": "Minutes",
"ONLINE": "Online",
"AGO": "ago",
"NEVER": "Never",
"TOMAN": "T",
"CURRENT_VALUE": "Current Value",
"ERROR_CLIENT_TOKEN": "❌Client bot is not set!",
"USERS_BOT_ADD_PLAN": "Please complete the following information to add a plan",
"USERS_BOT_ADD_PLAN_DAYS": "Please enter the days of Plan: ",
"USERS_BOT_ADD_PLAN_USAGE": "Please enter the usage limit(GB) of the Plan: ",
"USERS_BOT_ADD_PLAN_PRICE": "Please enter the price(TOMAN) of the Plan: ",
"USERS_BOT_ADD_PLAN_DESC": "Please enter the description of the Plan: ",
"USERS_BOT_ADD_PLAN_CONFIRM": "Please confirm the information:",
"USERS_BOT_ADD_PLAN_SUCCESS": "✅Plan added",
"USERS_BOT_OWNER_INFO_NOT_FOUND": "Owner info not found!\nPlease set it first.",
"USERS_BOT_OWNER_INFO_ADD_USERNAME": "Please enter the username of the support bot: ",
"USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER": "Please enter the card number: ",
"USERS_BOT_OWNER_INFO_ADD_CARD_NAME": "Please enter the name of the card owner: ",
"USERS_BOT_SEND_MSG_USERS": "Please enter the message you want to send to users:",
"USERS_BOT_PLANS_LIST": "📋Plans List",
"USERS_BOT_SELECT_PLAN_TO_DELETE": "Please select the plan you want to delete:",
"USERS_BOT_PLAN_DELETED": "✅Plan deleted",
"SUCCESS_UPDATE_DATA": "✅Data updated",
"USERS_BOT_SETTINGS": "⚙️Users Bot Settings",
"USERS_BOT_SETTINGS_HYPERLINK": "Set Hyperlink visibility when user request subscription info",
"USERS_BOT_ORDER_NUMBER_REQUEST": "Please enter the payment number:",
"USERS_BOT_SUB_ID_REQUEST": "Please enter the subscription ID:",
"USERS_BOT_SETTING_MIN_DEPO": "Please enter the minimum deposit:",
"USERS_BOT_SETTING_CHANNEL_ID": "Please enter the channel ID:",
"USERS_BOT_SETTING_FORCE_JOIN_HELP": "⭕Please add the bot to your channel and make it admin to work properly.",
"USERS_BOT_SETTING_WELCOME_MSG": "Please enter the welcome message:",
"USERS_BOT_SETTING_FAQ_MSG": "Please enter the faq text to show in the user panel:",
"USERS_BOT_SETTINGS_TEST_SUB_DAYS": "Please enter the days of test subscription:",
"USERS_BOT_SETTINGS_TEST_SUB_USAGE": "Please enter the usage limit(GB) of test subscription:",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS": "Set the number of days before the end of the subscription to send a reminder message:",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE": "Set the remaining GB to send a reminder message:",
"USERS_BOT_SETTINGS_PANEL_MANUAL": "Please enter the manual text to show in the user panel:",
"USERS_BOT_SETTINGS_BACKUP_BOT": "Backup Bot File",
"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",
"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:",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE":"Set the remaining GB to allow the user to renew the subscription:",
"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",
"ERROR_INVALID_USERNAME": "❌Invalid username\nUsername must start with @",
"ERROR_INVALID_CARD_NUMBER": "❌Invalid card number",
"PAYMENT_CONFIRMED": "✅Payment confirmed",
"PAYMENT_NOT_CONFIRMED": "❌Payment not confirmed",
"ERROR_PAYMENT_ALREADY_CONFIRMED": "❌Payment already confirmed",
"ERROR_PAYMENT_ALREADY_REJECTED": "❌Payment already rejected",
"PAYMENT_CONFIRMED_ADMIN": "✅Payment confirmed",
"PAYMENT_NOT_CONFIRMED_ADMIN": "❌Payment not confirmed",
"ERROR_PAYMENT_NOT_FOUND": "❌Payment not found",
"ERROR_ORDER_NOT_FOUND": "❌Order not found",
"ERROR_GIFT_NOT_FOUND": "❌Gift not found",
"ORDER_ID": "Payment number:",
"SUB_ID": "Subscription ID:",
"USER_TIME_EXPIRED": "⚠️EXPIRED",
"USER_LAST_DAY": "Last Day",
"PAYMENT_ASK_CHANGE_STATUS": "Do you want to change the status of the payment?",
"PAYMENT_ACCEPT_STATUS_CONFIRMED": "🟢Confirmed",
"PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED": "🔴Not Confirmed",
"PAYMENT_ACCEPT_STATUS_WAITING": "🟡Waiting",
"PAYMENT_ACCEPT_STATUS": "Status:",
"CREATED_AT": "Created:",
"WALLET_PAYMENT_CONFIRMED": "✅Payment confirmed\nYour wallet balance has increased.",
"FEATUR_UNAVAILABLE": "❌This feature is not available at the moment.",
"REQUEST_JOIN_HIDY": "Please join the support group to get the latest information.",
"WELCOME_TO_ADMIN": "Hiddify Management Bot has been successfully launched.\nTo start working, send the /start command.",
"SUCCESS_RESTORE_BOT": "✅Bot restored successfully",
"ADD_SERVER": "Please complete the following information to add a server",
"ADD_SERVER_TITLE": "Please enter the title of Server: ",
"ADD_SERVER_USER_LIMIT": "Please enter the user limit of the Server: ",
"ADD_SERVER_URL": "Please enter the url of the Server: ",
"ERROR_ADD_SERVER_URL": "Please enter the valid url of the Server: ",
"ERROR_SAME_SERVER_URL": "This link is already registered for another server, please submit another link:",
"ADD_SERVER_SUCCESS": "✅Server added",
"INFO_SERVER": "Server:",
"INFO_SERVER_USER_NUMBER": "Number of Users:",
"INFO_SERVER_USER_PLAN": "Number of Plan:",
"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.",
"ERROR_SERVER_NOT_FOUND": "❌Server not found",
"INFO_PLAN_ID": "Plan ID:",
"INFO_PLAN_USAGE": "Usage limit(GB):",
"INFO_PLAN_DAYS": "Time limitation:",
"INFO_PLAN_PRICE": "Price",
"INFO_PLAN_DESC": "Description:",
"INFO_PLAN_NUM_ORDER": "Purchases",
"INFO_PLAN_TOTAL_SALE": "Total sales",
"SUCCESS_SERVER_TITLE_EDITED":"✅Title edited to:",
"SUCCESS_SERVER_USER_LIMIT_EDITED" : "✅User limit edited to:",
"SUCCESS_SERVER_URL_EDITED": "✅URL edited to:",
"SERVER": "⬖ Server:",
"HEADER_ORDERS_LIST": "⬖ Orders List",
"NUM_ORDERS": "⬖ Number of Orders: ",
"TOTAL_ORDERS_VALUME": "⬖ Total volume ordered(GB): ",
"TOTAL_ORDERS_SALES": "⬖ Total value of orders: ",
"LAST_30DAYS_NUM_ORDERS": "⬖ Number of Last 30 Days Orders: ",
"LAST_30DAYS_ORDERS_VALUME": "⬖ Volume ordered in Last 30 Days(GB): ",
"LAST_30DAYS_ORDERS_SALES": "⬖ Value of orders in Last 30 Days: ",
"THIS_MONTH_NUM_ORDERS": "⬖ Number of This Month Orders: ",
"THIS_MONTH_ORDERS_VALUME": "⬖ Volume ordered in This Month(GB): ",
"THIS_MONTH_ORDERS_SALES": "⬖ Value of orders in This Month: ",
"HEADER_PAYMENT_LIST": "⬖ Payment List",
"NUM_PAYMENTS": "⬖ Number of Payments: ",
"TOTAL_PAYMENTS_AMOUNT": "⬖ Total amount payment: ",
"LAST_30DAYS_NUM_PAYMENTS": "⬖ Number of Last 30 Days Payments: ",
"LAST_30DAYS_PAYMENTS_AMOUNT": "⬖ Amount of Payments in Last 30 Days: ",
"THIS_MONTH_NUM_PAYMENTS": "⬖ Number of This Month Payments: ",
"THIS_MONTH_PAYMENTS_AMOUNT": "⬖ Amount of Payments in This Month: ",
"GET_FREE_TEST_STATUS": "⬖ Free Test Status: ",
"WALLET_BALANCE": "⬖ Wallet Balance: ",
"NUM_ORDER_SUB": "⬖ Number of ordered subscriptions: ",
"NUM_NON_ORDER_SUB": "⬖ Number of connected subscriptions: ",
"NUM_APPROVED_PAYMENTS": "⬖ Number of Approved Payments: ",
"BOT_ORDER_ID": "⬖ Order Number: ",
"ORDERED_VALUME": "⬖ Ordered Volume: ",
"ORDERED_DAYS": "⬖ Ordered Days: ",
"ORDERED_PRICE": "⬖ Ordered Price: ",
"SUB_NAME": "⬖ Subscription title: ",
"BOT_ORDER_DATE": "⬖ Order Date: ",
"ORDER_NUMBER_REQUEST": "Please enter the order number:",
"PAYMENTS_ID": "⬖ Payment number: ",
"BOT_PAYMENT_DATE": "⬖ Payment Date: ",
"PAIED_AMOUNT": "⬖ Paid amount: ",
"STATUS": "⬖ Status: ",
"PAYMENTS_METHOD": "⬖ Payment Method: ",
"PAYMENT_NUMBER_REQUEST": "Please enter the payment number:",
"CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST": "⚠️Are you sure about the changing payment status?",
"WALLET_CHANGED_TO_PAYMENT_CONFIRMED": "✅Payment changed to confirmed by admin\nYour wallet balance has increased.",
"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.",
"PAYMENT_CHANGED_TO_CONFIRMED_ADMIN": "✅Payment changed to confirmed",
"PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN": "❌Payment changed to rejected",
"SUCCESS_SEARCH_ORDER": "✅Order found",
"SUCCESS_SEARCH_PAYMENT": "✅Payment found",
"NOT_SET ": "Not set",
"EDIT_WALLET_BALANCE": "Please enter the new balance:",
"SEND_MESSAGE_TO_USER": "Please enter message you want to send to the user:",
"MESSAGE_SENDED": "Message Sended",
"ADMIN": "َAdmin:",
"MESSAGE_FROM_ADMIN": "Message from admin",
"MESSAGE_TEXT": "Message:",
"ERROR_USER_HAVE_TEST_SUB": "❌User already have a test subscription",
"SUCCESS_RESET_TEST_SUB": "✅Test subscription reset",
"WALLET_BALANCE_CHANGED_BY_ADMIN_P1": "💰Wallet balance changed to",
"WALLET_BALANCE_CHANGED_BY_ADMIN_P2": "by admin",
"SUCCESS_BAN_USER": "✅User banned",
"SUCCESS_UNBAN_USER": "✅User unbanned"
},
"FA": {
"WELCOME": "به ربات مدیریت هیدی بات خوش آمدید.",
"ERROR_INVALID_NUMBER": "❌تنها اعداد مجاز هستند!",
"ERROR_USER_NOT_FOUND": "❌کاربر یافت نشد",
"ERROR_INVALID_COMMAND": "❌فرمان نامعتبر",
"ERROR_UNKNOWN": "❌خطای ناشناخته",
"ERROR_CONFIG_NOT_FOUND": "❌کانفیگ یافت نشد",
"ERROR_PLAN_NOT_FOUND": "❌پلن یافت نشد",
"ERROR_SUB_NOT_FOUND": "❌اشتراکی با این شناسه یافت نشد",
"ERROR_CHANNEL_ID_NOT_SET": "❌آیدی کانال پشتیبانی تنظیم نشده است، لطفا ابتدا آن را تنظیم کنید.",
"SUCCESS_USER_DELETED": "✅کاربر حذف شد",
"SUCCESS_USER_EDITED": "✅کاربر ویرایش شد",
"SUCCESS_USER_ADDED": "✅کاربر اضافه شد",
"SUCCESS_USER_USAGE_EDITED": "✅محدودیت استفاده کاربر ویرایش شد به:",
"SUCCESS_USER_DAYS_EDITED": "✅روزها ویرایش شد به:",
"SUCCESS_USER_NAME_EDITED": "✅نام ویرایش شد به:",
"SUCCESS_USER_COMMENT_EDITED": "✅یادداشت ویرایش شد به:",
"SUCCESS_ADD_USER": "✅کاربر اضافه شد",
"SUCCESS_SEARCH_USER": "✅کاربر یافت شد",
"SUCCESS_SEARCH_SUB": "✅اشتراک یافت شد",
"SUCCESS_SEND_MSG_USERS": "✅پیام به کاربران ارسال شد",
"SUCCESS_REMOVED_SERVER": "✅سرور حذف شد",
"SUCCESS_RESET_FREE_TEST": "✅محدودیت تست رایگان با موفقیت بازنشانی شد",
"WAIT": "لطفاً منتظر بمانید...",
"CANCELED": "❌لغو شد",
"CANCEL_ADD_USER": "❌افزودن کاربر لغو شد",
"ADD_USER_NAME": "لطفاً نام کاربر را وارد کنید: ",
"ADD_USER_COMMENT": "لطفاً نظر کاربر را وارد کنید: ",
"ADD_USER_USAGE_LIMIT": "لطفاً محدودیت استفاده کاربر (GB) را وارد کنید: ",
"ADD_USER_DAYS": "لطفاً تعداد روز بستهی کاربر را وارد کنید: ",
"ENTER_NEW_USAGE_LIMIT": "لطفاً محدودیت استفاده جدید (GB) را وارد کنید: ",
"ENTER_NEW_DAYS": "لطفاً محدودیت جدید را وارد کنید: ",
"ENTER_NEW_NAME": "لطفاً نام جدید را وارد کنید: ",
"ENTER_NEW_COMMENT": "لطفاً یادداشت جدید را وارد کنید: ",
"RESET_USAGE": "✅محدودیت استفاده بازنشانی شد",
"RESET_DAYS": "✅روزها بازنشانی شد",
"ADD_USER_CONFIRM": "لطفاً اطلاعات را تأیید کنید:",
"ERROR_NOT_ADMIN": "❌شما ادمین نیستید!",
"NEW_USER_INFO": "[اطلاعات کاربر جدید]",
"EDITED_USER_INFO": "[اطلاعات کاربر بهروزرسانی شد]",
"EXPIRED_USERS_LIST": "[لیست کاربران منقضی شده]",
"GB": "گیگابایت",
"DAY_EXPIRE": "روز دیگر",
"INFO_USAGE": "📊مصرف:",
"OF": "از",
"INFO_REMAINING_DAYS": "📆انقضا:",
"INFO_LAST_CONNECTION": "📶آخرین اتصال:",
"INFO_COMMENT": "📝یادداشت:",
"INFO_USER_NAME": "⬖ کاربر:",
"INFO_USER_USERNAME": "⬖ نام کاربری:",
"INFO_USER_NUM_ID": "⬖ شناسه کاربر:",
"HEADER_USERS_LIST": "⬖ لیست کاربران",
"HEADER_USERS_LIST_MSG": "ش️ما میتوانید لیست کاربران و اطلاعات آنها را اینجا مشاهده کنید",
"NUM_USERS": "⬖ تعداد کاربران: ",
"NUM_USERS_ONLINE": "🔵کاربران آنلاین: ",
"NUM_GET_FREE_USERS": "⬖ تعداد کاربران تست رایگان: ",
"NUM_ORDERED_USERS": "⬖ تعداد کاربران سفارشات: ",
"TOTAL_BALANCE_USERS": "⬖ مجموع موجودی کیف پول کاربران: ",
"SEARCH_USER": "لطفاً روش جستجو را انتخاب کنید",
"SEARCH_USER_NAME": "لطفاً نام کاربر را وارد کنید: ",
"SEARCH_USER_TELEGRAM_ID": "لطفا Telegram ID کاربر را وارد کنید: ",
"SEARCH_USER_UUID": "لطفاً UUID کاربر را وارد کنید: ",
"SEARCH_USER_CONFIG": "لطفاً یکی از کانفیگ های کاربر را وارد کنید: ",
"SEARCH_RESULT": "[نتیجه جستجو]",
"MONTH": "ماه",
"WEEK": "هفته",
"DAY": "روز",
"HOUR": "ساعت",
"MINUTE": "دقیقه",
"ONLINE": "آنلاین",
"AGO": "پیش",
"NEVER": "هرگز",
"TOMAN": "تومان",
"CURRENT_VALUE": "مقدار فعلی",
"ERROR_CLIENT_TOKEN": "❌ربات کاربران تنظیم نشده",
"USERS_BOT_ADD_PLAN": "⬇️اطلاعات لازم را برای افزودن پلن وارد کنید",
"USERS_BOT_ADD_PLAN_DAYS": "لطفا زمان(تعداد روزهای) پلن را وارد کنید:",
"USERS_BOT_ADD_PLAN_USAGE": "لطفا محدودیت استفاده(گیگابایت) پلن را وارد کنید:",
"USERS_BOT_ADD_PLAN_PRICE": "لطفا قیمت(تومان) پلن را وارد کنید:",
"USERS_BOT_ADD_PLAN_DESC": "لطفا توضیحات پلن را وارد کنید:",
"USERS_BOT_ADD_PLAN_CONFIRM": "لطفا اطلاعات زیر را تایید کنید",
"USERS_BOT_ADD_PLAN_SUCCESS": "✅پلن با موفقیت افزوده شد",
"USERS_BOT_OWNER_INFO_NOT_FOUND": "❌اطلاعات مالک یافت نشد \n لطفا ابتدا آن را تنظیم کنید.",
"USERS_BOT_OWNER_INFO_ADD_USERNAME": "لطفا نام کاربری تلگرام پشتیبان را وارد کنید\nلطفا همراه با @ وارد کنید\nمثال: @example",
"USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER": "لطفا شماره 16 رقمی کارت بانکی جهت واریز را وارد کنید",
"USERS_BOT_OWNER_INFO_ADD_CARD_NAME": "لطفا نام صاحب حساب بانکی جهت واریز را وارد کنید",
"USERS_BOT_SEND_MSG_USERS": "لطفا پیام خود را برای ارسال به کاربران وارد کنید:",
"USERS_BOT_PLANS_LIST": "📋لیست پلن های موجود",
"USERS_BOT_SELECT_PLAN_TO_DELETE": "لطفا پلن مورد نظر را برای حذف انتخاب کنید",
"USERS_BOT_PLAN_DELETED": "✅پلن با موفقیت حذف شد",
"USERS_BOT_SETTINGS": "⚙️تنظیمات ربات کاربران",
"USERS_BOT_SETTINGS_HYPERLINK": "تنظیم نمایش Hyperlink صفحه هیدیفای روی نام کاربر هنگام دریافت اطلاعات اشتراک",
"USERS_BOT_ORDER_NUMBER_REQUEST": "لطفا [شناسه تراکنش] را وارد کنید:",
"USERS_BOT_SUB_ID_REQUEST": "لطفا شناسه اشتراک را وارد کنید:",
"USERS_BOT_SETTING_MIN_DEPO": "لطفا حداقل مبلغ واریزی را تعیین کنید:",
"USERS_BOT_SETTING_CHANNEL_ID": "لطفا آیدی کانال را وارد کنید:",
"USERS_BOT_SETTING_FORCE_JOIN_HELP": "⭕لطفا برای اجرای این قابلیت، حتما [ربات کاربران] را به کانال خود اضافه و آن را ادمین کنید!",
"USERS_BOT_SETTING_WELCOME_MSG": "لطفا پیام خوش آمدگویی را تنظیم کنید:",
"USERS_BOT_SETTING_FAQ_MSG": "لطفا متن سوالات متداول مورد نظر را برای نمایش در پنل کاربران وارد کنید:",
"USERS_BOT_SETTINGS_TEST_SUB_DAYS": "لطفا تعداد روزهای اشتراک تست را تنظیم کنید:",
"USERS_BOT_SETTINGS_TEST_SUB_USAGE": "لطفا حجم(گیگابایت) اشتراک تست را تنظیم کنید:",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS": "تعیین کنید که چند روز قبل از اتمام اشتراک پیام یادآوری تمدید اشتراک ارسال شود:",
"USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE": "تعیین کنید که چند گیگ مانده به اتمام اشتراک پیام یادآوری تمدید اشتراک ارسال شود:",
"USERS_BOT_SETTINGS_PANEL_MANUAL": "لطفا متن راهنمای مورد نظر را برای نمایش در پنل کاربران وارد کنید:",
"USERS_BOT_SETTINGS_BACKUP_BOT": "فایل پشتیبان ربات",
"USERS_BOT_SETTINGS_RESTORE_BOT": "📥 لطفا فایل پشتیبان خود را ارسال کنید: \n توجه داشته باشید که این قابلیت حساس میباشد و در صورت وجود هرگونه سوال یا شبهه، ابتدا با گروه پشتیبانی در ارتباط باشید.",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS":"تعیین کنید که چند روز مانده به پایان اشتراک، کاربر مجاز به تمدید اشتراک باشد:",
"USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE":"تعیین کنید که چند گیگ مانده به پایان اشتراک، کاربر مجاز به تمدید اشتراک باشد:",
"USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT_QUESTION": "آیا از بازنشانی تست رایگان کاربران اطمینان دارید؟\n⚠️با تایید این مورد تمامی کاربران قادر به گرفتن تست رایگان مجدد میباشند",
"SUCCESS_UPDATE_DATA": "✅اطلاعات با موفقیت به روز شد",
"ERROR_INVALID_USERNAME": "❌آیدی نامعتبر است\n آیدی باید با @ شروع شود",
"ERROR_INVALID_CARD_NUMBER": "❌شماره کارت نامعتبر است\nشماره کارت باید 16 رقمی باشد",
"PAYMENT_CONFIRMED": "تراکنش شما تایید شد\n از طریق دکمه [📊وضعیت اشتراک] میتوانید به اطلاعات اشتراک خود دسترسی داشته باشید.",
"PAYMENT_NOT_CONFIRMED": "تراکنش شما تایید نشد!\nلطفا اگر اشتباهی صورت گرفته با پشتیبانی در تماس باشید.",
"ERROR_PAYMENT_ALREADY_CONFIRMED": "تراکنش قبلا تایید شده است",
"ERROR_PAYMENT_ALREADY_REJECTED": "تراکنش قبلا رد شده است",
"PAYMENT_CONFIRMED_ADMIN": "تراکنش با موفقیت تایید شد",
"PAYMENT_NOT_CONFIRMED_ADMIN": "تراکنش تایید نشد",
"ERROR_ORDER_NOT_FOUND": "❌سفارش یافت نشد",
"ERROR_PAYMENT_NOT_FOUND": "تراکنش یافت نشد",
"ERROR_GIFT_NOT_FOUND": "❌هدیه یافت نشد",
"ORDER_ID": "شناسه تراکنش:",
"SUB_ID": "شناسه اشتراک",
"USER_TIME_EXPIRED": "⚠️منقضی",
"USER_LAST_DAY": "آخرین روز",
"PAYMENT_ASK_CHANGE_STATUS": "آیا میخواهید وضعیت تراکنش را تغییر دهید؟",
"PAYMENT_ACCEPT_STATUS_CONFIRMED": "🟢تایید شده",
"PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED": "🔴رد شده",
"PAYMENT_ACCEPT_STATUS_WAITING": "🟡در انتظار تایید",
"PAYMENT_ACCEPT_STATUS": "وضعیت:",
"CREATED_AT": "تاریخ ایجاد:",
"WALLET_PAYMENT_CONFIRMED": "تراکنش شما تایید شد\n از طریق دکمه [💰کیف پول] میتوانید به موجودی کیف پول خود دسترسی داشته باشید.",
"FEATUR_UNAVAILABLE": "❌این قابلیت در حال حاضر در دسترس نیست.",
"REQUEST_JOIN_HIDY": "📍جهت دریافت آخرین اطلاعات، در گروه پشتیبانی عضو شوید.",
"WELCOME_TO_ADMIN": "ربات مدیریت هیدی بات با موفقیت راهاندازی شد.\nبرای شروع کار، دستور /start را ارسال کنید.",
"SUCCESS_RESTORE_BOT": "✅ربات با موفقیت بازیابی شد",
"ADD_SERVER": "لطفا اطلاعات زیر را برای افزودن سرور وارد کنید",
"ADD_SERVER_TITLE": "لطفا عنوانی را برای سرور وارد کنید:",
"ADD_SERVER_USER_LIMIT": "لطفا محدودیت تعداد کاربر سرور را وارد کنید:",
"ADD_SERVER_URL": "لطفا لینک سرور را وارد کنید:",
"ERROR_ADD_SERVER_URL": "لطفا لینک معتبر ارسال کنید: ",
"ERROR_SAME_SERVER_URL": "این لینک قبلا برای سرور دیگری ثبت شده است، لطفا لینک دیگری ارسال کنید:",
"ADD_SERVER_SUCCESS": "✅سرور با موفقیت افزوده شد",
"INFO_SERVER": "سرور:",
"INFO_SERVER_USER_NUMBER": "تعداد کاربر:",
"INFO_SERVER_USER_PLAN": "تعداد پلن:",
"DELETE_SERVER_QUESTION": "آیا از حذف سرور مطمئن هستید؟\n⚠️بعد از حذف، اشتراکهای مربوط به این سرور برای کاربران قابل مشاهده نمیباشد و غیر قابل بازگردانی میباشد.",
"ERROR_SERVER_NOT_FOUND": "❌سرور یافت نشد",
"INFO_PLAN_ID": "آی دی:",
"INFO_PLAN_USAGE": "محدودیت مصرف(GB):",
"INFO_PLAN_DAYS": "محدودیت زمان(روز):",
"INFO_PLAN_PRICE": "قیمت:",
"INFO_PLAN_DESC": "توضیحات:",
"INFO_PLAN_NUM_ORDER": "تعداد سفارش:",
"INFO_PLAN_TOTAL_SALE": "مجموع فروش:",
"SUCCESS_SERVER_TITLE_EDITED":"✅عنوان سرور ویرایش شد به:",
"SUCCESS_SERVER_USER_LIMIT_EDITED" : "✅محدودیت کاربر ویرایش شد به:",
"SUCCESS_SERVER_URL_EDITED": "✅لینک سرور ویرایش شد به:",
"SERVER": "⬖ سرور: ",
"HEADER_ORDERS_LIST": "⬖ لیست سفارشات",
"NUM_ORDERS": "⬖ تعداد سفارشات: ",
"TOTAL_ORDERS_VALUME": "⬖ مجموع حجم سفارشات(GB): ",
"TOTAL_ORDERS_SALES": "⬖ مجموع ارزش سفارشات: ",
"LAST_30DAYS_NUM_ORDERS": "⬖ تعداد سفارشات 30 روز گذشته: ",
"LAST_30DAYS_ORDERS_VALUME": "⬖ حجم سفارشات 30 روز گذشته(GB): ",
"LAST_30DAYS_ORDERS_SALES": "⬖ ارزش سفارشات 30 روز گذشته: ",
"THIS_MONTH_NUM_ORDERS": "⬖ تعداد سفارشات این ماه: ",
"THIS_MONTH_ORDERS_VALUME": "⬖ حجم سفارشات این ماه(GB): ",
"THIS_MONTH_ORDERS_SALES": "⬖ ارزش سفارشات این ماه: ",
"HEADER_PAYMENT_LIST": "⬖ لیست تراکنشات",
"NUM_PAYMENTS": "⬖ تعداد تراکنشات: ",
"TOTAL_PAYMENTS_AMOUNT": "⬖ مبلغ تراکنشات: ",
"LAST_30DAYS_NUM_PAYMENTS": "⬖ تراکنشات 30 روز گذشته: ",
"LAST_30DAYS_PAYMENTS_AMOUNT": "⬖ مبلغ تراکنشات 30 روز گذشته: ",
"THIS_MONTH_NUM_PAYMENTS": "⬖ تراکنشات این ماه: ",
"THIS_MONTH_PAYMENTS_AMOUNT": "⬖ مبلغ تراکنشات این ماه: ",
"GET_FREE_TEST_STATUS": "⬖ وضعیت دریافت تست رایگان: ",
"WALLET_BALANCE": "⬖ موجودی کیف پول: ",
"NUM_ORDER_SUB": "⬖ تعداد اشتراکهای خریداری شده: ",
"NUM_NON_ORDER_SUB": "⬖ تعداد اشتراکهای متصل شده: ",
"NUM_APPROVED_PAYMENTS": "⬖ تعداد تراکنشات تایید شده: ",
"BOT_ORDER_ID": "⬖ شناسه سفارش: ",
"ORDERED_VALUME": "⬖ حجم سفارش(GB): ",
"ORDERED_DAYS": "⬖ تعداد روز سفارش: ",
"ORDERED_PRICE": "⬖ مبلغ سفارش: ",
"SUB_NAME": "⬖ عنوان اشتراک: ",
"BOT_ORDER_DATE": "⬖ تاریخ سفارش: ",
"ORDER_NUMBER_REQUEST": "لطفا شناسه سفارش را وارد کنید:",
"PAYMENTS_ID": "⬖ شناسه تراکنش: ",
"BOT_PAYMENT_DATE": "⬖ تاریخ تراکنش:",
"PAIED_AMOUNT": "⬖ مبلغ تراکنش: ",
"STATUS": "⬖ وضعیت: ",
"PAYMENTS_METHOD": "⬖ روش تراکنش: ",
"PAYMENT_NUMBER_REQUEST": "لطفا شناسه تراکنش را وارد کنید:",
"CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST": "⚠️آیا از تغییر وضعیت تراکنش، اطمینان دارید؟",
"WALLET_CHANGED_TO_PAYMENT_CONFIRMED": "✅وضیعت تراکنش شما توسط مدیر به تایید شده تغییر یافت\nاز طریق دکمه [💰کیف پول] میتوانید به موجودی کیف پول خود دسترسی داشته باشید.",
"PAYMENT_CHANGED_TO_NOT_CONFIRMED": "❌وضعیت تراکنش شما توسط مدیر به رد شده تغییر یافت و مبلغ تراکنش از موجود کیف پول شما کسر شد!\nلطفا اگر اشتباهی صورت گرفته با پشتیبانی در تماس باشید.",
"PAYMENT_CHANGED_TO_CONFIRMED_ADMIN": "✅وضعیت تراکنش به تایید شده تغییر یافت",
"PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN": "❌وضعیت تراکنش به رد شده تغییر یافت",
"SUCCESS_SEARCH_ORDER": "✅سفارش یافت شد",
"SUCCESS_SEARCH_PAYMENT": "تراکنش یافت شد",
"NOT_SET": "تنظیم نشده",
"EDIT_WALLET_BALANCE": "لطفا مبلغی که میخواهید موجودی کیف پول به آن تغییر کند را به تومان وارد کنید:",
"SEND_MESSAGE_TO_USER": "لطفا متن پیامی که می خواهید برای کاربر ارسال شود را وارد کنید:",
"MESSAGE_SENDED": "پیام ارسال شد",
"ADMIN": "ادمین:",
"MESSAGE_FROM_ADMIN": "📬پیام جدیدی از سمت ادمین دریافت شد",
"MESSAGE_TEXT": "📄متن پیام:",
"ERROR_USER_HAVE_TEST_SUB": "❌کاربر اکنون نیز اشتراک تست رایگان دارد",
"SUCCESS_RESET_TEST_SUB": "✅اشتراک تست رایگان این کاربر با موفقیت بازنشانی شد",
"WALLET_BALANCE_CHANGED_BY_ADMIN_P1": "💰موجودی کیف پول شما توسط مدیر به",
"WALLET_BALANCE_CHANGED_BY_ADMIN_P2": "تومان تغییر یافت",
"SUCCESS_BAN_USER": "✅کاربر مسدود شد",
"SUCCESS_UNBAN_USER": "✅کاربر مسدود شده، آزاد شد"
}
}
================================================
FILE: AdminBot/bot.py
================================================
# Description: Main Bot File
import datetime
import html
import logging
import operator
import time
import telebot
import os
from telebot.types import Message, CallbackQuery
from config import TELEGRAM_TOKEN, ADMINS_ID, PANEL_ADMIN_ID, CLIENT_TOKEN, BOT_BACKUP_LOC
from AdminBot.content import BOT_COMMANDS, MESSAGES, KEY_MARKUP
from AdminBot import markups
from AdminBot import templates
from Utils import utils
from Shared.common import user_bot
from Database.dbManager import USERS_DB
from Utils import api
from config import panel_url_validator, API_PATH
# Initialize Bot
bot = telebot.TeleBot(TELEGRAM_TOKEN, parse_mode="HTML")
bot.remove_webhook()
URL = 'url'
selected_server = None
search_mode = "Single"
server_mode = "Single"
searched_name = ""
list_mode = ""
item_mode= ""
selected_telegram_id = "0"
if CLIENT_TOKEN:
user_bot = user_bot()
# ----------------------------------- Helper Functions -----------------------------------
# Check if message is digit
def is_it_digit(message: Message, allow_float=False, response=MESSAGES['ERROR_INVALID_NUMBER'],
markup=markups.main_menu_keyboard_markup()):
if not message.text:
bot.send_message(message.chat.id, response, reply_markup=markup)
return False
try:
value = float(message.text) if allow_float else int(message.text)
return True
except ValueError:
bot.send_message(message.chat.id, response, reply_markup=markup)
return False
# Check if message is cancel
def is_it_cancel(message: Message, response=MESSAGES['CANCELED']):
if message.text == KEY_MARKUP['CANCEL']:
bot.send_message(message.chat.id, response, reply_markup=markups.main_menu_keyboard_markup())
return True
return False
def message_to_html(message: Message):
text = message.text
entities = message.entities
html_content = ""
offset = 0
for entity in entities:
html_content += html.escape(text[offset:entity.offset])
if entity.type == 'bold':
html_content += f'<b>{html.escape(text[entity.offset:entity.offset + entity.length])}</b>'
elif entity.type == 'italic':
html_content += f'<i>{html.escape(text[entity.offset:entity.offset + entity.length])}</i>'
elif entity.type == 'code':
html_content += f'<code>{html.escape(text[entity.offset:entity.offset + entity.length])}</code>'
elif entity.type == 'pre':
html_content += f'<pre>{html.escape(text[entity.offset:entity.offset + entity.length])}</pre>'
elif entity.type == 'text_link':
html_content += f'<a href="{html.escape(entity.url)}">{html.escape(text[entity.offset:entity.offset + entity.length])}</a>'
offset = entity.offset + entity.length
html_content += html.escape(text[offset:])
return html_content
# ----------------------------------- Add User Area -----------------------------------
# Add user Data dict
add_user_data = {}
# Add User - Name
def add_user_name(message: Message, server_id):
if is_it_cancel(message):
return
add_user_data['name'] = message.text
bot.send_message(message.chat.id, MESSAGES['ADD_USER_USAGE_LIMIT'], reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_user_limit, server_id)
# Add User - Usage Limit
def add_user_limit(message: Message, server_id):
if is_it_cancel(message):
return
if not is_it_digit(message, f"{MESSAGES['ERROR_INVALID_NUMBER']}\n{MESSAGES['ADD_USER_USAGE_LIMIT']}",
markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, add_user_limit, server_id)
return
add_user_data['limit'] = message.text
bot.send_message(message.chat.id, MESSAGES['ADD_USER_DAYS'], reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_user_usage_days, server_id)
# Add User - Usage Days
def add_user_usage_days(message: Message, server_id):
if is_it_cancel(message, MESSAGES['CANCEL_ADD_USER']):
return
if not is_it_digit(message, f"{MESSAGES['ERROR_INVALID_NUMBER']}\n{MESSAGES['ADD_USER_DAYS']}",
markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, add_user_usage_days, server_id)
return
add_user_data['usage_days'] = message.text
bot.send_message(message.chat.id,
f"{MESSAGES['ADD_USER_CONFIRM']}\n\n{MESSAGES['INFO_USER_NAME']} {add_user_data['name']}\n"
f"{MESSAGES['INFO_USAGE']} {add_user_data['limit']} {MESSAGES['GB']}\n{MESSAGES['INFO_REMAINING_DAYS']} {add_user_data['usage_days']} {MESSAGES['DAY']}",
reply_markup=markups.confirm_add_user_markup())
bot.register_next_step_handler(message, confirm_add_user, server_id)
# Add User - Confirm to add user
def confirm_add_user(message: Message, server_id):
if message.text == KEY_MARKUP['CANCEL']:
bot.send_message(message.chat.id, MESSAGES['CANCEL_ADD_USER'], reply_markup=markups.main_menu_keyboard_markup())
return
if message.text == KEY_MARKUP['CONFIRM']:
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'])
# res = ADMIN_DB.add_default_user(name=add_user_data['name'], package_days=int(add_user_data['usage_days']),
# usage_limit_GB=int(add_user_data['limit']))
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
URL = server['url'] + API_PATH
res = api.insert(URL, name=add_user_data['name'], package_days=int(add_user_data['usage_days']),
usage_limit_GB=int(add_user_data['limit']))
if res:
bot.send_message(message.chat.id, MESSAGES['SUCCESS_ADD_USER'],
reply_markup=markups.main_menu_keyboard_markup())
usr = utils.user_info(URL, res)
if not usr:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.user_info_template(usr, server, MESSAGES['NEW_USER_INFO'])
bot.delete_message(message.chat.id, msg_wait.message_id)
bot.send_message(message.chat.id, msg, reply_markup=markups.user_info_markup(usr['uuid']))
else:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
else:
bot.send_message(message.chat.id, MESSAGES['CANCEL_ADD_USER'], reply_markup=markups.main_menu_keyboard_markup())
# ----------------------------------- Edit User Area -----------------------------------
# Edit User - Name
def edit_user_name(message: Message, uuid):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
# status = ADMIN_DB.edit_user(uuid, name=message.text)
status = api.update(URL, uuid, name=message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_USER_NAME_EDITED']} {message.text} ",
reply_markup=markups.main_menu_keyboard_markup())
# Edit User - Usage
def edit_user_usage(message: Message, uuid):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, edit_user_usage, uuid)
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
# status = ADMIN_DB.edit_user(uuid, usage_limit_GB=int(message.text))
status = api.update(URL, uuid, usage_limit_GB=int(message.text))
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_USER_USAGE_EDITED']} {message.text} {MESSAGES['GB']}",
reply_markup=markups.main_menu_keyboard_markup())
# Edit User - Days
def edit_user_days(message: Message, uuid):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, edit_user_days, uuid)
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
# status = ADMIN_DB.edit_user(uuid, package_days=int(message.text))
status = api.update(URL, uuid, package_days=int(message.text))
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id,
f"{MESSAGES['SUCCESS_USER_DAYS_EDITED']} {message.text} {MESSAGES['DAY_EXPIRE']} ",
reply_markup=markups.main_menu_keyboard_markup())
# Edit User - Comment
def edit_user_comment(message: Message, uuid):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
# status = ADMIN_DB.edit_user(uuid, comment=message.text)
status = api.update(URL, uuid, comment=message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_USER_COMMENT_EDITED']} {message.text} ",
reply_markup=markups.main_menu_keyboard_markup())
# ----------------------------------- Search User Area -----------------------------------
# Search User - Name
def search_user_name(message: Message, server_id):
global searched_name
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
searched_name = message.text
users = utils.search_user_by_name(URL, searched_name)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not users:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.users_list_template(users, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.users_list_markup(server_id, users))
# Search User - UUID
def search_user_uuid(message: Message, server_id):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
user = utils.search_user_by_uuid(URL, message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not user:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.user_info_template(user, server, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.user_info_markup(user['uuid']))
# Search User - Config
def search_user_config(message: Message, server_id):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
user = utils.search_user_by_config(URL, message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not user:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.user_info_template(user, server, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.user_info_markup(user['uuid']))
# All Servers Search User - Name
def all_server_search_user_name(message: Message):
global searched_name
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
users = []
searched_name = message.text
servers = USERS_DB.select_servers()
if servers:
for server in servers:
URL = server['url'] + API_PATH
searched_users = utils.search_user_by_name(URL, searched_name)
if searched_users:
users.extend(searched_users)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not users:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.users_list_template(users, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.users_list_markup("None", users))
# All Servers Search User - UUID
def all_server_search_user_uuid(message: Message):
selected_server = None
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
servers = USERS_DB.select_servers()
if servers:
for server in servers:
URL = server['url'] + API_PATH
user = utils.search_user_by_uuid(URL, message.text)
if user:
selected_server = server
break
bot.delete_message(message.chat.id, msg_wait.message_id)
if not user:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.user_info_template(user, selected_server, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.user_info_markup(user['uuid']))
# All Servers Search User - Config
def all_server_search_user_config(message: Message):
selected_server = None
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
servers = USERS_DB.select_servers()
if servers:
for server in servers:
URL = server['url'] + API_PATH
user = utils.search_user_by_config(URL, message.text)
if user:
selected_server = server
break
bot.delete_message(message.chat.id, msg_wait.message_id)
if not user:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, templates.user_info_template(user, selected_server, MESSAGES['SEARCH_RESULT']),
reply_markup=markups.user_info_markup(user['uuid']))
# ----------------------------------- Users Bot Search Area -----------------------------------
# User Bot Search - Name
def search_bot_user_name(message: Message):
global searched_name
if is_it_cancel(message):
return
searched_name = message.text
users = USERS_DB.find_user(full_name=searched_name)
if not users:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
users.sort(key = operator.itemgetter('created_at'), reverse=True)
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
wallets_list = USERS_DB.select_wallet()
orders_list = USERS_DB.select_orders()
msg = templates.bot_users_list_template(users, wallets_list, orders_list)
bot.send_message(message.chat.id, msg, reply_markup=markups.bot_users_list_markup(users))
# User Bot Search - Name
def search_bot_user_telegram_id(message: Message):
global selected_telegram_id
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, search_bot_user_telegram_id)
return
searched_id = message.text
users = USERS_DB.find_user(telegram_id=int(searched_id))
if not users:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_USER'], reply_markup=markups.main_menu_keyboard_markup())
selected_telegram_id = user['telegram_id']
orders = USERS_DB.find_order(telegram_id=user['telegram_id'])
paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])
wallet = None
wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])
if wallets:
wallet = wallets[0]
non_order_subs = utils.non_order_user_info(user['telegram_id'])
order_subs = utils.order_user_info(user['telegram_id'])
plans_list = USERS_DB.select_plans()
msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)
bot.send_message(message.chat.id, msg, reply_markup=markups.bot_user_info_markup(user['telegram_id']))
# User Bot Search - Order
def search_bot_user_order(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, search_bot_user_order)
return
orders = USERS_DB.find_order(id=int(message.text))
if not orders:
bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
order = orders[0]
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_ORDER'], reply_markup=markups.main_menu_keyboard_markup())
plans = USERS_DB.find_plan(id=order['plan_id'])
if not plans:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
plan = plans[0]
#subs =
users = USERS_DB.find_user(telegram_id=order['telegram_id'])
if not users:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
servers = USERS_DB.find_server(id=plan['server_id'])
if not servers:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
server = servers[0]
msg = templates.bot_orders_info_template(order, plan, user, server)
bot.send_message(message.chat.id, msg)
# User Bot Search - Payment
def search_bot_user_payment(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, search_bot_user_payment)
return
payments = USERS_DB.find_payment(id=int(message.text))
if not payments:
bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_PAYMENT'], reply_markup=markups.main_menu_keyboard_markup())
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data)
photo_path = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])
bot.send_photo(message.chat.id, photo=open(photo_path, 'rb'),
caption=msg, reply_markup=markups.change_status_payment_by_admin(payment['id']))
# ----------------------------------- Users Bot Management Area -----------------------------------
#add_plan_data = {}
# Add Plan - Size
# def users_bot_add_plan_usage(message: Message):
# if is_it_cancel(message):
# return
# if not is_it_digit(message):
# return
# add_plan_data['usage'] = int(message.text)
# bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DAYS'],
# reply_markup=markups.while_edit_user_markup())
# bot.register_next_step_handler(message, users_bot_add_plan_days)
# # Add Plan - Days
# def users_bot_add_plan_days(message: Message):
# if is_it_cancel(message):
# return
# if not is_it_digit(message):
# return
# add_plan_data['days'] = int(message.text)
# bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_PRICE'],
# reply_markup=markups.while_edit_user_markup())
# bot.register_next_step_handler(message, users_bot_add_plan_price)
# # Add Plan - Price
# def users_bot_add_plan_price(message: Message):
# if is_it_cancel(message):
# return
# if not is_it_digit(message):
# return
# add_plan_data['price'] = utils.toman_to_rial(message.text)
# msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
# status = utils.users_bot_add_plan(add_plan_data['usage'], add_plan_data['days'], add_plan_data['price'])
# bot.delete_message(message.chat.id, msg_wait.message_id)
# if not status:
# bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
# return
# bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_SUCCESS'],
# reply_markup=markups.main_menu_keyboard_markup())
# ----------------------------------- Server Management Area -----------------------------------
add_server_data = {}
# Add Server - Title
def add_server_title(message: Message):
if is_it_cancel(message):
return
add_server_data['title'] = message.text
bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_server_url)
# Add Server - url
def add_server_url(message: Message):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
url = panel_url_validator(message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not url:
bot.reply_to(message, MESSAGES['ERROR_ADD_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_server_url)
return
servers = USERS_DB.select_servers()
if servers:
for server in servers:
if server['url'] == url:
bot.reply_to(message, MESSAGES['ERROR_SAME_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_server_url)
return
add_server_data['url'] = url
bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_USER_LIMIT'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, add_server_user_limit)
# Add Server - User Limit
def add_server_user_limit(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, add_server_user_limit)
return
add_server_data['user_limit'] = int(message.text)
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
status = utils.add_server(url=add_server_data['url'], user_limit=add_server_data['user_limit'], title=add_server_data['title'])
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['ADD_SERVER_SUCCESS'],
reply_markup=markups.main_menu_keyboard_markup())
servers = USERS_DB.select_servers()
bot.send_message(message.chat.id, KEY_MARKUP['SERVERS_MANAGEMENT'],
reply_markup=markups.servers_management_markup(servers))
# Edit Server - Server Title
def edit_server_title(message: Message, server_id):
if is_it_cancel(message):
return
status = USERS_DB.edit_server(int(server_id), title=message.text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_SERVER_TITLE_EDITED']}{server['title']}",
reply_markup=markups.main_menu_keyboard_markup())
plans = USERS_DB.select_plans()
msg = templates.server_info_template(server,plans)
bot.send_message(message.chat.id, msg,
reply_markup=markups.server_edit_markup(server_id))
# Edit Server - Server User Limit
def edit_server_user_limit(message: Message, server_id):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, edit_server_user_limit, server_id)
return
status = USERS_DB.edit_server(int(server_id), user_limit=int(message.text))
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_SERVER_USER_LIMIT_EDITED']}{server['user_limit']}",
reply_markup=markups.main_menu_keyboard_markup())
plans = USERS_DB.select_plans()
msg = templates.server_info_template(server,plans)
bot.send_message(message.chat.id, msg,
reply_markup=markups.server_edit_markup(server_id))
# Edit Server - Server Url
def edit_server_url(message: Message, server_id):
if is_it_cancel(message):
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
url = panel_url_validator(message.text)
bot.delete_message(message.chat.id, msg_wait.message_id)
if not url:
bot.send_message(message.chat.id, MESSAGES['ERROR_ADD_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, edit_server_url, server_id)
return
servers = USERS_DB.select_servers()
if servers:
for server in servers:
if server['url'] == url:
bot.reply_to(message, MESSAGES['ERROR_SAME_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, edit_server_url, server_id)
return
status = USERS_DB.edit_server(int(server_id), url=url)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
server = USERS_DB.find_server(id=int(server_id))
if not server:
bot.send_message(message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
bot.send_message(message.chat.id, f"{MESSAGES['SUCCESS_SERVER_URL_EDITED']}\n{server['url']}",
reply_markup=markups.main_menu_keyboard_markup())
plans = USERS_DB.select_plans()
msg = templates.server_info_template(server,plans)
bot.send_message(message.chat.id, msg,
reply_markup=markups.server_edit_markup(server_id))
# ----------------------------------- Users Bot Management Area -----------------------------------
add_plan_data = {}
# Add Plan - Size
def users_bot_add_plan_usage(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_add_plan_usage)
return
add_plan_data['usage'] = int(message.text)
bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DAYS'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, users_bot_add_plan_days)
# Add Plan - Days
def users_bot_add_plan_days(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_add_plan_days)
return
add_plan_data['days'] = int(message.text)
bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_PRICE'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(message, users_bot_add_plan_price)
# Add Plan - Price
def users_bot_add_plan_price(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_add_plan_price)
return
add_plan_data['price'] = utils.toman_to_rial(message.text)
bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_DESC'],
reply_markup=markups.while_edit_skip_user_markup())
bot.register_next_step_handler(message, users_bot_add_plan_description)
def users_bot_add_plan_description(message: Message):
if is_it_cancel(message):
return
if message.text == KEY_MARKUP['SKIP']:
add_plan_data['description'] = None
else:
add_plan_data['description'] = message.text
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
status = utils.users_bot_add_plan(add_plan_data['usage'], add_plan_data['days'],
add_plan_data['price'], add_plan_data['server_id'], add_plan_data['description'])
bot.delete_message(message.chat.id, msg_wait.message_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_SUCCESS'],
reply_markup=markups.main_menu_keyboard_markup())
plans_list = []
plans = USERS_DB.select_plans()
if plans:
for plan in plans:
if plan['status']:
if plan['server_id'] == int(add_plan_data['server_id']):
plans_list.append(plan)
plans_markup = markups.plans_list_markup(plans_list,add_plan_data['server_id'])
bot.send_message(message.chat.id, {MESSAGES['USERS_BOT_PLANS_LIST']},
reply_markup=plans_markup)
# Users Bot - Edit Owner Info - Username
def users_bot_edit_owner_info_username(message: Message):
if is_it_cancel(message):
return
if not message.text.startswith('@'):
bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_USERNAME'],
reply_markup=markups.main_menu_keyboard_markup())
return
status = USERS_DB.edit_str_config("support_username", value=message.text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
# Users Bot - Edit Owner Info - Card Number
def users_bot_edit_owner_info_card_number(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_edit_owner_info_card_number)
return
if len(message.text) != 16:
bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_CARD_NUMBER'],
reply_markup=markups.main_menu_keyboard_markup())
return
status = USERS_DB.edit_str_config("card_number", value=message.text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
# Users Bot - Edit Owner Info - Cardholder Name
def users_bot_edit_owner_info_card_name(message: Message):
if is_it_cancel(message):
return
status = USERS_DB.edit_str_config("card_holder", value=message.text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
# Users Bot - Send Message - All Users
def users_bot_send_msg_users(message: Message):
if is_it_cancel(message):
return
if not CLIENT_TOKEN:
bot.send_message(message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'],
reply_markup=markups.main_menu_keyboard_markup())
return
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'], reply_markup=markups.while_edit_user_markup())
users_number_id = USERS_DB.select_users()
bot.delete_message(message.chat.id, msg_wait.message_id)
if not users_number_id:
bot.send_message(message.chat.id, MESSAGES['ERROR_NO_USERS'], reply_markup=markups.main_menu_keyboard_markup())
return
for user in users_number_id:
time.sleep(0.05)
try:
user_bot.send_message(user['telegram_id'], message.text)
except Exception as e:
logging.warning(f"Error in send message to user {user['telegram_id']}: {e}")
continue
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEND_MSG_USERS'],
reply_markup=markups.main_menu_keyboard_markup())
# Users Bot - Settings - Update Message
def users_bot_settings_update_message(message: Message, markup,title=MESSAGES['USERS_BOT_SETTINGS']):
settings = utils.all_configs_settings()
bot.edit_message_text(chat_id=message.chat.id, message_id=message.message_id,
text=title,
reply_markup=markup)
# # Users Bot - Order Status
# def users_bot_order_status(message: Message):
# from UserBot.templates import payment_received_template
# if is_it_cancel(message):
# return
# if not is_it_digit(message):
# return
# payment = USERS_DB.find_payment(id=int(message.text))
# if not payment:
# bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'],
# reply_markup=markups.main_menu_keyboard_markup())
# return
# # plan = USERS_DB.find_plan(id=payment[0]['plan_id'])
# # if not payment:
# # bot.send_message(message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'], reply_markup=markups.main_menu_keyboard_markup())
# # return
# payment = payment[0]
# user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
# if not user_data:
# bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
# reply_markup=markups.main_menu_keyboard_markup())
# return
# user_data = user_data[0]
# is_it_accepted = None
# if payment['approved'] == 0:
# is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_NOT_CONFIRMED']
# elif payment['approved'] == 1:
# is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_CONFIRMED']
# else:
# is_it_accepted = MESSAGES['PAYMENT_ACCEPT_STATUS_WAITING']
# photo_path = path_recp = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])
# bot.send_photo(message.chat.id, photo=open(photo_path, 'rb'),
# caption=payment_received_template(payment,user_data,
# footer=f"{MESSAGES['PAYMENT_ACCEPT_STATUS']} {is_it_accepted}\n{MESSAGES['CREATED_AT']} {payment['created_at']}"),
# reply_markup=markups.main_menu_keyboard_markup())
def users_bot_sub_status(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_sub_status)
return
bot_user = None
if len(message.text) == 7:
user = USERS_DB.find_order_subscription(id=int(message.text))
if user:
orders = USERS_DB.find_order(id=user[0]['order_id'])
if orders:
bot_users = USERS_DB.find_user(telegram_id=orders[0]['telegram_id'])
if bot_users:
bot_user = bot_users[0]
elif len(message.text) == 8:
user = USERS_DB.find_non_order_subscription(id=int(message.text))
if user:
bot_users = USERS_DB.find_user(telegram_id=user[0]['telegram_id'])
if bot_users:
bot_user = bot_users[0]
else:
bot.send_message(message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
if not user:
bot.send_message(message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
if not bot_user:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user_uuid = user[0]['uuid']
selected_server = None
servers = USERS_DB.select_servers()
usr = None
if servers:
for server in servers:
URL = server['url'] + API_PATH
usr = utils.user_info(URL, user_uuid)
if usr:
selected_server = server
break
else:
continue
if not usr:
bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_SEARCH_SUB'],
reply_markup=markups.main_menu_keyboard_markup())
msg = templates.user_info_template(usr, selected_server)
bot.send_message(message.chat.id, msg,
reply_markup=markups.sub_search_info_markup(usr['uuid'], bot_user))
def users_bot_settings_min_depo(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_min_depo)
return
new_min_depo = utils.toman_to_rial(message.text)
new_min_depo = int(new_min_depo)
status = USERS_DB.edit_int_config("min_deposit_amount", value=new_min_depo)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_channel_id(message: Message):
if is_it_cancel(message):
return
if not message.text.startswith('@'):
bot.send_message(message.chat.id, MESSAGES['ERROR_INVALID_USERNAME'],
reply_markup=markups.main_menu_keyboard_markup())
return
status = USERS_DB.edit_str_config("channel_id", value=message.text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_welcome_msg(message: Message):
if is_it_cancel(message):
return
status = USERS_DB.edit_str_config("msg_user_start", value=message.html_text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_set_faq_msg(message: Message, msg):
if is_it_cancel(message):
return
status = USERS_DB.edit_str_config("msg_faq", value=message.html_text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
try:
bot.edit_message_reply_markup(message.chat.id, msg.message_id,
reply_markup=markups.users_bot_management_settings_faq_markup())
except:
pass
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_test_sub_size(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_test_sub_size)
return
# if float convert float else convert int
if '.' in message.text:
new_test_sub_size = float(message.text)
else:
new_test_sub_size = int(message.text)
status = USERS_DB.edit_int_config("test_sub_size_gb", value=new_test_sub_size)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_test_sub_days(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_test_sub_days)
return
new_test_sub_days = int(message.text)
status = USERS_DB.edit_int_config("test_sub_days", value=new_test_sub_days)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_notif_reminder_usage(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_notif_reminder_usage)
return
if '.' in message.text:
new_reminder_usage = float(message.text)
else:
new_reminder_usage = int(message.text)
status = USERS_DB.edit_int_config("reminder_notification_usage", value=new_reminder_usage)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_notif_reminder_days(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_notif_reminder_days)
return
new_test_sub_days = int(message.text)
status = USERS_DB.edit_int_config("reminder_notification_days", value=new_test_sub_days)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_panel_manual(message: Message, db_key):
if is_it_cancel(message):
return
status = USERS_DB.edit_str_config(db_key, value=message.html_text)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_restore_bot(message: Message):
if is_it_cancel(message):
return
# save file
file_name = message.document.file_name
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
file_save_path = os.path.join(BOT_BACKUP_LOC,"Restore")
if not os.path.exists(file_save_path):
os.makedirs(file_save_path)
# save in Backup/bot/restore
with open(os.path.join(file_save_path,file_name), 'wb') as new_file:
new_file.write(downloaded_file)
restore_status = utils.restore_json_bot(os.path.join(file_save_path,file_name))
if not restore_status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(message.chat.id, MESSAGES['SUCCESS_RESTORE_BOT'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_renewal_method_advanced_days(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_renewal_method_advanced_days)
return
new_test_sub_days = int(message.text)
status = USERS_DB.edit_int_config("advanced_renewal_days", value=new_test_sub_days)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def users_bot_settings_renewal_method_advanced_usage(message: Message):
if is_it_cancel(message):
return
if not is_it_digit(message, allow_float=True, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, users_bot_settings_renewal_method_advanced_usage)
return
if '.' in message.text:
new_renewal_usage = float(message.text)
else:
new_renewal_usage = int(message.text)
status = USERS_DB.edit_int_config("advanced_renewal_usage", value=new_renewal_usage)
if not status:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
def edit_wallet_balance(message: Message,telegram_id):
if is_it_cancel(message):
return
if not is_it_digit(message, markup=markups.while_edit_user_markup()):
bot.register_next_step_handler(message, edit_wallet_balance)
return
new_balance = utils.toman_to_rial(message.text)
wallet_status = USERS_DB.find_wallet(telegram_id=telegram_id)
if not wallet_status:
status = USERS_DB.add_wallet(telegram_id=telegram_id)
if not status:
bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
status = USERS_DB.edit_wallet(telegram_id=telegram_id, balance=new_balance)
if not status:
bot.send_message(message.chat.id, MESSAGES['UNKNOWN_ERROR'])
bot.send_message(message.chat.id, MESSAGES['SUCCESS_UPDATE_DATA'], reply_markup=markups.main_menu_keyboard_markup())
user_bot.send_message(telegram_id, f"{MESSAGES['WALLET_BALANCE_CHANGED_BY_ADMIN_P1']} {message.text} {MESSAGES['WALLET_BALANCE_CHANGED_BY_ADMIN_P2']}")
def send_message_to_user(message: Message, payment_id):
if is_it_cancel(message):
return
payment_info = USERS_DB.find_payment(id=int(payment_id))
if not payment_info:
bot.send_message(message.chat.id,
f"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\n{MESSAGES['ORDER_ID']} {payment_id}")
return
payment_info = payment_info[0]
user_bot.send_message(int(payment_info['telegram_id']),
f"{MESSAGES['ADMIN']}\n{message.text}\n{MESSAGES['ORDER_ID']} {payment_id}",
reply_markup=markups.send_message_to_user_markup(message.chat.id))
bot.send_message(message.chat.id, MESSAGES['MESSAGE_SENDED'],
reply_markup=markups.main_menu_keyboard_markup())
def users_bot_send_message_to_user(message: Message, telegram_id):
if is_it_cancel(message):
return
user_bot.send_message(int(telegram_id),
f"{MESSAGES['MESSAGE_FROM_ADMIN']}\n{MESSAGES['MESSAGE_TEXT']} {message.text}", reply_markup=markups.send_message_to_user_markup(message.chat.id))
bot.send_message(message.chat.id, MESSAGES['MESSAGE_SENDED'],
reply_markup=markups.main_menu_keyboard_markup())
# ----------------------------------- Callbacks -----------------------------------
# Callback Handler for Inline Buttons
@bot.callback_query_handler(func=lambda call: True)
def callback_query(call: CallbackQuery):
logging.info(f"Callback Query: {call.data}")
bot.answer_callback_query(call.id, MESSAGES['WAIT'])
# Check if user is not admin
if call.from_user.id not in ADMINS_ID:
bot.answer_callback_query(call.id, MESSAGES['ERROR_NOT_ADMIN'])
return
bot.clear_step_handler(call.message)
# Split Callback Data to Key(Command) and UUID
data = call.data.split(':')
key = data[0]
value = data[1]
global URL
#Single , Single_name , Single_expired , All_server_name , All_server_expired
global search_mode
# All , Single
global server_mode
global searched_name
global selected_server
#User_Orders, User_Payments, User_Gifts, Orders, Approved_Payments
#Non_Approved_Payments, Pending_Payments, Card_Payments, Digital_Payments
#Bot_User, Bot_Users_Search_Name, User_Refferals
global list_mode
#Order, Payment, Gift
global item_mode
global selected_telegram_id
# ----------------------------------- Users List Area Callbacks -----------------------------------
# Single User Info Callback
if key == "info":
if server_mode == "Single":
usr = utils.user_info(URL, value)
else:
servers = USERS_DB.select_servers()
if servers:
for server in servers:
URL = server['url'] + API_PATH
usr = utils.user_info(URL, value)
if usr:
selected_server = server
break
if not usr:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.user_info_template(usr, selected_server)
bot.send_message(call.message.chat.id, msg,
reply_markup=markups.user_info_markup(usr['uuid']))
# Next Page Callback
elif key == "next":
# users_list = utils.dict_process(utils.users_to_dict(ADMIN_DB.select_users()))
users_list = []
server_id = selected_server['id']
if search_mode == "Single":
users_list = api.select(URL)
server_id = selected_server['id']
elif search_mode == "Single_name":
users_list = utils.search_user_by_name(URL, searched_name)
server_id = selected_server['id']
elif search_mode == "Single_expired":
users_list = api.select(URL)
users_list = utils.expired_users_list(users_list)
server_id = selected_server['id']
elif search_mode == "All_server_name":
servers = USERS_DB.select_servers()
if servers:
for server in servers:
server_url = server['url'] + API_PATH
searched_users = utils.search_user_by_name(server_url, searched_name)
users_list.extend(searched_users)
server_id = "None"
elif search_mode == "All_server_expired":
servers = USERS_DB.select_servers()
if servers:
for server in servers:
server_url = server['url'] + API_PATH
users = api.select(server_url)
users = utils.expired_users_list(users)
users_list.extend(users)
server_id = "None"
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_list_markup(server_id, users_list, int(value)))
# ----------------------------------- Single User Info Area Callbacks -----------------------------------
# Delete User Callback
elif key == "user_delete":
# status = ADMIN_DB.delete_user(uuid=value)
bot.send_message(call.message.chat.id, MESSAGES['FEATUR_UNAVAILABLE'],
reply_markup=markups.main_menu_keyboard_markup())
return
# if not status:
# bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
# reply_markup=markups.main_menu_keyboard_markup())
# return
# bot.delete_message(call.message.chat.id, call.message.message_id)
# bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_USER_DELETED'],
# reply_markup=markups.main_menu_keyboard_markup())
# Edit User Main Button Callback
elif key == "user_edit":
if server_mode == "All":
servers = USERS_DB.select_servers()
if servers:
for server in servers:
users_list = api.find(server['url'] + API_PATH, value)
if users_list:
URL = server['url'] + API_PATH
selected_server = server
break
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.edit_user_markup(value))
# Configs User Callback
elif key == "user_config":
if server_mode == "All":
servers = USERS_DB.select_servers()
if servers:
for server in servers:
users_list = api.find(server['url'] + API_PATH, value)
if users_list:
URL = server['url'] + API_PATH
selected_server = server
break
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.sub_url_user_list_markup(value))
# ----------------------------------- Edit User Area Callbacks -----------------------------------
# Edit User - Update Message Callback
elif key == "user_edit_update":
usr = utils.user_info(URL, value)
if not usr:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
msg = templates.user_info_template(usr, selected_server, MESSAGES['EDITED_USER_INFO'])
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.edit_user_markup(value))
# Edit User - Edit Usage Callback
elif key == "user_edit_usage":
bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_USAGE_LIMIT'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_user_usage, value)
# Edit User - Reset Usage Callback
elif key == "user_edit_reset_usage":
status = api.update(URL, uuid=value, current_usage_GB=0)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(call.message.chat.id, MESSAGES['RESET_USAGE'],
reply_markup=markups.main_menu_keyboard_markup())
# Edit User - Edit Days Callback
elif key == "user_edit_days":
bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_DAYS'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_user_days, value)
# Edit User - Reset Days Callback
elif key == "user_edit_reset_days":
# status = ADMIN_DB.reset_package_days(uuid=value)
last_reset_time = datetime.datetime.now().strftime("%Y-%m-%d")
status = api.update(URL, uuid=value, start_date=last_reset_time)
# api.insert()
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(call.message.chat.id, MESSAGES['RESET_DAYS'], reply_markup=markups.main_menu_keyboard_markup())
# Edit User - Edit Comment Callback
elif key == "user_edit_comment":
bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_COMMENT'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_user_comment, value)
# Edit User - Edit Name Callback
elif key == "user_edit_name":
bot.send_message(call.message.chat.id, MESSAGES['ENTER_NEW_NAME'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_user_name, value)
# ----------------------------------- Configs User Info Area Callbacks -----------------------------------
# User Configs - DIR Configs Callback
elif key == "conf_dir":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
configs = utils.sub_parse(sub['sub_link'])
if not configs:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.sub_user_list_markup(value,configs))
# User Configs - VLESS Configs Callback
elif key == "conf_dir_vless":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
configs = utils.sub_parse(sub['sub_link'])
if not configs:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
if not configs['vless']:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
msgs = templates.configs_template(configs['vless'])
for message in msgs:
if message:
bot.send_message(call.message.chat.id, f"{message}",
reply_markup=markups.main_menu_keyboard_markup())
# User Configs - VMess Configs Callback
elif key == "conf_dir_vmess":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
configs = utils.sub_parse(sub['sub_link'])
if not configs:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
if not configs['vmess']:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
msgs = templates.configs_template(configs['vmess'])
for message in msgs:
if message:
bot.send_message(call.message.chat.id, f"{message}",
reply_markup=markups.main_menu_keyboard_markup())
# User Configs - Trojan Configs Callback
elif key == "conf_dir_trojan":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
configs = utils.sub_parse(sub['sub_link'])
if not configs:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
if not configs['trojan']:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CONFIG_NOT_FOUND'])
return
msgs = templates.configs_template(configs['trojan'])
for message in msgs:
if message:
bot.send_message(call.message.chat.id, f"{message}",
reply_markup=markups.main_menu_keyboard_markup())
# User Configs - Main Menu
elif key == 'configs_list':
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.sub_url_user_list_markup(value))
# User Configs - Subscription Configs Callback
elif key == "conf_sub_url":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['sub_link'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_SUB']}\n<code>{sub['sub_link']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
# User Configs - Base64 Subscription Configs Callback
elif key == "conf_sub_url_b64":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['sub_link_b64'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_SUB_B64']}\n<code>{sub['sub_link_b64']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
# User Configs - Subscription Configs For Clash Callback
elif key == "conf_clash":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['clash_configs'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_CLASH']}\n<code>{sub['clash_configs']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
# User Configs - Subscription Configs For Hiddify Callback
elif key == "conf_hiddify":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['hiddify_configs'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_HIDDIFY']}\n<code>{sub['hiddify_configs']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
elif key == "conf_sub_auto":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['sub_link_auto'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_SUB_AUTO']}\n<code>{sub['sub_link_auto']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
elif key == "conf_sub_sing_box":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['sing_box'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_SING_BOX']}\n<code>{sub['sing_box']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
elif key == "conf_sub_full_sing_box":
sub = utils.sub_links(value, URL)
if not sub:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
qr_code = utils.txt_to_qr(sub['sing_box_full'])
if not qr_code:
bot.send_message(call.message.chat.id, MESSAGES['UNKNOWN_ERROR'])
return
bot.send_photo(
call.message.chat.id,
photo=qr_code,
caption=f"{KEY_MARKUP['CONFIGS_FULL_SING_BOX']}\n<code>{sub['sing_box_full']}</code>",
reply_markup=markups.main_menu_keyboard_markup()
)
else:
bot.answer_callback_query(call.id, MESSAGES['ERROR_INVALID_COMMAND'])
# ----------------------------------- Search User Area Callbacks -----------------------------------
# Search User - Name Callback
if key == "search_name":
bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_NAME'],
reply_markup=markups.while_edit_user_markup())
if value == "None":
search_mode = "All_server_name"
bot.register_next_step_handler(call.message, all_server_search_user_name)
else:
search_mode = "Single_name"
bot.register_next_step_handler(call.message, search_user_name, value)
# Search User - UUID Callback
elif key == "search_uuid":
bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_UUID'],
reply_markup=markups.while_edit_user_markup())
if value == "None":
bot.register_next_step_handler(call.message, all_server_search_user_uuid)
else:
bot.register_next_step_handler(call.message, search_user_uuid, value)
# Search User - Config Callback
elif key == "search_config":
bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_CONFIG'],
reply_markup=markups.while_edit_user_markup())
if value == "None":
bot.register_next_step_handler(call.message, all_server_search_user_config)
else:
bot.register_next_step_handler(call.message, search_user_config, value)
# Search User - Expired Callback
elif key == "search_expired":
users_list = []
if value == "None":
search_mode = "All_server_expired"
servers = USERS_DB.select_servers()
if servers:
for server in servers:
server_url = server['url'] + API_PATH
users = api.select(server_url)
users = utils.expired_users_list(users)
users_list.extend(users)
else:
search_mode = "Single_expired"
users_list = api.select(URL)
users_list = utils.expired_users_list(users_list)
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.users_list_template(users_list, MESSAGES['EXPIRED_USERS_LIST'])
bot.send_message(call.message.chat.id, msg, reply_markup=markups.users_list_markup(value, users_list))
# ----------------------------------- Server Management Callbacks -----------------------------------
elif key == "server_selected":
server_mode = "Single"
server = USERS_DB.find_server(id=int(value))
if not server:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
URL = server['url'] + API_PATH
selected_server = server
plans = USERS_DB.select_plans()
msg = templates.server_info_template(server,plans)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.server_selected_markup(value))
# Server Management - Add Server Callback
elif key == "add_server":
bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER'],
reply_markup=markups.while_edit_user_markup())
bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_TITLE'])
bot.register_next_step_handler(call.message, add_server_title)
# Server Management - Delete Server Callback
elif key == "delete_server":
bot.edit_message_text(MESSAGES['DELETE_SERVER_QUESTION'], call.message.chat.id, call.message.message_id,
reply_markup=markups.server_delete_markup(value))
# Server Management - Edit Server Callback
elif key == "edit_server":
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.server_edit_markup(value))
# Server Management - Edit Title Server Callback
elif key == "server_edit_title":
bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_TITLE'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_server_title, value)
# Server Management - Edit User Limit Server Callback
elif key == "server_edit_user_limit":
bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_USER_LIMIT'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_server_user_limit, value)
# Server Management - Edit Url Server Callback
elif key == "server_edit_url":
bot.send_message(call.message.chat.id, MESSAGES['ADD_SERVER_URL'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_server_url, value)
# Server Management - Confirm Delete Server Callback
elif key == "confirm_delete_server":
server_id = int(value)
#status = USERS_DB.edit_server(value, status=0)
status = USERS_DB.delete_server(id=server_id)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
USERS_DB.delete_plan(server_id=server_id)
USERS_DB.delete_order_subscription(server_id=server_id)
USERS_DB.delete_non_order_subscription(server_id=server_id)
servers = USERS_DB.select_servers()
bot.edit_message_text(KEY_MARKUP['SERVERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.servers_management_markup(servers))
bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_REMOVED_SERVER'], reply_markup=markups.main_menu_keyboard_markup())
# Server Management - List of Plans for Server Callback
elif key == "server_list_of_plans":
plans_list = []
plans = USERS_DB.select_plans()
if plans:
for plan in plans:
if plan['status']:
if plan['server_id'] == int(value):
plans_list.append(plan)
plans_markup = markups.plans_list_markup(plans_list,value)
bot.edit_message_text({MESSAGES['USERS_BOT_PLANS_LIST']}, call.message.chat.id, call.message.message_id,
reply_markup=plans_markup)
elif key == "server_list_of_users":
users_list = api.select(URL)
search_mode = "Single"
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.users_list_template(users_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.users_list_markup(value, users_list))
elif key == "server_add_user":
global add_user_data
bot.send_message(call.message.chat.id, MESSAGES['ADD_USER_NAME'], reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, add_user_name, value)
elif key == "server_search_user":
bot.edit_message_text(MESSAGES['SEARCH_USER'],call.message.chat.id, call.message.message_id,
reply_markup=markups.search_user_markup(server_id=value))
# ----------------------------------- Users Bot Management Callbacks -----------------------------------
elif key == "users_bot_management_menu":
bot.edit_message_text(KEY_MARKUP['USERS_BOT_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_markup())
elif key == "bot_users_list_management":
bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_users_management_markup())
elif key == "bot_users_list":
list_mode = "Bot_Users"
users_list = USERS_DB.select_users()
wallets_list = USERS_DB.select_wallet()
orders_list = USERS_DB.select_orders()
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
users_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_users_list_template(users_list, wallets_list, orders_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_users_list_markup(users_list))
users_list.sort(key = operator.itemgetter('created_at'), reverse=True)
elif key == "search_users_bot":
bot.edit_message_text(MESSAGES['SEARCH_USER'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_users_search_method_markup())
elif key == "bot_users_search_name":
list_mode = "Bot_Users"
bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_NAME'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, search_bot_user_name)
elif key == "bot_users_search_telegram_id":
bot.send_message(call.message.chat.id, MESSAGES['SEARCH_USER_TELEGRAM_ID'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, search_bot_user_telegram_id)
elif key == "bot_user_info":
selected_telegram_id = value
users = USERS_DB.find_user(telegram_id=int(value))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
orders = USERS_DB.find_order(telegram_id=user['telegram_id'])
paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])
wallet = None
wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])
if wallets:
wallet = wallets[0]
non_order_subs = utils.non_order_user_info(user['telegram_id'])
order_subs = utils.order_user_info(user['telegram_id'])
plans_list = USERS_DB.select_plans()
msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)
bot.send_message(call.message.chat.id, msg, reply_markup=markups.bot_user_info_markup(value))
elif key == "bot_user_next":
if list_mode == "Bot_Users":
users_list = USERS_DB.select_users()
elif list_mode == "Bot_Users_Search_Name":
users_list = USERS_DB.find_user(full_name=searched_name)
elif list_mode == "User_Refferals":
users_list = USERS_DB.find_user(telegram_id=int(selected_telegram_id))
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
users_list.sort(key = operator.itemgetter('created_at'), reverse=True)
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_users_list_markup(users_list, int(value)))
elif key == "bot_user_item_info":
if item_mode == "Order":
orders = USERS_DB.find_order(id=int(value))
if not orders:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
order = orders[0]
plans = USERS_DB.find_plan(id=order['plan_id'])
if not plans:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
plan = plans[0]
#subs =
users = USERS_DB.find_user(telegram_id=order['telegram_id'])
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
servers = USERS_DB.find_server(id=plan['server_id'])
if not servers:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
server = servers[0]
msg = templates.bot_orders_info_template(order, plan, user, server)
bot.send_message(call.message.chat.id, msg)
elif item_mode == "Payment":
payments = USERS_DB.find_payment(id=int(value))
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data)
photo_path = os.path.join(os.getcwd(), 'UserBot', 'Receiptions', payment['payment_image'])
if payment['approved'] == None:
bot.send_photo(call.message.chat.id, photo=open(photo_path, 'rb'),
caption=msg, reply_markup=markups.confirm_payment_by_admin(payment['id']))
else:
bot.send_photo(call.message.chat.id, photo=open(photo_path, 'rb'),
caption=msg, reply_markup=markups.change_status_payment_by_admin(payment['id']))
elif item_mode == "Gift":
gift = USERS_DB.find_user_plans(id=int(value))
elif key == "bot_user_item_next":
if list_mode == "User_Orders":
item_list = USERS_DB.find_order(telegram_id=int(selected_telegram_id))
elif list_mode == "User_Payments":
item_list = USERS_DB.find_payment(telegram_id=int(selected_telegram_id))
elif list_mode == "User_Gifts":
item_list = USERS_DB.find_user_plans(telegram_id=int(selected_telegram_id))
elif list_mode == "Orders":
item_list = USERS_DB.select_orders()
if list_mode == "Approved_Payments":
payments_list = USERS_DB.select_payments()
item_list = [payment for payment in payments_list if payment['approved'] == 1]
elif list_mode == "Non_Approved_Payments":
payments_list = USERS_DB.select_payments()
item_list = [payment for payment in payments_list if payment['approved'] == 0]
elif list_mode == "Pending_Payments":
payments_list = USERS_DB.select_payments()
item_list = [payment for payment in payments_list if payment['approved'] == None]
elif list_mode == "Card_Payments":
payments_list = USERS_DB.select_payments()
item_list = [payment for payment in payments_list if payment['payment_method'] == "Card"]
elif list_mode == "Digital_Payments":
payments_list = USERS_DB.select_payments()
item_list = [payment for payment in payments_list if payment['payment_method'] == "Digital"]
if not item_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
if not list_mode == "User_Gifts":
item_list.sort(key = operator.itemgetter('created_at'), reverse=True)
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(item_list, int(value)))
elif key == "bot_users_sub_user_list":
server_mode = "All"
subs = utils.non_order_user_info(int(value))
order_subs = utils.order_user_info(int(value))
if order_subs:
subs.extend(order_subs)
if not subs:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_SUB_NOT_FOUND'])
return
msg = templates.users_list_template(subs)
bot.send_message(call.message.chat.id, msg, reply_markup=markups.users_list_markup("None", subs))
elif key == "users_bot_orders_user_list":
list_mode = "User_Orders"
item_mode = "Order"
orders_list = USERS_DB.find_order(telegram_id=int(value))
plans_list = USERS_DB.select_plans()
if not orders_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'])
return
orders_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_orders_list_template(orders_list, plans_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(orders_list))
elif key == "users_bot_payments_user_list":
list_mode = "User_Payments"
item_mode = "Payment"
paymets = USERS_DB.find_payment(telegram_id=int(value))
if not paymets:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
paymets.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(paymets)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(paymets))
elif key == "users_bot_wallet_edit_balance":
bot.send_message(call.message.chat.id, MESSAGES['EDIT_WALLET_BALANCE'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, edit_wallet_balance, value)
elif key == "users_bot_reset_test":
users = USERS_DB.find_user(telegram_id=int(value))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
if user['test_subscription'] == 0:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_HAVE_TEST_SUB'])
return
status = USERS_DB.edit_user(telegram_id=int(value), test_subscription=0)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_RESET_TEST_SUB'])
elif key == "users_bot_ban_user":
users = USERS_DB.find_user(telegram_id=int(value))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
if user['banned'] == 0:
status = USERS_DB.edit_user(telegram_id=int(value), banned=1)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_BAN_USER'])
return
if user['banned'] == 1:
status = USERS_DB.edit_user(telegram_id=int(value), banned=0)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_UNBAN_USER'])
return
elif key == "users_bot_gifts_user_list":
list_mode = "User_Gifts"
item_mode = "Gift"
gift = USERS_DB.find_user_plans(telegram_id=int(value))
if not gift:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_GIFT_NOT_FOUND'])
return
# msg = templates.bot_gift_list_template(paymets)
# bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
# reply_markup=markups.bot_user_item_list_markup(gift))
elif key == "users_bot_referred_user_list":
list_mode = "User_Refferals"
users = USERS_DB.find_user(telegram_id=int(value))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
#referred_user =
elif key == "users_bot_orders_list_management":
bot.edit_message_text(KEY_MARKUP['ORDERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_orders_management_markup())
elif key == "users_bot_orders_list":
list_mode = "Orders"
item_mode = "Order"
orders_list = USERS_DB.select_orders()
plans_list = USERS_DB.select_plans()
if not orders_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_ORDER_NOT_FOUND'])
return
orders_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_orders_list_template(orders_list, plans_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(orders_list))
elif key == "search_orders":
bot.send_message(call.message.chat.id, MESSAGES['ORDER_NUMBER_REQUEST'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, search_bot_user_order)
elif key == "users_bot_payments_list_management":
bot.edit_message_text(KEY_MARKUP['PAYMENT_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_payments_management_markup())
elif key == "search_payments":
bot.send_message(call.message.chat.id, MESSAGES['PAYMENT_NUMBER_REQUEST'],
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, search_bot_user_payment)
elif key == "bot_users_approved_payments_list":
list_mode = "Approved_Payments"
item_mode = "Payment"
payments_list = USERS_DB.select_payments()
if not payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
approved_payments_list = [payment for payment in payments_list if payment['approved'] == 1]
if not approved_payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
approved_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(approved_payments_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(approved_payments_list))
elif key == "users_bot_non_approved_payments_list":
list_mode = "Non_Approved_Payments"
item_mode = "Payment"
payments_list = USERS_DB.select_payments()
if not payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
non_approved_payments_list = [payment for payment in payments_list if payment['approved'] == 0]
if not non_approved_payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
non_approved_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(non_approved_payments_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(non_approved_payments_list))
elif key == "users_bot_pending_payments_list":
list_mode = "Pending_Payments"
item_mode = "Payment"
payments_list = USERS_DB.select_payments()
if not payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
pending_payments_list = [payment for payment in payments_list if payment['approved'] == None]
if not pending_payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
pending_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(pending_payments_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(pending_payments_list))
elif key == "users_bot_card_payments_list":
list_mode = "Card_Payments"
item_mode = "Payment"
payments_list = USERS_DB.select_payments()
if not payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
card_payments_list = [payment for payment in payments_list if payment['payment_method'] == "Card"]
if not card_payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
card_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(card_payments_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(card_payments_list))
elif key == "users_bot_digital_payments_list":
list_mode = "Digital_Payments"
item_mode = "Payment"
payments_list = USERS_DB.select_payments()
if not payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
digital_payments_list = [payment for payment in payments_list if payment['payment_method'] == "Digital"]
if not digital_payments_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
digital_payments_list.sort(key = operator.itemgetter('created_at'), reverse=True)
msg = templates.bot_payments_list_template(digital_payments_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_item_list_markup(digital_payments_list))
# Plan Management - Add Plan Callback
elif key == "users_bot_add_plan":
bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN'],
reply_markup=markups.while_edit_user_markup())
bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_ADD_PLAN_USAGE'])
add_plan_data['server_id'] = int(value)
bot.register_next_step_handler(call.message, users_bot_add_plan_usage)
# Plan Management - Info Plan Callback
elif key == "info_plan_selected":
plans= USERS_DB.find_plan(id=value)
if not plans:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
orders = USERS_DB.find_order(plan_id=value)
plan = plans[0]
msg = templates.plan_info_template(plan, orders)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.plan_info_selected_markup(plan['server_id']))
# Plan Management - Edit Plan Callback
elif key == "users_bot_del_plan":
status = USERS_DB.edit_plan(value, status=0)
if status:
plans= USERS_DB.find_plan(id=value)
if not plans:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
del_plan = plans[0]
server_id = del_plan['server_id']
plans_list = []
plans = USERS_DB.select_plans()
if plans:
for plan in plans:
if plan['status']:
if plan['server_id'] == server_id:
plans_list.append(plan)
plans_markup = markups.plans_list_markup(plans_list, server_id,delete_mode = True)
bot.edit_message_text({MESSAGES['USERS_BOT_SELECT_PLAN_TO_DELETE']}, call.message.chat.id, call.message.message_id,
reply_markup=plans_markup)
else:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
# Plan Management - List Plans Callback
elif key == "users_bot_list_plans":
plans_list = []
plans = USERS_DB.select_plans()
if plans:
for plan in plans:
if plan['status']:
if plan['server_id'] == int(value):
plans_list.append(plan)
plans_markup = markups.plans_list_markup(plans_list,value,delete_mode = True)
bot.edit_message_text({MESSAGES['USERS_BOT_SELECT_PLAN_TO_DELETE']}, call.message.chat.id, call.message.message_id,
reply_markup=plans_markup)
# Owner Info - Edit Owner Info Callback
elif key == "users_bot_owner_info":
owner_info = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
templates.owner_info_template(owner_info['support_username'], owner_info['card_number'],
owner_info['card_holder']),
reply_markup=markups.users_bot_edit_owner_info_markup())
# Owner Info - Edit Owner Username Callback
elif key == "users_bot_owner_info_edit_username":
bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_USERNAME']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_edit_owner_info_username)
# Owner Info - Edit Owner Card Number Callback
elif key == "users_bot_owner_info_edit_card_number":
bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_CARD_NUMBER']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_edit_owner_info_card_number)
# Owner Info - Edit Owner Cardholder Callback
elif key == "users_bot_owner_info_edit_card_name":
bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_OWNER_INFO_ADD_CARD_NAME']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_edit_owner_info_card_name)
# Send Message - Send Message To All Users Callback
elif key == "users_bot_send_msg_users":
bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_SEND_MSG_USERS']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_send_msg_users)
# User Bot Settings - Main Settings Callback
elif key == "users_bot_settings":
settings = USERS_DB.select_bool_config()
if not settings:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
bot.edit_message_text(MESSAGES['USERS_BOT_SETTINGS'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_markup(settings))
# User Bot Settings - Set Hyperlink Status Callback
elif key == "users_bot_settings_hyperlink":
if value == "1":
edit_config = USERS_DB.edit_bool_config("visible_hiddify_hyperlink", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("visible_hiddify_hyperlink", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
# User Bot Settings - Set three random letters for define price
elif key == "users_bot_settings_three_rand_price":
if value == "1":
edit_config = USERS_DB.edit_bool_config("three_random_num_price", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("three_random_num_price", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_panel_auto_backup":
if value == "1":
edit_config = USERS_DB.edit_bool_config("panel_auto_backup", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("panel_auto_backup", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_bot_auto_backup":
if value == "1":
edit_config = USERS_DB.edit_bool_config("bot_auto_backup", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("bot_auto_backup", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_min_depo":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {utils.rial_to_toman(settings['min_deposit_amount'])}\n{MESSAGES['USERS_BOT_SETTING_MIN_DEPO']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_min_depo)
# elif key == "users_bot_settings_panel_v8":
# if value == "1":
# edit_config = USERS_DB.edit_bool_config("hiddify_v8_feature", value=False)
# if not edit_config:
# bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
# return
# elif value == "0":
# edit_config = USERS_DB.edit_bool_config("hiddify_v8_feature", value=True)
# if not edit_config:
# bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
# return
# users_bot_settings_update_message(call.message)
elif key == "users_bot_settings_channel_id":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['channel_id']}\n{MESSAGES['USERS_BOT_SETTING_CHANNEL_ID']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_channel_id)
elif key == "users_bot_settings_force_join":
settings = utils.all_configs_settings()
if not settings['channel_id']:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CHANNEL_ID_NOT_SET'])
return
if value == "1":
edit_config = USERS_DB.edit_bool_config("force_join_channel", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("force_join_channel", value=True)
bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_SETTING_FORCE_JOIN_HELP'])
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_visible_sub_menu":
settings = utils.all_configs_settings()
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_visible_sub_markup(settings))
elif key == "users_bot_settings_visible_sub":
settings = utils.all_configs_settings()
row_key = value
current_status = settings[row_key]
if current_status == 1:
edit_config = USERS_DB.edit_bool_config(row_key, value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif current_status == 0:
edit_config = USERS_DB.edit_bool_config(row_key, value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message,
markups.users_bot_management_settings_visible_sub_markup(settings))
elif key == "users_bot_settings_set_welcome_msg":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['msg_user_start']}\n{MESSAGES['USERS_BOT_SETTING_WELCOME_MSG']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_welcome_msg)
elif key == "users_bot_settings_faq_management":
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_faq_markup())
elif key == "users_bot_settings_set_faq_msg":
settings = utils.all_configs_settings()
faq_text = settings['msg_faq']
msg = call.message
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {faq_text}\n{MESSAGES['USERS_BOT_SETTING_FAQ_MSG']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_set_faq_msg, msg)
elif key == "users_bot_settings_hide_faq":
settings = utils.all_configs_settings()
status = USERS_DB.edit_str_config("msg_faq", value=None)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_faq_markup())
elif key == "users_bot_settings_test_sub_menu":
settings = utils.all_configs_settings()
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_test_sub_markup(settings))
elif key == "users_bot_settings_test_sub":
settings = utils.all_configs_settings()
row_key = value
current_status = settings['test_subscription']
if current_status == 1:
edit_config = USERS_DB.edit_bool_config(row_key, value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif current_status == 0:
edit_config = USERS_DB.edit_bool_config(row_key, value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_test_sub_markup(settings))
elif key == "users_bot_settings_test_sub_size":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['test_sub_size_gb']} {MESSAGES['GB']}\n{MESSAGES['USERS_BOT_SETTINGS_TEST_SUB_USAGE']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_test_sub_size)
elif key == "users_bot_settings_test_sub_days":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['test_sub_days']} {MESSAGES['DAY']}\n{MESSAGES['USERS_BOT_SETTINGS_TEST_SUB_DAYS']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_test_sub_days)
# User Bot Settings - Reminder Notification Callback
elif key == "users_bot_settings_notif_reminder_menu":
settings = utils.all_configs_settings()
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_notif_reminder_markup(
settings))
elif key == "users_bot_settings_notif_reminder":
settings = utils.all_configs_settings()
row_key = value
current_status = settings['reminder_notification']
if current_status == 1:
edit_config = USERS_DB.edit_bool_config(row_key, value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif current_status == 0:
edit_config = USERS_DB.edit_bool_config(row_key, value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message,
markups.users_bot_management_settings_notif_reminder_markup(settings))
elif key == "users_bot_settings_notif_reminder_usage":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['reminder_notification_usage']} {MESSAGES['GB']}\n{MESSAGES['USERS_BOT_SETTINGS_NOTIF_REMINDER_USAGE']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_notif_reminder_usage)
elif key == "users_bot_settings_notif_reminder_days":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['reminder_notification_days']} {MESSAGES['DAY']}\n{MESSAGES['USERS_BOT_SETTINGS_NOTIF_REMINDER_DAYS']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_notif_reminder_days)
elif key == "users_bot_settings_panel_manual_menu":
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_panel_manual_markup())
elif key == "users_bot_settings_panel_manual":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings[value]}\n{MESSAGES['USERS_BOT_SETTINGS_PANEL_MANUAL']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_panel_manual, value)
elif key == "users_bot_settings_backup_bot":
backup_file = utils.backup_json_bot()
if not backup_file:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.send_document(call.message.chat.id, open(backup_file, 'rb'),caption=MESSAGES['USERS_BOT_SETTINGS_BACKUP_BOT'])
elif key == "users_bot_settings_restore_bot":
bot.send_message(call.message.chat.id, MESSAGES['USERS_BOT_SETTINGS_RESTORE_BOT'], reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_restore_bot)
elif key == "users_bot_settings_buy_sub_status":
if value == "1":
edit_config = USERS_DB.edit_bool_config("buy_subscription_status", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("buy_subscription_status", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_renewal_sub_status":
if value == "1":
edit_config = USERS_DB.edit_bool_config("renewal_subscription_status", value=False)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "0":
edit_config = USERS_DB.edit_bool_config("renewal_subscription_status", value=True)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_markup(settings))
elif key == "users_bot_settings_renewal_method_menu":
settings = utils.all_configs_settings()
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_renewal_method_markup(settings))
elif key == "users_bot_settings_renewal_method":
if value == "1":
edit_config = USERS_DB.edit_int_config("renewal_method", value=1)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "2":
edit_config = USERS_DB.edit_int_config("renewal_method", value=2)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
elif value == "3":
edit_config = USERS_DB.edit_int_config("renewal_method", value=3)
if not edit_config:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
settings = utils.all_configs_settings()
users_bot_settings_update_message(call.message, markups.users_bot_management_settings_renewal_method_markup(settings))
elif key == "users_bot_settings_renewal_method_advanced_days":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['advanced_renewal_days']} {MESSAGES['DAY']}\n{MESSAGES['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_DAYS']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_renewal_method_advanced_days)
elif key == "users_bot_settings_renewal_method_advanced_usage":
settings = utils.all_configs_settings()
bot.send_message(call.message.chat.id,
f"{MESSAGES['CURRENT_VALUE']}: {settings['advanced_renewal_usage']} {MESSAGES['GB']}\n{MESSAGES['USERS_BOT_SETTINGS_RENEWAL_METHOD_ADVANCED_USAGE']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_settings_renewal_method_advanced_usage)
# User Bot Settings - Order Status Callback
# elif key == "users_bot_orders_status":
# bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_ORDER_NUMBER_REQUEST']}")
# bot.register_next_step_handler(call.message, users_bot_order_status)
elif key == "users_bot_sub_status":
bot.send_message(call.message.chat.id, f"{MESSAGES['USERS_BOT_SUB_ID_REQUEST']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_sub_status)
elif key == "users_bot_settings_reset_free_test_limit_question":
bot.edit_message_text(MESSAGES['USERS_BOT_SETTINGS_RESET_FREE_TEST_LIMIT_QUESTION'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_management_settings_reset_free_test_markup())
elif key == "users_bot_management_settings_reset_free_test_confirm":
users_list = USERS_DB.select_users()
free_test_bot_users = [user for user in users_list if user['test_subscription']]
if free_test_bot_users:
for user in free_test_bot_users:
status = USERS_DB.edit_user(telegram_id=user['telegram_id'],test_subscription=False)
if not status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'], reply_markup=markups.main_menu_keyboard_markup())
return
bot.send_message(call.message.chat.id, MESSAGES['SUCCESS_RESET_FREE_TEST'], reply_markup=markups.main_menu_keyboard_markup())
else:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'], reply_markup=markups.main_menu_keyboard_markup())
# ----------------------------------- Payment Callbacks -----------------------------------
# Payment - Confirm Payment Callback
elif key == "confirm_payment_by_admin":
if not CLIENT_TOKEN:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
payment_id = value
payment_info = USERS_DB.find_payment(id=payment_id)
if not payment_info:
bot.send_message(call.message.chat.id,
f"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\n{MESSAGES['ORDER_ID']} {payment_id}")
return
payment_info = payment_info[0]
if payment_info['approved'] == 1:
bot.send_message(call.message.chat.id,
f"{MESSAGES['ERROR_PAYMENT_ALREADY_CONFIRMED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
return
wallet = USERS_DB.find_wallet(telegram_id=payment_info['telegram_id'])
if not wallet:
create_wallet_status = USERS_DB.add_wallet(payment_info['telegram_id'])
if not create_wallet_status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
wallet = USERS_DB.find_wallet(telegram_id=payment_info['telegram_id'])
wallet = wallet[0]
payment_status = USERS_DB.edit_payment(payment_id, approved=True)
if payment_status:
new_balance = int(wallet['balance']) + int(payment_info['payment_amount'])
wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)
if not wallet_status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.delete_message(call.message.chat.id, call.message.message_id)
user_bot.send_message(int(payment_info['telegram_id']),
f"{MESSAGES['WALLET_PAYMENT_CONFIRMED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
bot.send_message(call.message.chat.id,
f"{MESSAGES['PAYMENT_CONFIRMED_ADMIN']}\n{MESSAGES['ORDER_ID']} {payment_id}")
# Payment - Reject Payment Callback
elif key == 'cancel_payment_by_admin':
if not CLIENT_TOKEN:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
payment_id = value
payment_info = USERS_DB.find_payment(id=payment_id)
if not payment_info:
bot.send_message(call.message.chat.id,
f"{MESSAGES['ERROR_PAYMENT_NOT_FOUND']}\n{MESSAGES['ORDER_ID']} {payment_id}")
return
payment_info = payment_info[0]
if payment_info['approved'] == 0:
bot.send_message(call.message.chat.id,
f"{MESSAGES['ERROR_PAYMENT_ALREADY_REJECTED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
return
payment_status = USERS_DB.edit_payment(payment_id, approved=False)
if payment_status:
user_bot.send_message(int(payment_info['telegram_id']),
f"{MESSAGES['PAYMENT_NOT_CONFIRMED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
bot.send_message(call.message.chat.id,
f"{MESSAGES['PAYMENT_NOT_CONFIRMED_ADMIN']}\n{MESSAGES['ORDER_ID']}: {payment_id}")
bot.delete_message(call.message.chat.id, call.message.message_id)
else:
bot.send_message(call.message.chat.id, f"{MESSAGES['ERROR_UNKNOWN']}\n{MESSAGES['ORDER_ID']}: {payment_id}")
# Payment - Change status Payment Callback
elif key == "change_status_payment_by_admin":
payments = USERS_DB.find_payment(id=int(value))
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data, footer=MESSAGES['CHANGE_STATUS_PAYMENT_CONFIRM_REQUEST'])
bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.confirm_change_status_payment_by_admin(value))
# Payment - Confirm change status Payment Callback
elif key == "confirm_change_status_payment_by_admin":
if not CLIENT_TOKEN:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
payment_id = int(value)
payments = USERS_DB.find_payment(id=payment_id)
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
if payment['approved']:
payment_status = USERS_DB.edit_payment(payment_id, approved=False)
if payment_status:
wallet = USERS_DB.find_wallet(telegram_id=payment['telegram_id'])
if not wallet:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
wallet = wallet[0]
new_balance = int(wallet['balance']) - int(payment['payment_amount'])
wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)
if not wallet_status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
payments = USERS_DB.find_payment(id=payment_id)
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data)
bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.change_status_payment_by_admin(value))
user_bot.send_message(int(payment['telegram_id']),
f"{MESSAGES['PAYMENT_CHANGED_TO_NOT_CONFIRMED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
bot.send_message(call.message.chat.id,
f"{MESSAGES['PAYMENT_CHANGED_TO_NOT_CONFIRMED_ADMIN']}\n{MESSAGES['ORDER_ID']} {payment_id}")
elif payment['approved'] == False:
payment_status = USERS_DB.edit_payment(payment_id, approved=True)
if payment_status:
wallet = USERS_DB.find_wallet(telegram_id=payment['telegram_id'])
if not wallet:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
wallet = wallet[0]
new_balance = int(wallet['balance']) + int(payment['payment_amount'])
wallet_status = USERS_DB.edit_wallet(wallet['telegram_id'], balance=new_balance)
if not wallet_status:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
payments = USERS_DB.find_payment(id=payment_id)
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data)
bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.change_status_payment_by_admin(value))
user_bot.send_message(int(payment['telegram_id']),
f"{MESSAGES['WALLET_CHANGED_TO_PAYMENT_CONFIRMED']}\n{MESSAGES['ORDER_ID']} {payment_id}")
bot.send_message(call.message.chat.id,
f"{MESSAGES['PAYMENT_CHANGED_TO_CONFIRMED_ADMIN']}\n{MESSAGES['ORDER_ID']} {payment_id}")
elif key == "cancel_change_status_payment_by_admin":
payments = USERS_DB.find_payment(id=int(value))
if not payments:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_PAYMENT_NOT_FOUND'])
return
payment = payments[0]
user_data = USERS_DB.find_user(telegram_id=payment['telegram_id'])
if not user_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
user_data = user_data[0]
msg = templates.bot_payment_info_template(payment,user_data)
bot.edit_message_caption(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.change_status_payment_by_admin(value))
# Payment - Send Message Callback
elif key == "send_message_by_admin":
if not CLIENT_TOKEN:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
bot.send_message(call.message.chat.id, f"{MESSAGES['SEND_MESSAGE_TO_USER']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, send_message_to_user, value)
elif key == "users_bot_send_message_by_admin":
if not CLIENT_TOKEN:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
bot.send_message(call.message.chat.id, f"{MESSAGES['SEND_MESSAGE_TO_USER']}",
reply_markup=markups.while_edit_user_markup())
bot.register_next_step_handler(call.message, users_bot_send_message_to_user, value)
# Back to User Panel Callback
elif key == "back_to_user_panel":
usr = utils.user_info(URL, value)
if not usr:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.user_info_template(usr, selected_server)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.user_info_markup(usr['uuid']))
elif key == "back_to_sub_url_user_list":
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id,
reply_markup=markups.sub_url_user_list_markup(value))
elif key == "back_to_server_management":
servers = USERS_DB.select_servers()
bot.edit_message_text(KEY_MARKUP['SERVERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.servers_management_markup(servers))
elif key == "back_to_server_list_of_plans":
plans_list = []
plans = USERS_DB.select_plans()
if plans:
for plan in plans:
if plan['status']:
if plan['server_id'] == int(value):
plans_list.append(plan)
plans_markup = markups.plans_list_markup(plans_list,value)
bot.edit_message_text({MESSAGES['USERS_BOT_PLANS_LIST']}, call.message.chat.id, call.message.message_id,
reply_markup=plans_markup)
elif key == "back_to_server_selected":
if search_mode == "Single":
server = USERS_DB.find_server(id=int(value))
if not server:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
plans = USERS_DB.select_plans()
msg = templates.server_info_template(server,plans)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.server_selected_markup(value))
else:
bot.edit_message_text(MESSAGES['SEARCH_USER'],call.message.chat.id, call.message.message_id,
reply_markup=markups.search_user_markup(server_id=value))
search_mode = "Single"
elif key == "back_to_server_user_list":
users_list = api.select(URL)
if not users_list:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
return
msg = templates.users_list_template(users_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.users_list_markup(value, users_list))
elif key == "back_to_users_bot_users_management":
bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_users_management_markup())
elif key == "back_to_bot_users_or_reffral_management":
if list_mode == "Bot_Users_Search_Name" or "Bot_User":
bot.edit_message_text(KEY_MARKUP['BOT_USERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_users_management_markup())
elif list_mode == "User_Refferals":
users = USERS_DB.find_user(telegram_id=int(selected_telegram_id))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
orders = USERS_DB.find_order(telegram_id=user['telegram_id'])
paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])
wallet = None
wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])
if wallets:
wallet = wallets[0]
non_order_subs = utils.non_order_user_info(user['telegram_id'])
order_subs = utils.order_user_info(user['telegram_id'])
plans_list = USERS_DB.select_plans()
msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)
bot.send_message(call.message.chat.id, msg, reply_markup=markups.bot_user_info_markup(value))
elif key == "back_management_item_list":
approved_payments = list_mode == "Approved_Payments"
non_approved_payments = list_mode == "Non_Approved_Payments"
pending_payments = list_mode == "Pending_Payments"
card_payments = list_mode == "Card_Payments"
digital_payments = list_mode == "Digital_Payments"
if list_mode == "Orders":
bot.edit_message_text(KEY_MARKUP['ORDERS_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_orders_management_markup())
elif approved_payments or non_approved_payments or pending_payments or card_payments or digital_payments:
bot.edit_message_text(KEY_MARKUP['PAYMENT_MANAGEMENT'], call.message.chat.id, call.message.message_id,
reply_markup=markups.users_bot_payments_management_markup())
elif list_mode == "User_Payments" or list_mode == "User_Gifts" or list_mode == "User_Orders":
users = USERS_DB.find_user(telegram_id=int(selected_telegram_id))
if not users:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'],
reply_markup=markups.main_menu_keyboard_markup())
return
user = users[0]
orders = USERS_DB.find_order(telegram_id=user['telegram_id'])
paymets = USERS_DB.find_payment(telegram_id=user['telegram_id'])
wallet = None
wallets = USERS_DB.find_wallet(telegram_id=user['telegram_id'])
if wallets:
wallet = wallets[0]
non_order_subs = utils.non_order_user_info(user['telegram_id'])
order_subs = utils.order_user_info(user['telegram_id'])
plans_list = USERS_DB.select_plans()
msg = templates.bot_users_info_template(user, orders, paymets, wallet, non_order_subs, order_subs, plans_list)
bot.edit_message_text(msg, call.message.chat.id, call.message.message_id,
reply_markup=markups.bot_user_info_markup(selected_telegram_id))
elif key == "server_status":
from Utils.serverInfo import get_server_status
msg_wait = bot.send_message(call.message.chat.id, MESSAGES['WAIT'])
server = USERS_DB.find_server(id=int(value))
if not server:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_SERVER_NOT_FOUND'])
return
server = server[0]
server_status_data = get_server_status(server)
if not server_status_data:
bot.send_message(call.message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.delete_message(call.message.chat.id, msg_wait.message_id)
bot.send_message(call.message.chat.id, server_status_data, reply_markup=markups.main_menu_keyboard_markup())
elif key == "del_msg":
bot.delete_message(call.message.chat.id, call.message.message_id)
# Check Admin Permission
@bot.message_handler(func=lambda message: message.chat.id not in ADMINS_ID)
def not_admin(message: Message):
bot.reply_to(message, MESSAGES['ERROR_NOT_ADMIN'])
# Send Welcome Message Handler
@bot.message_handler(commands=['help', 'start', 'restart'])
def send_welcome(message: Message):
bot.reply_to(message, MESSAGES['WELCOME'], reply_markup=markups.main_menu_keyboard_markup())
bot.send_message(message.chat.id, MESSAGES['REQUEST_JOIN_HIDY'], reply_markup=markups.start_bot_markup())
# Send users list Message Handler
# @bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_LIST'])
# def all_users_list(message: Message):
# # users_list = utils.dict_process(utils.users_to_dict(ADMIN_DB.select_users()))
# users_list = api.select(URL)
# if not users_list:
# bot.send_message(message.chat.id, MESSAGES['ERROR_USER_NOT_FOUND'])
# return
# msg = templates.users_list_template(users_list)
# bot.send_message(message.chat.id, msg, reply_markup=markups.users_list_markup(users_list))
# Add User Message Handler
# @bot.message_handler(func=lambda message: message.text == KEY_MARKUP['ADD_USER'])
# def add_user(message: Message):
# global add_user_data
# bot.send_message(message.chat.id, MESSAGES['ADD_USER_NAME'], reply_markup=markups.while_add_user_markup())
# bot.register_next_step_handler(message, add_user_name)
# Panel Backup Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVER_BACKUP'])
def server_backup(message: Message):
msg_wait = bot.send_message(message.chat.id, MESSAGES['WAIT'])
zip_file_name = utils.full_backup()
if not zip_file_name:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
logging.error("Backup failed")
return
if message.chat.id in ADMINS_ID:
bot.send_document(message.chat.id, open(zip_file_name, 'rb'), caption="🤖Backup",disable_notification=True)
else:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
bot.delete_message(message.chat.id, msg_wait.message_id)
# Server Status Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVER_STATUS'])
def server_status(message: Message):
servers = USERS_DB.select_servers()
bot.send_message(message.chat.id, KEY_MARKUP['SERVER_STATUS'],
reply_markup=markups.server_status_markup(servers))
# Search User Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_SEARCH'])
def search_user(message: Message):
global server_mode
server_mode = "All"
bot.send_message(message.chat.id, MESSAGES['SEARCH_USER'],
reply_markup=markups.search_user_markup())
# Users Bot Management Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['USERS_BOT_MANAGEMENT'])
def users_bot_management(message: Message):
if not CLIENT_TOKEN:
bot.send_message(message.chat.id, MESSAGES['ERROR_CLIENT_TOKEN'])
return
bot.send_message(message.chat.id, KEY_MARKUP['USERS_BOT_MANAGEMENT'],
reply_markup=markups.users_bot_management_markup())
# Server Management Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['SERVERS_MANAGEMENT'])
def servers_management(message: Message):
servers = USERS_DB.select_servers()
bot.send_message(message.chat.id, KEY_MARKUP['SERVERS_MANAGEMENT'],
reply_markup=markups.servers_management_markup(servers))
# About Message Handler
@bot.message_handler(func=lambda message: message.text == KEY_MARKUP['ABOUT_BOT'])
def about_bot(message: Message):
bot.send_message(message.chat.id, templates.about_template())
# Debug Handler
@bot.message_handler(commands=['debug'])
def debug(message: Message):
debug_zip = utils.debug_data()
if not debug_zip:
bot.send_message(message.chat.id, MESSAGES['ERROR_UNKNOWN'])
return
bot.send_document(message.chat.id, open(debug_zip, 'rb'), caption="👹Debug")
# ----------------------------------- Main -----------------------------------
# Start Bot
def start():
# Bot Start Commands
try:
bot.set_my_commands([
telebot.types.BotCommand("/start", BOT_COMMANDS['START']),
telebot.types.BotCommand("/debug", BOT_COMMANDS['DEBUG']),
])
except telebot.apihelper.ApiTelegramException as e:
if e.result.status_code == 401:
logging.error("Invalid Telegram Bot Token!")
exit(1)
# Welcome to Admin
for admin in ADMINS_ID:
try:
bot.send_message(admin, MESSAGES['WELCOME_TO_ADMIN'])
except Exception as e:
logging.warning(f"Error in send message to admin {admin}: {e}")
bot.enable_save_next_step_handlers()
bot.load_next_step_handlers()
bot.infinity_polling()
================================================
FILE: AdminBot/content.py
================================================
import os
import json
from config import LANG
FOLDER = "Json"
MSG_FILE = "messages.json"
BTN_FILE = "buttons.json"
CMD_FILE = "commands.json"
with open(os.path.join(os.path.dirname(__file__),FOLDER, MSG_FILE), encoding='utf-8') as f:
MESSAGES = json.load(f)
MESSAGES = MESSAGES[LANG]
with open(os.path.join(os.path.dirname(__file__),FOLDER, BTN_FILE), encoding='utf-8') as f:
KEY_MARKUP = json.load(f)
KEY_MARKUP = KEY_MARKUP[LANG]
with open(os.path.join(os.path.dirname(__file__),FOLDER, CMD_FILE), encoding='utf-8') as f:
BOT_COMMANDS = json.load(f)
BOT_COMMANDS = BOT_COMMANDS[LANG]
================================================
FILE: AdminBot/markups.py
================================================
# Description: This file contains all the reply and inline keyboard markups used in the bot.
from telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton
from AdminBot.content import KEY_MARKUP
from AdminBot.content import MESSAGES
from config import CLIENT_TOKEN, HIDY_BOT_ID
from Utils.utils import all_configs_settings, rial_to_toman
# Main Menu Reply Keyboard Markup
def main_menu_keyboard_markup():
markup = ReplyKeyboardMarkup(row_width=3, resize_keyboard=True)
#markup.add(KeyboardButton(KEY_MARKUP['USERS_LIST']))
#markup.add(KeyboardButton(KEY_MARKUP['USERS_SEARCH']), KeyboardButton(KEY_MARKUP['ADD_USER']))
markup.add(KeyboardButton(KEY_MARKUP['SERVERS_MANAGEMENT']))
markup.add(KeyboardButton(KEY_MARKUP['USERS_SEARCH']))
if CLIENT_TOKEN:
markup.add(KeyboardButton(KEY_MARKUP['USERS_BOT_MANAGEMENT']))
markup.add()
markup.add(KeyboardButton(KEY_MARKUP['SERVER_STATUS']), KeyboardButton(KEY_MARKUP['ABOUT_BOT']),
KeyboardButton(KEY_MARKUP['SERVER_BACKUP']))
return markup
#----------------------------------Hiddify User ---------------------------------
# Users List Inline Keyboard Markup
def users_list_markup(server_id, users, page=1):
markup = InlineKeyboardMarkup(row_width=3)
USER_PER_PAGE = 20
start = (page - 1) * USER_PER_PAGE
end = start + USER_PER_PAGE
keys = []
for user in users[start:end]:
status_tag = ""
if user['last_connection'] == "Online" or user['last_connection'] == "آنلاین":
status_tag = "🔵"
else:
status_tag = "🟡"
if user['remaining_day'] == 0:
status_tag = "🔴"
if user['usage']['remaining_usage_GB'] <= 0:
status_tag = "🔴️"
keys.append(InlineKeyboardButton(f"{status_tag}|{user['name']}", callback_data=f"info:{user['uuid']}"))
markup.add(*keys)
if page < len(users) / USER_PER_PAGE:
markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f"next:{page + 1}"), row_width=2)
if page > 1:
markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f"next:{page - 1}"), row_width=1)
if server_id != "None":
markup.add(InlineKeyboardButton(KEY_MARKUP['ADD_USER'], callback_data=f"server_add_user:{server_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_SEARCH'], callback_data=f"server_search_user:{server_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_server_selected:{server_id}"))
return markup
# Single User Inline Keyboard Markup
def user_info_markup(uuid):
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_USER'], callback_data=f"user_config:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_USER'], callback_data=f"user_edit:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['DELETE_USER'], callback_data=f"user_delete:{uuid}"))
return markup
# Single User Edit Inline Keyboard Markup
def edit_user_markup(uuid):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_NAME'], callback_data=f"user_edit_name:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_USAGE'], callback_data=f"user_edit_usage:{uuid}"),
InlineKeyboardButton(KEY_MARKUP['RESET_USAGE'], callback_data=f"user_edit_reset_usage:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_DAYS'], callback_data=f"user_edit_days:{uuid}"),
InlineKeyboardButton(KEY_MARKUP['RESET_DAYS'], callback_data=f"user_edit_reset_days:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_COMMENT'], callback_data=f"user_edit_comment:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['UPDATE_MESSAGE'], callback_data=f"user_edit_update:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_user_panel:{uuid}"))
return markup
# # Add User Reply Keyboard Markup
# def while_add_user_markup():
# markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
# markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))
# return markup
# Edit User Reply Keyboard Markup
def while_edit_user_markup():
markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))
return markup
def while_edit_skip_user_markup():
markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
markup.add(KeyboardButton(KEY_MARKUP['SKIP']))
markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))
return markup
# Confirm Add User Reply Keyboard Markup
def confirm_add_user_markup():
markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
markup.add(KeyboardButton(KEY_MARKUP['CONFIRM']))
markup.add(KeyboardButton(KEY_MARKUP['CANCEL']))
return markup
# Subscription URL Inline Keyboard Markup
def sub_url_user_list_markup(uuid):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_DIR'], callback_data=f"conf_dir:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_AUTO'], callback_data=f"conf_sub_auto:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB'], callback_data=f"conf_sub_url:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SUB_B64'], callback_data=f"conf_sub_url_b64:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_CLASH'], callback_data=f"conf_clash:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_HIDDIFY'], callback_data=f"conf_hiddify:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_SING_BOX'], callback_data=f"conf_sub_sing_box:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CONFIGS_FULL_SING_BOX'],
callback_data=f"conf_sub_full_sing_box:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_user_panel:{uuid}"))
return markup
# Subscription Configs Inline Keyboard Markup
def sub_user_list_markup(uuid,configs):
markup = InlineKeyboardMarkup()
markup.row_width = 1
if configs['vless']:
markup.add(InlineKeyboardButton('Vless', callback_data=f"conf_dir_vless:{uuid}"))
if configs['vmess']:
markup.add(InlineKeyboardButton('Vmess', callback_data=f"conf_dir_vmess:{uuid}"))
if configs['trojan']:
markup.add(InlineKeyboardButton('Trojan', callback_data=f"conf_dir_trojan:{uuid}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_sub_url_user_list:{uuid}"))
return markup
# Search User Inline Keyboard Markup
def search_user_markup(server_id=None):
callback_data = server_id if server_id else "None"
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_NAME'], callback_data=f"search_name:{callback_data}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_UUID'], callback_data=f"search_uuid:{callback_data}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_CONFIG'], callback_data=f"search_config:{callback_data}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_EXPIRED_USERS'], callback_data=f"search_expired:{callback_data}"))
if server_id:
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_server_user_list:{server_id}"))
return markup
#----------------------------------End Hiddify User ---------------------------------
#----------------------------------Bot User Management ------------------------------
# Users Bot Management - Inline Keyboard Markup
def users_bot_management_markup(value=None):
markup = InlineKeyboardMarkup()
markup.row_width = 3
# markup.add(
# InlineKeyboardButton(KEY_MARKUP['USERS_BOT_ORDERS_STATUS'], callback_data=f"users_bot_orders_status:None"),
# markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_ADD_PLAN'], callback_data=f"users_bot_add_plan:None"),
# InlineKeyboardButton(KEY_MARKUP['USERS_BOT_DEL_PLAN'], callback_data=f"users_bot_list_plans:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BOT_USERS_MANAGEMENT'],
callback_data=f"bot_users_list_management:None"))
# markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_MANAGEMENT'],
# callback_data=f"users_bot_orders_list_management:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['PAYMENT_MANAGEMENT'],
callback_data=f"users_bot_payments_list_management:None"),
InlineKeyboardButton(KEY_MARKUP['ORDERS_MANAGEMENT'],
callback_data=f"users_bot_orders_list_management:None"),)
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SUB_STATUS'], callback_data=f"users_bot_sub_status:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SEND_MESSAGE_TO_USERS'],
callback_data=f"users_bot_send_msg_users:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_OWNER_INFO'], callback_data=f"users_bot_owner_info:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_BOT_SETTINGS'], callback_data=f"users_bot_settings:None"))
return markup
# Users Bot Users List Management - Inline Keyboard Markup
def users_bot_users_management_markup(value=None):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['USERS_LIST'], callback_data=f"bot_users_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USERS_BOT'], callback_data=f"search_users_bot:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"users_bot_management_menu:None"))
return markup
# Users Bot Search Method - Inline Keyboard Markup
def users_bot_users_search_method_markup(value=None):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_NAME'], callback_data=f"bot_users_search_name:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_USER_TELEGRAM_ID'], callback_data=f"bot_users_search_telegram_id:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_users_bot_users_management:None"))
return markup
# Users List Inline Keyboard Markup
def bot_users_list_markup(users, page=1):
markup = InlineKeyboardMarkup(row_width=3)
USER_PER_PAGE = 20
start = (page - 1) * USER_PER_PAGE
end = start + USER_PER_PAGE
keys = []
for user in users[start:end]:
name = user['full_name'] if user['full_name'] else user['telegram_id']
keys.append(InlineKeyboardButton(f"{name}", callback_data=f"bot_user_info:{user['telegram_id']}"))
markup.add(*keys)
if page < len(users) / USER_PER_PAGE:
markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f"bot_user_next:{page + 1}"), row_width=2)
if page > 1:
markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f"bot_user_next:{page - 1}"), row_width=1)
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_to_bot_users_or_reffral_management:None"))
return markup
# User Item List Inline Keyboard Markup
def bot_user_item_list_markup(items, page=1):
markup = InlineKeyboardMarkup(row_width=3)
USER_PER_PAGE = 20
start = (page - 1) * USER_PER_PAGE
end = start + USER_PER_PAGE
keys = []
for item in items[start:end]:
keys.append(InlineKeyboardButton(f"{item['id']}", callback_data=f"bot_user_item_info:{item['id']}"))
markup.add(*keys)
if page < len(items) / USER_PER_PAGE:
markup.add(InlineKeyboardButton(KEY_MARKUP['NEXT_PAGE'], callback_data=f"bot_user_item_next:{page + 1}"), row_width=2)
if page > 1:
markup.add(InlineKeyboardButton(KEY_MARKUP['PREV_PAGE'], callback_data=f"bot_user_item_next:{page - 1}"), row_width=1)
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"back_management_item_list:None"))
return markup
# Users Bot Users info Management - Inline Keyboard Markup
def bot_user_info_markup(telegram_id):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['USER_SUB_LIST'], callback_data=f"bot_users_sub_user_list:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_LIST'], callback_data=f"users_bot_orders_user_list:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['PAYMENTS_LIST'], callback_data=f"users_bot_payments_user_list:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['EDIT_WALLET'], callback_data=f"users_bot_wallet_edit_balance:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['RESET_TEST'], callback_data=f"users_bot_reset_test:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BAN_USER'], callback_data=f"users_bot_ban_user:{telegram_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_MESSAGE'], callback_data=f"users_bot_send_message_by_admin:{telegram_id}"))
# markup.add(InlineKeyboardButton(KEY_MARKUP['GIFT_LIST'], callback_data=f"users_bot_gifts_user_list:{telegram_id}"),
# InlineKeyboardButton(KEY_MARKUP['REFERRED_LIST'], callback_data=f"users_bot_referred_user_list:{telegram_id}"))
#markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"users_bot_management_menu:None"))
return markup
# Users Bot Users List Management - Inline Keyboard Markup
def users_bot_orders_management_markup(value=None):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['ORDERS_LIST'], callback_data=f"users_bot_orders_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_ORDERS'], callback_data=f"search_orders:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"users_bot_management_menu:None"))
return markup
def confirm_payment_by_admin(payment_id):
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(
InlineKeyboardButton(KEY_MARKUP['CONFIRM_PAYMENT'], callback_data=f"confirm_payment_by_admin:{payment_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f"cancel_payment_by_admin:{payment_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEND_MESSAGE'], callback_data=f"send_message_by_admin:{payment_id}"))
return markup
def send_message_to_user_markup(admin_id):
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(InlineKeyboardButton(KEY_MARKUP['ANSWER'], callback_data=f"answer_to_admin:{admin_id}"))
return markup
def change_status_payment_by_admin(payment_id):
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(
InlineKeyboardButton(KEY_MARKUP['CHANGE_STATUS_PAYMENT'], callback_data=f"change_status_payment_by_admin:{payment_id}"))
return markup
def confirm_change_status_payment_by_admin(payment_id):
markup = InlineKeyboardMarkup()
markup.row_width = 1
markup.add(
InlineKeyboardButton(KEY_MARKUP['YES'], callback_data=f"confirm_change_status_payment_by_admin:{payment_id}"))
markup.add(InlineKeyboardButton(KEY_MARKUP['NO'], callback_data=f"cancel_change_status_payment_by_admin:{payment_id}"))
return markup
# Users Bot Payments List Management - Inline Keyboard Markup
def users_bot_payments_management_markup(value=None):
markup = InlineKeyboardMarkup()
markup.row_width = 2
markup.add(InlineKeyboardButton(KEY_MARKUP['APPROVED_PAYMENTS_LIST'],
callback_data=f"bot_users_approved_payments_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['NON_APPROVED_PAYMENTS_LIST'],
callback_data=f"users_bot_non_approved_payments_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['PENDING_PAYMENT_LIST'],
callback_data=f"users_bot_pending_payments_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['CARD_PAYMENT_LIST'],
callback_data=f"users_bot_card_payments_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['DIGITAL_PAYMENT_LIST'],
callback_data=f"users_bot_digital_payments_list:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['SEARCH_PAYMENTS'], callback_data=f"search_payments:None"))
markup.add(InlineKeyboardButton(KEY_MARKUP['BACK'], callback_data=f"users_bot_management_menu:None"))
return markup
#----------------------------------Bot User Settings Management ------------------------------
# Users Bot Management - Settings - Inline Keyboard Markup
def users_bot_management_settings_markup(settings):
markup = InlineKeyboardMarkup()
markup.row_width = 2
status_hyperlink = "✅" if settings['visible_hiddify_hyperlink'] else "❌"
status_three_rand = "✅" if settings['three_random_num_price'] else "❌"
status_panel_auto_backup = "✅" if settings['panel_auto_backup'] else "❌"
status_bot_auto_backup = "✅" if settings['bot_auto_backup'] else "❌"
status_force_join = "✅" if settings['force_join_channel'] else "❌"
status_buy_sub = "✅" if settings['buy_subscription_status'] else "❌"
status_renewal_sub = "✅" if settings['renewal_subscription_status'] else "❌"
markup.add(InlineKeyboardBu
gitextract_jrhoa15n/ ├── .gitignore ├── AdminBot/ │ ├── Json/ │ │ ├── buttons.json │ │ ├── commands.json │ │ └── messages.json │ ├── bot.py │ ├── content.py │ ├── markups.py │ └── templates.py ├── Cronjob/ │ ├── backup.py │ ├── backupBot.py │ └── reminder.py ├── Database/ │ └── dbManager.py ├── LICENSE ├── README-FA.md ├── README.md ├── Shared/ │ └── common.py ├── UserBot/ │ ├── Json/ │ │ ├── buttons.json │ │ ├── commands.json │ │ └── messages.json │ ├── bot.py │ ├── content.py │ ├── markups.py │ └── templates.py ├── Utils/ │ ├── api.py │ ├── serverInfo.py │ └── utils.py ├── config.py ├── crontab.py ├── hiddifyTelegramBot.py ├── install.sh ├── requirements.txt ├── restart.sh ├── uninstall.sh ├── update.py ├── update.sh └── version.py
SYMBOL INDEX (312 symbols across 17 files)
FILE: AdminBot/bot.py
function is_it_digit (line 38) | def is_it_digit(message: Message, allow_float=False, response=MESSAGES['...
function is_it_cancel (line 51) | def is_it_cancel(message: Message, response=MESSAGES['CANCELED']):
function message_to_html (line 58) | def message_to_html(message: Message):
function add_user_name (line 88) | def add_user_name(message: Message, server_id):
function add_user_limit (line 97) | def add_user_limit(message: Message, server_id):
function add_user_usage_days (line 110) | def add_user_usage_days(message: Message, server_id):
function confirm_add_user (line 126) | def confirm_add_user(message: Message, server_id):
function edit_user_name (line 163) | def edit_user_name(message: Message, uuid):
function edit_user_usage (line 178) | def edit_user_usage(message: Message, uuid):
function edit_user_days (line 196) | def edit_user_days(message: Message, uuid):
function edit_user_comment (line 215) | def edit_user_comment(message: Message, uuid):
function search_user_name (line 231) | def search_user_name(message: Message, server_id):
function search_user_uuid (line 250) | def search_user_uuid(message: Message, server_id):
function search_user_config (line 271) | def search_user_config(message: Message, server_id):
function all_server_search_user_name (line 291) | def all_server_search_user_name(message: Message):
function all_server_search_user_uuid (line 317) | def all_server_search_user_uuid(message: Message):
function all_server_search_user_config (line 343) | def all_server_search_user_config(message: Message):
function search_bot_user_name (line 368) | def search_bot_user_name(message: Message):
function search_bot_user_telegram_id (line 387) | def search_bot_user_telegram_id(message: Message):
function search_bot_user_order (line 417) | def search_bot_user_order(message: Message):
function search_bot_user_payment (line 453) | def search_bot_user_payment(message: Message):
function add_server_title (line 529) | def add_server_title(message: Message):
function add_server_url (line 539) | def add_server_url(message: Message):
function add_server_user_limit (line 566) | def add_server_user_limit(message: Message):
function edit_server_title (line 586) | def edit_server_title(message: Message, server_id):
function edit_server_user_limit (line 605) | def edit_server_user_limit(message: Message, server_id):
function edit_server_url (line 627) | def edit_server_url(message: Message, server_id):
function users_bot_add_plan_usage (line 668) | def users_bot_add_plan_usage(message: Message):
function users_bot_add_plan_days (line 681) | def users_bot_add_plan_days(message: Message):
function users_bot_add_plan_price (line 694) | def users_bot_add_plan_price(message: Message):
function users_bot_add_plan_description (line 704) | def users_bot_add_plan_description(message: Message):
function users_bot_edit_owner_info_username (line 736) | def users_bot_edit_owner_info_username(message: Message):
function users_bot_edit_owner_info_card_number (line 751) | def users_bot_edit_owner_info_card_number(message: Message):
function users_bot_edit_owner_info_card_name (line 770) | def users_bot_edit_owner_info_card_name(message: Message):
function users_bot_send_msg_users (line 782) | def users_bot_send_msg_users(message: Message):
function users_bot_settings_update_message (line 807) | def users_bot_settings_update_message(message: Message, markup,title=MES...
function users_bot_sub_status (line 855) | def users_bot_sub_status(message: Message):
function users_bot_settings_min_depo (line 916) | def users_bot_settings_min_depo(message: Message):
function users_bot_settings_channel_id (line 931) | def users_bot_settings_channel_id(message: Message):
function users_bot_settings_welcome_msg (line 945) | def users_bot_settings_welcome_msg(message: Message):
function users_bot_settings_set_faq_msg (line 955) | def users_bot_settings_set_faq_msg(message: Message, msg):
function users_bot_settings_test_sub_size (line 971) | def users_bot_settings_test_sub_size(message: Message):
function users_bot_settings_test_sub_days (line 989) | def users_bot_settings_test_sub_days(message: Message):
function users_bot_settings_notif_reminder_usage (line 1003) | def users_bot_settings_notif_reminder_usage(message: Message):
function users_bot_settings_notif_reminder_days (line 1020) | def users_bot_settings_notif_reminder_days(message: Message):
function users_bot_settings_panel_manual (line 1034) | def users_bot_settings_panel_manual(message: Message, db_key):
function users_bot_settings_restore_bot (line 1043) | def users_bot_settings_restore_bot(message: Message):
function users_bot_settings_renewal_method_advanced_days (line 1065) | def users_bot_settings_renewal_method_advanced_days(message: Message):
function users_bot_settings_renewal_method_advanced_usage (line 1077) | def users_bot_settings_renewal_method_advanced_usage(message: Message):
function edit_wallet_balance (line 1092) | def edit_wallet_balance(message: Message,telegram_id):
function send_message_to_user (line 1113) | def send_message_to_user(message: Message, payment_id):
function users_bot_send_message_to_user (line 1128) | def users_bot_send_message_to_user(message: Message, telegram_id):
function callback_query (line 1139) | def callback_query(call: CallbackQuery):
function not_admin (line 2791) | def not_admin(message: Message):
function send_welcome (line 2797) | def send_welcome(message: Message):
function server_backup (line 2824) | def server_backup(message: Message):
function server_status (line 2842) | def server_status(message: Message):
function search_user (line 2850) | def search_user(message: Message):
function users_bot_management (line 2859) | def users_bot_management(message: Message):
function servers_management (line 2868) | def servers_management(message: Message):
function about_bot (line 2875) | def about_bot(message: Message):
function debug (line 2880) | def debug(message: Message):
function start (line 2890) | def start():
FILE: AdminBot/markups.py
function main_menu_keyboard_markup (line 10) | def main_menu_keyboard_markup():
function users_list_markup (line 26) | def users_list_markup(server_id, users, page=1):
function user_info_markup (line 58) | def user_info_markup(uuid):
function edit_user_markup (line 68) | def edit_user_markup(uuid):
function while_edit_user_markup (line 90) | def while_edit_user_markup():
function while_edit_skip_user_markup (line 95) | def while_edit_skip_user_markup():
function confirm_add_user_markup (line 102) | def confirm_add_user_markup():
function sub_url_user_list_markup (line 110) | def sub_url_user_list_markup(uuid):
function sub_user_list_markup (line 129) | def sub_user_list_markup(uuid,configs):
function search_user_markup (line 143) | def search_user_markup(server_id=None):
function users_bot_management_markup (line 159) | def users_bot_management_markup(value=None):
function users_bot_users_management_markup (line 182) | def users_bot_users_management_markup(value=None):
function users_bot_users_search_method_markup (line 191) | def users_bot_users_search_method_markup(value=None):
function bot_users_list_markup (line 200) | def bot_users_list_markup(users, page=1):
function bot_user_item_list_markup (line 219) | def bot_user_item_list_markup(items, page=1):
function bot_user_info_markup (line 236) | def bot_user_info_markup(telegram_id):
function users_bot_orders_management_markup (line 252) | def users_bot_orders_management_markup(value=None):
function confirm_payment_by_admin (line 260) | def confirm_payment_by_admin(payment_id):
function send_message_to_user_markup (line 269) | def send_message_to_user_markup(admin_id):
function change_status_payment_by_admin (line 275) | def change_status_payment_by_admin(payment_id):
function confirm_change_status_payment_by_admin (line 282) | def confirm_change_status_payment_by_admin(payment_id):
function users_bot_payments_management_markup (line 291) | def users_bot_payments_management_markup(value=None):
function users_bot_management_settings_markup (line 311) | def users_bot_management_settings_markup(settings):
function users_bot_management_settings_renewal_method_markup (line 368) | def users_bot_management_settings_renewal_method_markup(settings):
function users_bot_management_settings_test_sub_markup (line 398) | def users_bot_management_settings_test_sub_markup(settings):
function users_bot_management_settings_notif_reminder_markup (line 413) | def users_bot_management_settings_notif_reminder_markup(settings):
function users_bot_management_settings_visible_sub_markup (line 428) | def users_bot_management_settings_visible_sub_markup(settings):
function users_bot_management_settings_panel_manual_markup (line 461) | def users_bot_management_settings_panel_manual_markup():
function users_bot_management_settings_faq_markup (line 477) | def users_bot_management_settings_faq_markup():
function users_bot_edit_owner_info_markup (line 491) | def users_bot_edit_owner_info_markup():
function users_bot_management_settings_reset_free_test_markup (line 502) | def users_bot_management_settings_reset_free_test_markup():
function sub_search_info_markup (line 511) | def sub_search_info_markup(uuid,user):
function servers_management_markup (line 526) | def servers_management_markup(servers):
function server_selected_markup (line 540) | def server_selected_markup(server_id):
function server_delete_markup (line 554) | def server_delete_markup(server_id):
function server_edit_markup (line 565) | def server_edit_markup(server_id):
function plans_list_markup (line 580) | def plans_list_markup(plans, server_id, delete_mode=False):
function plan_info_selected_markup (line 598) | def plan_info_selected_markup(server_id):
function start_bot_markup (line 606) | def start_bot_markup():
function server_status_markup (line 613) | def server_status_markup(servers):
FILE: AdminBot/templates.py
function user_info_template (line 10) | def user_info_template(usr, server, header=""):
function server_info_template (line 32) | def server_info_template(server, plans, header=""):
function plan_info_template (line 54) | def plan_info_template(plan, orders, header=""):
function users_list_template (line 73) | def users_list_template(users, heder=""):
function bot_users_list_template (line 90) | def bot_users_list_template(users, wallets, orders, header=""):
function bot_users_info_template (line 123) | def bot_users_info_template(user, orders, payments, wallet, non_order_su...
function bot_orders_info_template (line 175) | def bot_orders_info_template(order, plan, user, server, header=""):
function bot_payment_info_template (line 196) | def bot_payment_info_template(payment,user, header="", footer=""):
function bot_orders_list_template (line 220) | def bot_orders_list_template(orders, plans, header=""):
function bot_payments_list_template (line 281) | def bot_payments_list_template(payments, header=""):
function configs_template (line 323) | def configs_template(configs):
function system_status_template (line 338) | def system_status_template(status):
function last_online_time_template (line 349) | def last_online_time_template(last_online_time):
function owner_info_template (line 367) | def owner_info_template(username, card_number_card, card_name):
function about_template (line 390) | def about_template():
FILE: Cronjob/backup.py
function cron_backup (line 10) | def cron_backup():
FILE: Cronjob/backupBot.py
function cron_backup_bot (line 10) | def cron_backup_bot():
FILE: Cronjob/reminder.py
function alert_package_gb (line 15) | def alert_package_gb(package_remaining_gb):
function alert_package_days (line 21) | def alert_package_days(package_remaining_days):
function cron_reminder (line 28) | def cron_reminder():
FILE: Database/dbManager.py
class UserDBManager (line 16) | class UserDBManager:
method __init__ (line 17) | def __init__(self, db_file):
method __del__ (line 23) | def __del__(self):
method close (line 26) | def close(self):
method create_connection (line 30) | def create_connection(self, db_file):
method create_user_table (line 39) | def create_user_table(self):
method select_users (line 163) | def select_users(self):
method find_user (line 174) | def find_user(self, **kwargs):
method delete_user (line 193) | def delete_user(self, **kwargs):
method edit_user (line 208) | def edit_user(self, telegram_id, **kwargs):
method add_user (line 222) | def add_user(self, telegram_id, full_name,username, created_at):
method add_plan (line 235) | def add_plan(self, plan_id, size_gb, days, price, server_id, descripti...
method select_plans (line 248) | def select_plans(self):
method find_plan (line 259) | def find_plan(self, **kwargs):
method delete_plan (line 278) | def delete_plan(self, **kwargs):
method edit_plan (line 293) | def edit_plan(self, plan_id, **kwargs):
method add_user_plans (line 307) | def add_user_plans(self, telegram_id, plan_id):
method select_user_plans (line 320) | def select_user_plans(self):
method find_user_plans (line 331) | def find_user_plans(self, **kwargs):
method delete_user_plans (line 350) | def delete_user_plans(self, **kwargs):
method edit_user_plans (line 365) | def edit_user_plans(self, user_plans_id, **kwargs):
method add_order (line 379) | def add_order(self, order_id, telegram_id,user_name, plan_id, created_...
method select_orders (line 393) | def select_orders(self):
method find_order (line 404) | def find_order(self, **kwargs):
method edit_order (line 423) | def edit_order(self, order_id, **kwargs):
method add_order_subscription (line 437) | def add_order_subscription(self, sub_id, order_id, uuid, server_id):
method select_order_subscription (line 451) | def select_order_subscription(self):
method find_order_subscription (line 462) | def find_order_subscription(self, **kwargs):
method edit_order_subscriptions (line 481) | def edit_order_subscriptions(self, order_id, **kwargs):
method delete_order_subscription (line 495) | def delete_order_subscription(self, **kwargs):
method add_non_order_subscription (line 507) | def add_non_order_subscription(self, non_sub_id, telegram_id, uuid, se...
method select_non_order_subscriptions (line 521) | def select_non_order_subscriptions(self):
method find_non_order_subscription (line 532) | def find_non_order_subscription(self, **kwargs):
method delete_non_order_subscription (line 551) | def delete_non_order_subscription(self, **kwargs):
method edit_bool_config (line 563) | def edit_bool_config(self, key_row, **kwargs):
method find_bool_config (line 576) | def find_bool_config(self, **kwargs):
method add_bool_config (line 595) | def add_bool_config(self, key, value):
method select_bool_config (line 611) | def select_bool_config(self):
method select_str_config (line 622) | def select_str_config(self):
method find_str_config (line 633) | def find_str_config(self, **kwargs):
method edit_str_config (line 652) | def edit_str_config(self, key_row, **kwargs):
method add_str_config (line 665) | def add_str_config(self, key, value):
method select_int_config (line 680) | def select_int_config(self):
method find_int_config (line 691) | def find_int_config(self, **kwargs):
method edit_int_config (line 709) | def edit_int_config(self, key_row, **kwargs):
method add_int_config (line 722) | def add_int_config(self, key, value):
method set_default_configs (line 737) | def set_default_configs(self):
method add_wallet (line 794) | def add_wallet(self, telegram_id):
method select_wallet (line 808) | def select_wallet(self):
method find_wallet (line 819) | def find_wallet(self, **kwargs):
method edit_wallet (line 838) | def edit_wallet(self, telegram_id, **kwargs):
method add_payment (line 850) | def add_payment(self, payment_id, telegram_id, payment_amount, payment...
method edit_payment (line 864) | def edit_payment(self, payment_id, **kwargs):
method find_payment (line 876) | def find_payment(self, **kwargs):
method select_payments (line 895) | def select_payments(self):
method select_servers (line 906) | def select_servers(self):
method add_server (line 917) | def add_server(self, url, user_limit, title=None, description=None, st...
method edit_server (line 930) | def edit_server(self, server_id, **kwargs):
method find_server (line 942) | def find_server(self, **kwargs):
method delete_server (line 961) | def delete_server(self, **kwargs):
method backup_to_json (line 977) | def backup_to_json(self, backup_dir):
method restore_from_json (line 1003) | def restore_from_json(self, backup_file):
FILE: Shared/common.py
function admin_bot (line 3) | def admin_bot():
function user_bot (line 8) | def user_bot():
FILE: UserBot/bot.py
function is_it_digit (line 26) | def is_it_digit(message: Message,allow_float=False, response=MESSAGES['E...
function is_it_cancel (line 39) | def is_it_cancel(message: Message, response=MESSAGES['CANCELED']):
function is_it_command (line 47) | def is_it_command(message: Message):
function type_of_subscription (line 54) | def type_of_subscription(text):
function is_user_banned (line 66) | def is_user_banned(user_id):
function user_channel_status (line 80) | def user_channel_status(user_id):
function is_user_in_channel (line 93) | def is_user_in_channel(user_id):
function buy_from_wallet_confirm (line 105) | def buy_from_wallet_confirm(message: Message, plan):
function renewal_from_wallet_confirm (line 128) | def renewal_from_wallet_confirm(message: Message):
function next_step_send_screenshot (line 284) | def next_step_send_screenshot(message, charge_wallet):
function next_step_answer_to_admin (line 336) | def next_step_answer_to_admin(message, admin_id):
function next_step_send_ticket_to_admin (line 348) | def next_step_send_ticket_to_admin(message):
function next_step_send_name_for_buy_from_wallet (line 362) | def next_step_send_name_for_buy_from_wallet(message: Message, plan):
function next_step_send_name_for_get_free_test (line 445) | def next_step_send_name_for_get_free_test(message: Message, server_id):
function next_step_to_qr (line 506) | def next_step_to_qr(message: Message):
function next_step_link_subscription (line 526) | def next_step_link_subscription(message: Message):
function next_step_increase_wallet_balance (line 565) | def next_step_increase_wallet_balance(message):
function increase_wallet_balance_specific (line 596) | def increase_wallet_balance_specific(message,amount):
function update_info_subscription (line 619) | def update_info_subscription(message: Message, uuid,markup=None):
function callback_query (line 659) | def callback_query(call: CallbackQuery):
function start_bot (line 1132) | def start_bot(message: Message):
function not_in_users_table (line 1166) | def not_in_users_table(message: Message):
function subscription_status (line 1177) | def subscription_status(message: Message):
function buy_subscription (line 1220) | def buy_subscription(message: Message):
function to_qr (line 1262) | def to_qr(message: Message):
function help_guide (line 1274) | def help_guide(message: Message):
function faq (line 1285) | def faq(message: Message):
function send_ticket (line 1298) | def send_ticket(message: Message):
function link_subscription (line 1309) | def link_subscription(message: Message):
function wallet_balance (line 1321) | def wallet_balance(message: Message):
function free_test (line 1348) | def free_test(message: Message):
function cancel (line 1394) | def cancel(message: Message):
function start (line 1404) | def start():
FILE: UserBot/markups.py
function main_menu_keyboard_markup (line 10) | def main_menu_keyboard_markup():
function user_info_markup (line 26) | def user_info_markup(uuid):
function sub_url_user_list_markup (line 37) | def sub_url_user_list_markup(uuid):
function sub_user_list_markup (line 64) | def sub_user_list_markup(uuid,configs):
function user_info_non_sub_markup (line 80) | def user_info_non_sub_markup(uuid):
function confirm_subscription_markup (line 91) | def confirm_subscription_markup(uuid):
function confirm_buy_plan_markup (line 99) | def confirm_buy_plan_markup(plan_id, renewal=False,uuid=None):
function send_screenshot_markup (line 111) | def send_screenshot_markup(plan_id):
function plans_list_markup (line 119) | def plans_list_markup(plans, renewal=False,uuid=None):
function servers_list_markup (line 139) | def servers_list_markup(servers, free_test=False):
function confirm_payment_by_admin (line 155) | def confirm_payment_by_admin(order_id):
function notify_to_admin_markup (line 164) | def notify_to_admin_markup(user):
function send_ticket_to_admin (line 171) | def send_ticket_to_admin():
function answer_to_user_markup (line 181) | def answer_to_user_markup(user,user_id):
function cancel_markup (line 189) | def cancel_markup():
function wallet_info_markup (line 195) | def wallet_info_markup():
function wallet_info_specific_markup (line 202) | def wallet_info_specific_markup(amount):
function force_join_channel_markup (line 209) | def force_join_channel_markup(channel_id):
function users_bot_management_settings_panel_manual_markup (line 222) | def users_bot_management_settings_panel_manual_markup():
FILE: UserBot/templates.py
function user_info_template (line 7) | def user_info_template(sub_id, server, usr, header=""):
function wallet_info_template (line 33) | def wallet_info_template(balance):
function plan_info_template (line 43) | def plan_info_template(plan, header=""):
function owner_info_template (line 58) | def owner_info_template(card_number, card_holder_name, price, header=""):
function payment_received_template (line 86) | def payment_received_template(payment,user, header="", footer=""):
function connection_help_template (line 121) | def connection_help_template(header=""):
function package_days_expire_soon_template (line 196) | def package_days_expire_soon_template(sub_id, remaining_days):
function package_size_end_soon_template (line 212) | def package_size_end_soon_template(sub_id, remaining_size):
function renewal_unvalable_template (line 227) | def renewal_unvalable_template(settings):
FILE: Utils/api.py
function select (line 17) | def select(url, endpoint="/user/"):
function find (line 26) | def find(url, uuid, endpoint="/user/"):
function insert (line 41) | def insert(url, name, usage_limit_GB, package_days, last_reset_time=None...
function update (line 75) | def update(url, uuid, endpoint="/user/", **kwargs, ):
FILE: Utils/serverInfo.py
function scrape_data_from_json_url (line 8) | def scrape_data_from_json_url(url):
function json_template (line 26) | def json_template(data):
function server_status_template (line 104) | def server_status_template(result, server_name):
function get_server_status (line 171) | def get_server_status(server_row):
FILE: Utils/utils.py
function get_request (line 33) | def get_request(url):
function post_request (line 55) | def post_request(url, data):
function users_to_dict (line 75) | def users_to_dict(users_dict):
function Telegram_users_to_dict (line 93) | def Telegram_users_to_dict(Tel_users_dict):
function calculate_remaining_days (line 103) | def calculate_remaining_days(start_date, package_days):
function calculate_remaining_usage (line 120) | def calculate_remaining_usage(usage_limit_GB, current_usage_GB):
function calculate_remaining_last_online (line 126) | def calculate_remaining_last_online(last_online_date_time):
function dict_process (line 138) | def dict_process(url, users_dict, sub_id=None, server_id=None):
function user_info (line 167) | def user_info(url, uuid):
function sub_links (line 179) | def sub_links(uuid, url= None):
function sub_parse (line 221) | def sub_parse(sub):
function backup_panel (line 260) | def backup_panel(url):
function zip_files (line 283) | def zip_files(files, zip_file_name,path=None):
function full_backup (line 295) | def full_backup():
function extract_uuid_from_config (line 315) | def extract_uuid_from_config(config):
function system_status (line 328) | def system_status():
function search_user_by_name (line 340) | def search_user_by_name(url, name):
function search_user_by_uuid (line 355) | def search_user_by_uuid(url, uuid):
function base64decoder (line 367) | def base64decoder(s):
function search_user_by_config (line 379) | def search_user_by_config(url, config):
function is_it_config_or_sub (line 397) | def is_it_config_or_sub(config):
function users_bot_add_plan (line 409) | def users_bot_add_plan(size, days, price, server_id,description=None):
function add_server (line 421) | def add_server(url, user_limit, title=None, description=None, status=Tru...
function is_user_expired (line 431) | def is_user_expired(user):
function expired_users_list (line 438) | def expired_users_list(users):
function txt_to_qr (line 447) | def txt_to_qr(txt):
function non_order_user_info (line 465) | def non_order_user_info(telegram_id):
function order_user_info (line 487) | def order_user_info(telegram_id):
function replace_last_three_with_random (line 513) | def replace_last_three_with_random(input_string):
function privacy_friendly_logging_request (line 525) | def privacy_friendly_logging_request(url):
function all_configs_settings (line 531) | def all_configs_settings():
function find_order_subscription_by_uuid (line 547) | def find_order_subscription_by_uuid(uuid):
function is_it_subscription_by_uuid_and_telegram_id (line 557) | def is_it_subscription_by_uuid_and_telegram_id(uuid, telegram_id):
function toman_to_rial (line 585) | def toman_to_rial(toman):
function rial_to_toman (line 589) | def rial_to_toman(rial):
function backup_json_bot (line 593) | def backup_json_bot():
function restore_json_bot (line 616) | def restore_json_bot(file):
function debug_data (line 697) | def debug_data():
FILE: config.py
function setup_users_db (line 45) | def setup_users_db():
function load_config (line 63) | def load_config(db):
function load_server_url (line 79) | def load_server_url(db):
function set_config_variables (line 93) | def set_config_variables(configs, server_url):
function panel_url_validator (line 119) | def panel_url_validator(url):
function bot_token_validator (line 146) | def bot_token_validator(token):
function set_by_user (line 162) | def set_by_user():
function set_config_in_db (line 237) | def set_config_in_db(db, admin_ids, token, url, lang, client_token):
function print_current_conf (line 268) | def print_current_conf(conf, server_url):
FILE: update.py
function version (line 14) | def version():
function is_version_less (line 22) | def is_version_less(version1, version2):
function drop_columns_from_table (line 38) | def drop_columns_from_table(table_name, columns_to_drop):
function update_v4_v5 (line 70) | def update_v4_v5():
function update_v5_1_0_to_v5_5_0 (line 153) | def update_v5_1_0_to_v5_5_0():
function update_v5_9_5_to_v6_1_0 (line 210) | def update_v5_9_5_to_v6_1_0():
function update_by_version (line 227) | def update_by_version(current_version, target_version):
FILE: version.py
function version (line 8) | def version():
function is_version_less (line 14) | def is_version_less(version1, version2):
Condensed preview — 36 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (534K chars).
[
{
"path": ".gitignore",
"chars": 228,
"preview": "/Database/hidyBot.db\n/Logs\n/Backup\n/UserBot/Receiptions\n/.idea\n/temp\n/Utils/swapWallet.py\n\n/.handler-saves\nhiddifypanel."
},
{
"path": "AdminBot/Json/buttons.json",
"chars": 11224,
"preview": "{\n \"EN\": {\n \"CONFIRM\": \"✅Confirm\",\n \"CANCEL\": \"❌Cancel\",\n \"BOT_USERS_MANAGEMENT\": \"👤Bot Users Management\",\n "
},
{
"path": "AdminBot/Json/commands.json",
"chars": 147,
"preview": "{\n \"EN\": {\n \"START\": \"start\",\n \"DEBUG\": \"debug\"\n },\n \"FA\": {\n \"START\": \"شروع\",\n \"DE"
},
{
"path": "AdminBot/Json/messages.json",
"chars": 25716,
"preview": "{\n \"EN\": {\n \"WELCOME\": \"Welcome to Hiddify Management Bot\",\n \"ERROR_INVALID_NUMBER\": \"❌Only numbers are allowed!\""
},
{
"path": "AdminBot/bot.py",
"chars": 143587,
"preview": "# Description: Main Bot File\nimport datetime\nimport html\nimport logging\nimport operator\nimport time\nimport telebot\nimpor"
},
{
"path": "AdminBot/content.py",
"chars": 603,
"preview": "import os\nimport json\nfrom config import LANG\n\nFOLDER = \"Json\"\n\nMSG_FILE = \"messages.json\"\nBTN_FILE = \"buttons.json\"\nCMD"
},
{
"path": "AdminBot/markups.py",
"chars": 36828,
"preview": "# Description: This file contains all the reply and inline keyboard markups used in the bot.\nfrom telebot.types import R"
},
{
"path": "AdminBot/templates.py",
"chars": 15095,
"preview": "# Description: This file contains all the templates used in the bot.\nfrom config import LANG, VERSION, API_PATH\nfrom Adm"
},
{
"path": "Cronjob/backup.py",
"chars": 554,
"preview": "from AdminBot.bot import bot\nfrom config import ADMINS_ID\nfrom Utils.utils import full_backup,all_configs_settings\nimpor"
},
{
"path": "Cronjob/backupBot.py",
"chars": 511,
"preview": "from Utils.utils import all_configs_settings, backup_json_bot\nfrom AdminBot.bot import bot\nfrom config import ADMINS_ID\n"
},
{
"path": "Cronjob/reminder.py",
"chars": 1862,
"preview": "from Utils.utils import *\nfrom UserBot.bot import bot\nfrom config import CLIENT_TOKEN\nfrom UserBot.templates import pack"
},
{
"path": "Database/dbManager.py",
"chars": 43580,
"preview": "import datetime\nimport json\nimport logging\nimport os\nimport sqlite3\nfrom sqlite3 import Error\nfrom version import is_ver"
},
{
"path": "LICENSE",
"chars": 35158,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "README-FA.md",
"chars": 4478,
"preview": "\n\n<p align=\"center\">\n <a href=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot\" target=\"_blank\" rel=\"noopener noreferrer\""
},
{
"path": "README.md",
"chars": 4885,
"preview": "<p align=\"center\">\r\n <a href=\"https://github.com/B3H1Z/Hiddify-Telegram-Bot\" target=\"_blank\" rel=\"noopener noreferrer\""
},
{
"path": "Shared/common.py",
"chars": 211,
"preview": "# Common file for avoiding circular import.\n\ndef admin_bot():\n from AdminBot.bot import bot as admin_bot\n return a"
},
{
"path": "UserBot/Json/buttons.json",
"chars": 3002,
"preview": "{\n \"EN\": {\n \"BACK\": \"🔙Back\",\n \"SUBSCRIPTION_STATUS\": \"📊Subscription Status\",\n \"YES\": \"✅Yes\",\n \"NO\": \"❌No\",\n"
},
{
"path": "UserBot/Json/commands.json",
"chars": 89,
"preview": "{\n \"EN\": {\n \"START\": \"start\"\n },\n \"FA\": {\n \"START\": \"شروع\"\n }\n}"
},
{
"path": "UserBot/Json/messages.json",
"chars": 13227,
"preview": "{\n \"EN\": {\n \"WELCOME\": \"Welcome to users bot\",\n \"INFO_USER\": \"📄Your Subscription Info\",\n \"SUBSCR"
},
{
"path": "UserBot/bot.py",
"chars": 65365,
"preview": "import datetime\nimport random\n\nimport telebot\nfrom telebot.types import Message, CallbackQuery\nfrom config import *\nfrom"
},
{
"path": "UserBot/content.py",
"chars": 769,
"preview": "import os\nimport json\nfrom config import LANG\nfrom Utils.utils import all_configs_settings\n\nFOLDER = \"Json\"\nMSG_FILE = \""
},
{
"path": "UserBot/markups.py",
"chars": 11079,
"preview": "# Description: This file contains all the reply and inline keyboard markups used in the bot.\nfrom telebot import types\nf"
},
{
"path": "UserBot/templates.py",
"chars": 7584,
"preview": "# Description: This file contains all the templates used in the bot.\nfrom config import LANG\nfrom UserBot.content import"
},
{
"path": "Utils/api.py",
"chars": 2876,
"preview": "# from config import *\n# from Utils.utils import *\nimport json\nimport logging\nfrom urllib.parse import urlparse\nimport d"
},
{
"path": "Utils/serverInfo.py",
"chars": 8549,
"preview": "# Thanks to https://github.com/m-mjd/hiddybot_info_severs\nimport sqlite3\nfrom urllib.parse import urlparse\nimport reques"
},
{
"path": "Utils/utils.py",
"chars": 26636,
"preview": "# Description: API for connecting to the panel\nimport json\nimport logging\nimport os\nimport random\nimport string\nfrom io "
},
{
"path": "config.py",
"chars": 11483,
"preview": "# Description: Configuration file for the bot\nimport json\nimport logging\nimport os\nfrom urllib.parse import urlparse\nimp"
},
{
"path": "crontab.py",
"chars": 736,
"preview": "# Crontab\nimport argparse\nfrom config import CLIENT_TOKEN\n\n# use argparse to get the arguments\nif __name__ == \"__main__\""
},
{
"path": "hiddifyTelegramBot.py",
"chars": 327,
"preview": "from threading import Thread\nimport AdminBot.bot\nfrom config import CLIENT_TOKEN\n\n# Start the admin bot\nif __name__ == '"
},
{
"path": "install.sh",
"chars": 5631,
"preview": "#!/bin/bash\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nYELLOW='\\033[1;33m'\nRESET='\\033[0m' # Reset text co"
},
{
"path": "requirements.txt",
"chars": 106,
"preview": "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",
"chars": 960,
"preview": "#!/bin/bash\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nRESET='\\033[0m' # Reset text color\ninstall_dir=\"/o"
},
{
"path": "uninstall.sh",
"chars": 1124,
"preview": "#!/bin/bash\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'\nYELLOW='\\033[1;33m'\nRESET='\\033[0m' # Reset text c"
},
{
"path": "update.py",
"chars": 10709,
"preview": "import json\nimport sqlite3\nimport argparse\nimport logging\nimport os\nUSERS_DB_LOC = os.path.join(os.getcwd(), \"Database\","
},
{
"path": "update.sh",
"chars": 5071,
"preview": "#!/bin/bash\n# shellcheck disable=SC2034\ntarget_version=\"6.1.5\"\n\n# Define text colors\nGREEN='\\033[0;32m'\nRED='\\033[0;31m'"
},
{
"path": "version.py",
"chars": 672,
"preview": "import argparse\n\n# Define the version number\n__version__ = \"6.1.5\"\n\n\n\ndef version():\n parser = argparse.ArgumentParse"
}
]
About this extraction
This page contains the full source code of the B3H1Z/Hiddify-Telegram-Bot GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 36 files (488.9 KB), approximately 116.4k tokens, and a symbol index with 312 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.