indrajitghosh20006/Testseller_01botPublic · Bot Template

ProfileTelegram

AIThis bot provides an admin‑controlled system for managing user balances, products, and reseller roles. It includes commands to add balances (via manual input, Binance Pay, or UPI), approve and credit payments, and set up product listings with categories and pricing. Admins can also add resellers, view reseller info, and manage stock entries. The bot uses built‑in TeleBotHost APIs such as Bot, Api, HTTP, and Libs for database operations and message handling.

Commerceadminbalanceproductresellerpaymentsbinance
138 commands0 envUpdated 17h agoCreated Sep 27, 2026
Back to folder

commands/_admin.js

javascript · 187 lines

Raw
1/**#command2name: /admin3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  // ✅ FIXED (v3): dynamic owner_id (same fix as /addbal) so this stays correct14  // even after ownership transfer, instead of a frozen hardcoded ID.15  var adminId = Bot.getProperty("owner_id") || "7839151435";16 17  var currentChatId = (typeof chat !== 'undefined' && chat && chat.chatid) ? String(chat.chatid) : null;18  var isCoAdmin = currentChatId && Bot.getProperty("co_admin_" + currentChatId);19  if (currentChatId !== adminId && !isCoAdmin) {20    Bot.sendMessage("❌ Restricted command! Only accessible by Owner.");21    return;22  }23 24  // Live Database Metrics Extraction25  var userList = Bot.getProperty("all_users_list") || [];26  var totalUsers = userList.length;27  var currentResellerPrice = Bot.getProperty("reseller_upgrade_price") || "Not Set";28 29  // 📝 PREMIUM ADMINISTRATIVE MASTER INTERFACE30  var adminPanelText = 31    "<blockquote><b><tg-emoji emoji-id='6064138396228392033'>👑</tg-emoji> MASTER ADMINISTRATIVE PANEL</b>\n\n" +32    "<i>Welcome back Boss! Securely manage your store microservices, logs, databases, plans, and inventory control nodes below.</i></blockquote>\n" +33    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +34    "<blockquote><b><tg-emoji emoji-id='6039605143601680423'>📊</tg-emoji> BOT INFRASTRUCTURE SUMMARY</b>\n\n" +35    "• <b>Total Registered Users:</b> <code>" + totalUsers + " Users</code>\n" +36    "• <b>Reseller Upgrade Price:</b> <code>₹" + currentResellerPrice + "</code></blockquote>\n" +37    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +38    "<tg-emoji emoji-id='5346024644635804737'>🔰</tg-emoji> <b>Select an operational control terminal module:</b>";39 40  // 🎨 ADVANCED SYSTEM CUSTOM-EMOJI INFRASTRUCTURE41  var adminKeyboard = [42    // Row 1: Product Structure (Success vs Danger Vector)43    [44      { text: "Add Product", callback_data: "/addproduct", style: "success", icon_custom_emoji_id: "5348392971207194994" },45      { text: "Remove Product", callback_data: "/removeproduct", style: "danger", icon_custom_emoji_id: "6143299028655280273" }46    ],47    // Row 2: Plan / Validity Variants48    [49      { text: "Add Plan", callback_data: "/addplan", style: "primary", icon_custom_emoji_id: "6194922667242429131" },50      { text: "Remove Plan", callback_data: "/removeplan", style: "danger", icon_custom_emoji_id: "6143299028655280273" }51    ],52    // Row 3: License Key Inventory System53    [54      { text: "Add Key", callback_data: "/addkey", style: "success", icon_custom_emoji_id: "6195196054795721892" },55      { text: "Remove Key", callback_data: "/removekey", style: "danger", icon_custom_emoji_id: "6143299028655280273" }56    ],57    // Row 4: FF ID Category Configurations58    [59      { text: "Add Cat for ID", callback_data: "/addcat_id", style: "success", icon_custom_emoji_id: "5334890573281114250" },60      { text: "Rem Cat for ID", callback_data: "/remcat_id", style: "danger", icon_custom_emoji_id: "6143299028655280273" }61    ],62    // Row 5: FF ID Stock Controls63    [64      { text: "Add Stock ID", callback_data: "/addstock_id", style: "success", icon_custom_emoji_id: "6195196054795721892" },65      { text: "Remove Stock ID", callback_data: "/remstock_id", style: "danger", icon_custom_emoji_id: "6143299028655280273" }66    ],67    // Row 5b: Stock Monitoring & Clear Control (UPDATED)68    [69      { text: "Check ID Stock", callback_data: "/allstocks", style: "primary", icon_custom_emoji_id: "6039605143601680423" },70      { text: "Clear All ID Stock", callback_data: "/clearstock", style: "danger", icon_custom_emoji_id: "6143299028655280273" }71    ],72    // Row 6: ID Pricing Controls73    [74      { text: "Set Normal Price ID", callback_data: "/normalprice_id", style: "primary", icon_custom_emoji_id: "5778145208411624388" },75      { text: "Set Reseller Price ID", callback_data: "/resellerprice_id", style: "success", icon_custom_emoji_id: "6267068789146260253" }76    ],77    // Row 7: Pricing Matrix Configurations (Global Keys)78    [79      { text: "Set All Products Normal Price", callback_data: "/normalprice", style: "primary", icon_custom_emoji_id: "5778145208411624388" },80      { text: "Set All Products Reseller Price", callback_data: "/setresellerprice", style: "success", icon_custom_emoji_id: "6267068789146260253" }81    ],82    // Row 8: Financial Wallet Controls83    [84      { text: "Add Bal", callback_data: "/addbal", style: "success", icon_custom_emoji_id: "5778145208411624388" },85      { text: "Remove Bal", callback_data: "/rembal", style: "danger", icon_custom_emoji_id: "6143299028655280273" },86      { text: "Check Bal", callback_data: "/checkbal", style: "primary", icon_custom_emoji_id: "6039605143601680423" }87    ],88    // Row 8b: Bulk Wallet Control89    [90      { text: "Add Bal To All Users", callback_data: "/addbal_all", style: "success", icon_custom_emoji_id: "5778145208411624388" }91    ],92    // Row 9: Reseller Authorization Cluster93    [94      { text: "Add Reseller", callback_data: "/addreseller", style: "success", icon_custom_emoji_id: "6195245116207143870" },95      { text: "Remove Reseller", callback_data: "/removereseller", style: "danger", icon_custom_emoji_id: "6143299028655280273" },96      { text: "View Role", callback_data: "/role", style: "primary", icon_custom_emoji_id: "6064138396228392033" }97    ],98    // Row 10: Global Parameters & Auditing Tools99    [100      { text: " Set Reseller Upgrade Fee", callback_data: "/setprice", style: "primary", icon_custom_emoji_id: "5463172695132745432" },101      { text: "All Keys", callback_data: "/allkey", style: "success", icon_custom_emoji_id: "6010210211334200822" },102      { text: "Total Users", callback_data: "/check_users", style: "primary", icon_custom_emoji_id: "6039605143601680423" }103    ],104    // Row 11: Core System Communications Hub105    [106      { text: "Broadcast System Terminal", callback_data: "/broadcast", style: "primary", icon_custom_emoji_id: "6041705726206808304" }107    ],108    // Row 12: 🎟 Coupon System (NEW)109    [110      { text: "Generate Coupon", callback_data: "/gencoupon", style: "success", icon_custom_emoji_id: "6093677128295914531" },111      { text: "View Coupons", callback_data: "/coupons", style: "primary", icon_custom_emoji_id: "6102818532393750087" }112    ],113    // Row 13: 👑 Ownership / Co-Admin Controls (NEW — Owner only, not Co-Admins)114    [115      { text: "Manage Co-Admins", callback_data: "/manage_coadmin", style: "primary", icon_custom_emoji_id: "6102856637343600044" },116      { text: "Transfer Ownership", callback_data: "/transfer_ownership", style: "danger", icon_custom_emoji_id: "6215386799133433653" }117    ],118    // Row 14: 🛠 Global + Product Maintenance / Stock / Demo controls119    [120      { text: "Global Maintenance", callback_data: "/toggle_maintenance", style: "danger", icon_custom_emoji_id: "6100657257605763582" }121    ],122    [123      { text: "Product Maintenance", callback_data: "/toggle_product_maintenance", style: "danger", icon_custom_emoji_id: "6100657257605763582" },124      { text: "Plan Stock ON/OFF", callback_data: "/toggle_plan_stock", style: "primary", icon_custom_emoji_id: "6039605143601680423" }125    ],126    [127      { text: "Set Demo Video", callback_data: "/set_demo_video", style: "primary", icon_custom_emoji_id: "5258077307985207053" }128    ],129    // Row 15: 💎 Reseller System (NEW)130    [131      { text: "Toggle Reseller System", callback_data: "/toggle_reseller_system", style: "success", icon_custom_emoji_id: "6102856637343600044" },132      { text: "Set Reseller Price", callback_data: "/set_reseller_price", style: "primary", icon_custom_emoji_id: "6312263493051489212" }133    ],134    // Row 16: 👑 Direct Reseller (NEW) — admin types a User ID, no payment needed135    [136      { text: "Direct Reseller (by User ID)", callback_data: "/addreseller_info", style: "success", icon_custom_emoji_id: "6215386799133433653" }137    ],138    // Row 17: 💸 Auto-Discount System (NEW)139    [140      { text: "Set Product/Plan Discount", callback_data: "/set_discount", style: "primary", icon_custom_emoji_id: "6093677128295914531" }141    ],142    // Row 18: 🔗 Download Files Link (NEW)143    [144      { text: "Set Download Link", callback_data: "/set_download_link_btn", style: "primary", icon_custom_emoji_id: "6091571559233755994" }145    ],146    // Row 19: 💳 Payment API / UPI Control (NEW)147    [148      { text: "Set Payment (UPI + Fam Pay API)", callback_data: "/set_payment_upi_btn", style: "primary", icon_custom_emoji_id: "6312263493051489212" }149    ],150    // Row 19b: 🟡 Binance Pay Control (NEW)151    [152      { text: "Set Payment (Binance Pay)", callback_data: "/set_payment_binance_btn", style: "primary", icon_custom_emoji_id: "6312263493051489212" }153    ],154    // Row 21: 🎁 Refer & Earn Amount Control (NEW)155    [156      { text: "Set Refer & Earn Amount", callback_data: "/set_refer_earn_btn", style: "success", icon_custom_emoji_id: "5823654080584618403" }157    ],158    // Row 22: 📹 How To Use Link Control (NEW)159    [160      { text: "Set How-To-Use Link", callback_data: "/set_how_link_btn", style: "primary", icon_custom_emoji_id: "5258077307985207053" }161    ],162    // Row 23: ✅ Payment Proof Link Control (NEW)163    [164      { text: "Set Payment Proof Link", callback_data: "/set_proof_link_btn", style: "primary", icon_custom_emoji_id: "5330237710655306682" }165    ],166    // Row 24: 📞 Support Admin Username Link Control (NEW)167    [168      { text: "Set Support Link", callback_data: "/set_support_link_btn", style: "danger", icon_custom_emoji_id: "6267129592998270736" }169    ]170  ];171 172  // 🤖 DISPATCH PIPELINE EXECUTION173  // ✅ FIXED: pehle ye hamesha hardcoded adminId ko panel bhejta tha — agar174  // koi co-admin /admin kholta, to panel unko na milkar owner ke chat me175  // chala jaata tha. Ab panel usi chat me jaata hai jisne /admin request kiya.176  Api.sendMessage({177    chat_id: currentChatId,178    text: adminPanelText,179    parse_mode: "HTML",180    reply_markup: JSON.stringify({181      inline_keyboard: adminKeyboard182    })183  });184 185} catch (err) {186  Bot.sendMessage("Admin Panel Premium Cluster Error: " + err.message);187}