indrajitghosh20006/HgfhhuybotPublic · Bot Template
AIThis bot provides a command‑based admin interface for managing user balances, products, and resellers. It supports adding balances via UPI or Binance Pay, approving payments, and configuring product details and categories. The bot also handles user role changes, stock uploads, and offers a simple calculator UI for entering amounts. All interactions are handled through short commands and inline keyboards, with no long‑running listeners or external frameworks.
Utilityadminbalanceproductresellerpaymentupi
138 commands0 envUpdated 15h agoCreated Sep 27, 2026
commands/_addproduct.js
javascript · 113 lines
1/**#command2name: /addproduct3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12var adminId = Bot.getProperty("owner_id") || "7839151435";13var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));14 15if (chat.chatid == adminId || isCoAdmin0) {16 // Format: /addproduct Name | EmojiID | PID | Category(root/nonroot/both) | Features(optional)17 if (!params || params.trim() === "") {18 Bot.sendMessage(19 "⚠️ <b>Galat Format!</b>\n\n" +20 "Kripya is tarah bhejien:\n" +21 "<code>/addproduct Name | EmojiID | PID | Category | Features</code>\n\n" +22 "<b>Category</b> me likhein: <code>root</code>, <code>nonroot</code>, <code>iphone</code> ya <code>both</code>\n\n" +23 "<b>Example:</b>\n<code>/addproduct Drip Client | 61160843705 | 91 | root</code>\n" +24 "<code>/addproduct Drip Client | 61160843705 | 92 | nonroot</code>\n" +25 "<code>/addproduct Panther Spoofer | 61160843705 | 93 | iphone | Anti Ban, Smooth, Fast Update</code>",26 { parse_mode: "HTML" }27 );28 return;29 }30 31 var parts = params.split("|");32 if (parts.length < 3) {33 Bot.sendMessage("⚠️ Sabhi details (Name, Emoji ID, PID) '|' lagakar bhejein!", { parse_mode: "HTML" });34 return;35 }36 37 var prodName = parts[0].trim();38 var prodEmoji = parts[1].trim();39 var prodId = parts[2].trim();40 // Optional product features. Multiple features can be comma-separated.41 var prodFeaturesRaw = parts.length >= 5 ? parts.slice(4).join("|").trim() : "";42 var prodFeatures = prodFeaturesRaw ? prodFeaturesRaw.split(/[,\n]+/).map(function(f){ return f.trim(); }).filter(function(f){ return !!f; }) : [];43 44 // ✅ NEW: 4th field = category (root / nonroot / iphone / both). Agar admin nahi bhejta45 // toh default "both" — taaki purana /addproduct format (3 fields) bhi chalta rahe.46 var rawCategory = parts.length >= 4 ? parts[3].trim().toLowerCase() : "both";47 var prodCategory = "both";48 if (rawCategory === "root" || rawCategory === "android root" || rawCategory === "androidroot") {49 prodCategory = "root";50 } else if (rawCategory === "nonroot" || rawCategory === "non root" || rawCategory === "android non root" || rawCategory === "androidnonroot") {51 prodCategory = "nonroot";52 } else if (rawCategory === "iphone" || rawCategory === "ios" || rawCategory === "i phone" || rawCategory === "apple") {53 prodCategory = "iphone";54 } else {55 prodCategory = "both";56 }57 58 // Safe database fetch59 var productList = Bot.getProperty("stored_products");60 if (!Array.isArray(productList)) {61 productList = [];62 }63 64 // ✅ BUG FIX: pehle har /addproduct call ek NAYA duplicate entry bana deta tha,65 // chahe wahi product naam se pehle se maujood ho — isse shop me same product66 // do baar dikhta tha aur plans purani wali entry se hi attached rehte the.67 // Ab existing product (case-insensitive match) ho to usi ko UPDATE karta hai,68 // uske plans (agar honge) safe rehte hain.69 var existingIdx = -1;70 for (var pi = 0; pi < productList.length; pi++) {71 if (productList[pi].name && productList[pi].name.trim().toLowerCase() === prodName.toLowerCase()) {72 existingIdx = pi;73 break;74 }75 }76 77 var isUpdate = existingIdx > -1;78 79 if (isUpdate) {80 productList[existingIdx].name = prodName;81 productList[existingIdx].emoji = prodEmoji;82 productList[existingIdx].id = prodId;83 productList[existingIdx].category = prodCategory;84 productList[existingIdx].features = prodFeatures;85 if (!Array.isArray(productList[existingIdx].plans)) { productList[existingIdx].plans = []; }86 } else {87 productList.push({88 name: prodName,89 emoji: prodEmoji,90 id: prodId,91 category: prodCategory,92 features: prodFeatures,93 plans: []94 });95 }96 97 // Save karo98 Bot.setProperty("stored_products", productList, "json");99 100 Bot.sendMessage(101 "<blockquote>✅ <b>Product " + (isUpdate ? "Updated" : "Successfully Added") + "!</b></blockquote>\n\n" +102 "📦 <b>Name:</b> " + prodName + "\n" +103 "💎 <b>Emoji:</b> <code>" + prodEmoji + "</code>\n" +104 "🔑 <b>PID:</b> <code>" + prodId + "</code>\n" +105 "📂 <b>Category:</b> <code>" + (prodCategory === "root" ? "ANDROID ROOT" : prodCategory === "nonroot" ? "ANDROID NON ROOT" : prodCategory === "iphone" ? "iPHONE" : "BOTH") + "</code>\n" +106 "✨ <b>Features:</b> " + (prodFeatures.length ? prodFeatures.join(", ") : "<i>Optional / Not set</i>") + "\n\n" +107 "<i>" + (isUpdate ? "Existing plans safe rakhe gaye hain." : "Ab yeh product store me sabhi ko dikhega! Use /addplan to add pricing plans.") + "</i>",108 { parse_mode: "HTML" }109 );110 111} else {112 Bot.sendMessage("❌ You are not the admin!");113}