ayushyadav7970824760/goldensellingstore_botPublic · Bot Template
AIThis Telegram store bot lets customers browse digital products and plans, apply coupons, add funds via UPI, and receive purchased keys. It includes a full admin panel for managing products, reordering items, setting reseller prices, viewing and removing key stock, configuring UPI payment details and update links, and checking user balances. Co-admins and resellers are supported, and support tickets are forwarded to the admin.
Commercedigital_storeadmin_panelupi_paymentsresellercouponskey_stock
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
commands/_addproduct.js
javascript · 120 lines
1/**#command2name: /addproduct3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12var adminId = Bot.getProperty("owner_id") || "8477746023";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)17 // ✅ PID ki jagah -, skip, none, ya pid bhejo agar website API nahi hai —18 // aisa product "manual key" ban jaayega: har order par aapko ek "Give Key"19 // button milega, jisse aap khud key bhej sakte ho.20 if (!params || params.trim() === "") {21 Bot.sendMessage(22 "⚠️ <b>Galat Format!</b>\n\n" +23 "Kripya is tarah bhejien:\n" +24 "<code>/addproduct Name | EmojiID | PID | Category</code>\n\n" +25 "<b>Category</b> me likhein: <code>root</code>, <code>nonroot</code>, <code>iphone</code> ya <code>both</code>\n\n" +26 "<b>Example (Website API se auto-delivery):</b>\n<code>/addproduct Drip Client | 61160843705 | 91 | root</code>\n\n" +27 "<b>Example (PID nahi hai — aap khud manually key doge):</b>\n<code>/addproduct Drip Client | 61160843705 | - | root</code>\n" +28 "<i>(PID ki jagah -, skip, none ya pid bhi likh sakte ho — sab ka matlab \"no PID / manual key\" hoga)</i>",29 { parse_mode: "HTML" }30 );31 return;32 }33 34 var parts = params.split("|");35 if (parts.length < 3) {36 Bot.sendMessage("⚠️ Sabhi details (Name, Emoji ID, PID) '|' lagakar bhejein!", { parse_mode: "HTML" });37 return;38 }39 40 var prodName = parts[0].trim();41 var prodEmoji = parts[1].trim();42 var prodIdRaw = parts[2].trim();43 44 // ✅ NEW: PID field me -, skip, none, pid, pid_id, n/a, ya 0 likhne ka matlab45 // hai "koi website API PID nahi hai" — ye product manual-key product ban46 // jaata hai, jisme har order par admin ko "Give Key" button milta hai.47 var isManualPidSkip = /^(-|skip|none|0|pid|pid_id|n\/?a)$/i.test(prodIdRaw);48 var prodId = isManualPidSkip ? "" : prodIdRaw;49 50 // ✅ NEW: 4th field = category (root / nonroot / iphone / both). Agar admin nahi bhejta51 // toh default "both" — taaki purana /addproduct format (3 fields) bhi chalta rahe.52 var rawCategory = parts.length >= 4 ? parts[3].trim().toLowerCase() : "both";53 var prodCategory = "both";54 if (rawCategory === "root" || rawCategory === "android root" || rawCategory === "androidroot") {55 prodCategory = "root";56 } else if (rawCategory === "nonroot" || rawCategory === "non root" || rawCategory === "android non root" || rawCategory === "androidnonroot") {57 prodCategory = "nonroot";58 } else if (rawCategory === "iphone" || rawCategory === "ios" || rawCategory === "i phone" || rawCategory === "apple") {59 prodCategory = "iphone";60 } else {61 prodCategory = "both";62 }63 64 // Safe database fetch65 var productList = Bot.getProperty("stored_products");66 if (!Array.isArray(productList)) {67 productList = [];68 }69 70 // ✅ BUG FIX: pehle har /addproduct call ek NAYA duplicate entry bana deta tha,71 // chahe wahi product naam se pehle se maujood ho — isse shop me same product72 // do baar dikhta tha aur plans purani wali entry se hi attached rehte the.73 // Ab existing product (case-insensitive match) ho to usi ko UPDATE karta hai,74 // uske plans (agar honge) safe rehte hain.75 var existingIdx = -1;76 for (var pi = 0; pi < productList.length; pi++) {77 if (productList[pi].name && productList[pi].name.trim().toLowerCase() === prodName.toLowerCase()) {78 existingIdx = pi;79 break;80 }81 }82 83 var isUpdate = existingIdx > -1;84 85 if (isUpdate) {86 productList[existingIdx].name = prodName;87 productList[existingIdx].emoji = prodEmoji;88 productList[existingIdx].id = prodId;89 productList[existingIdx].manual_key_product = isManualPidSkip;90 productList[existingIdx].category = prodCategory;91 if (!Array.isArray(productList[existingIdx].plans)) { productList[existingIdx].plans = []; }92 } else {93 productList.push({94 name: prodName,95 emoji: prodEmoji,96 id: prodId,97 manual_key_product: isManualPidSkip,98 category: prodCategory,99 plans: []100 });101 }102 103 // Save karo104 Bot.setProperty("stored_products", productList, "json");105 106 Bot.sendMessage(107 "<blockquote>✅ <b>Product " + (isUpdate ? "Updated" : "Successfully Added") + "!</b></blockquote>\n\n" +108 "📦 <b>Name:</b> " + prodName + "\n" +109 "<tg-emoji emoji-id='" + prodEmoji + "'>💎</tg-emoji> <b>Emoji ID:</b> <code>" + prodEmoji + "</code>\n" +110 (isManualPidSkip ?111 "🔑 <b>Delivery:</b> <code>Manual (Admin gives key on each order)</code>\n" :112 "🔑 <b>PID:</b> <code>" + prodId + "</code>\n") +113 "📂 <b>Category:</b> <code>" + (prodCategory === "root" ? "ANDROID ROOT" : prodCategory === "nonroot" ? "ANDROID NON ROOT" : prodCategory === "iphone" ? "iPHONE" : "BOTH") + "</code>\n\n" +114 "<i>" + (isUpdate ? "Existing plans safe rakhe gaye hain." : "Ab yeh product store me sabhi ko dikhega! Use /addplan to add pricing plans.") + "</i>",115 { parse_mode: "HTML" }116 );117 118} else {119 Bot.sendMessage("❌ You are not the admin!");120}