indrajitghosh20006/Igstore_01botPublic Β· Bot Template

ProfileTelegram

AIThe bot provides an admin interface for a digital store, allowing the owner or co‑admins to add balances, products, plans, and categories. It supports payment workflows via UPI and Binance Pay, automatically generating QR codes and handling manual approval of deposits. The code patches inline keyboards to use premium emoji icons and includes helper functions for user and bot properties. Overall, it serves as a commerce management tool for a Telegram-based storefront.

Commercestoreadminbalanceproductplancategory
170 commands0 envUpdated 8h agoCreated Oct 30, 2026
Back to folder

commands/_addproduct.js

javascript Β· 153 lines

Raw
1/**#command2name: /addproduct3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// PREMIUM BUTTON ICONS13(function(){14  try {15    if (!JSON.__premiumPatched) {16      var __origStringify = JSON.stringify;17      JSON.stringify = function(value, replacer, space) {18        try {19          if (value && value.inline_keyboard && Array.isArray(value.inline_keyboard)) {20            var premiumIds = [21              "6143444134125379822",22              "6091379307907652768",23              "6147534454819661264",24              "6147817325660741985",25              "6235683689292897318",26              "6102856637343600044"27            ];28            var rows = value.inline_keyboard.map(function(row, ri) {29              if (!Array.isArray(row)) return row;30              return row.map(function(btn, bi) {31                if (!btn || typeof btn !== "object") return btn;32                var copy = {};33                for (var k in btn) copy[k] = btn[k];34                if (!copy.icon_custom_emoji_id) copy.icon_custom_emoji_id = premiumIds[(ri + bi) % premiumIds.length];35                return copy;36              });37            });38            var cloned = {};39            for (var key in value) cloned[key] = value[key];40            cloned.inline_keyboard = rows;41            return __origStringify.call(JSON, cloned, replacer, space);42          }43        } catch (e) {}44        return __origStringify.call(JSON, value, replacer, space);45      };46      JSON.__premiumPatched = true;47    }48  } catch (e) {}49})();50 51 52 53var adminId = Bot.getProperty("owner_id") || "7839151435";54var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));55 56if (chat.chatid == adminId || isCoAdmin0) {57  // Format: /addproduct Name | EmojiID | Category (PID is now plan-level)58  if (!params || params.trim() === "") {59    Bot.sendMessage(60      "⚠️ <b>Galat Format!</b>\n\n" +61      "Kripya is tarah bhejien:\n" +62      "<code>/addproduct Name | EmojiID | Category</code>\n\n" +63      "<b>Category</b> me likhein: <code>root</code>, <code>nonroot</code>, <code>iphone</code> ya <code>both</code>\n\n" +64      "<b>Example:</b>\n<code>/addproduct Drip Client | 61160843705 | root</code>\n" +65      "<code>/addproduct Drip Client | 61160843705 | nonroot</code>\n" +66      "<code>/addproduct Panther Spoofer | 61160843705 | iphone</code>",67      { parse_mode: "HTML" }68    );69    return;70  }71 72  var parts = params.split("|");73  if (parts.length < 2) {74    Bot.sendMessage("⚠️ Name aur Emoji ID zaroori hain. PID ab Add Product me nahi liya jayega!", { parse_mode: "HTML" });75    return;76  }77 78  var prodName = parts[0].trim();79  var prodEmoji = parts[1].trim();80 81  // βœ… PID is now plan-level. Add Product only creates the hack/product.82  // 3rd field = category (root / nonroot / iphone / both).83  var rawCategory = parts.length >= 3 ? parts[2].trim().toLowerCase() : "both";84 85  // Agar purane 4-field format se koi product add kiya gaya ho, category ko86  // 4th field se bhi read kar lo, lekin PID ko product-level par store nahi karna.87  if (parts.length >= 4) { rawCategory = parts[3].trim().toLowerCase(); }88 89  // βœ… NEW: 4th field = category (root / nonroot / iphone / both). Agar admin nahi bhejta90  // toh default "both" β€” taaki purana /addproduct format (3 fields) bhi chalta rahe.91  var prodCategory = "both";92  if (rawCategory === "root" || rawCategory === "android root" || rawCategory === "androidroot") {93    prodCategory = "root";94  } else if (rawCategory === "nonroot" || rawCategory === "non root" || rawCategory === "android non root" || rawCategory === "androidnonroot") {95    prodCategory = "nonroot";96  } else if (rawCategory === "iphone" || rawCategory === "ios" || rawCategory === "i phone" || rawCategory === "apple") {97    prodCategory = "iphone";98  } else {99    prodCategory = "both";100  }101 102  // Safe database fetch103  var productList = Bot.getProperty("stored_products");104  if (!Array.isArray(productList)) {105    productList = [];106  }107 108  // βœ… BUG FIX: pehle har /addproduct call ek NAYA duplicate entry bana deta tha,109  // chahe wahi product naam se pehle se maujood ho β€” isse shop me same product110  // do baar dikhta tha aur plans purani wali entry se hi attached rehte the.111  // Ab existing product (case-insensitive match) ho to usi ko UPDATE karta hai,112  // uske plans (agar honge) safe rehte hain.113  var existingIdx = -1;114  for (var pi = 0; pi < productList.length; pi++) {115    if (productList[pi].name && productList[pi].name.trim().toLowerCase() === prodName.toLowerCase()) {116      existingIdx = pi;117      break;118    }119  }120 121  var isUpdate = existingIdx > -1;122 123  if (isUpdate) {124    productList[existingIdx].name = prodName;125    productList[existingIdx].emoji = prodEmoji;126    // PID intentionally removed from product-level data; each plan owns its PID.127    delete productList[existingIdx].id;128    productList[existingIdx].category = prodCategory;129    if (!Array.isArray(productList[existingIdx].plans)) { productList[existingIdx].plans = []; }130  } else {131    productList.push({132      name: prodName,133      emoji: prodEmoji,134      category: prodCategory,135      plans: []136    });137  }138 139  // Save karo140  Bot.setProperty("stored_products", productList, "json");141 142  Bot.sendMessage(143    "<blockquote>βœ… <b>Product " + (isUpdate ? "Updated" : "Successfully Added") + "!</b></blockquote>\n\n" +144    "πŸ“¦ <b>Name:</b> " + prodName + "\n" +145    "πŸ’Ž <b>Emoji:</b> <code>" + prodEmoji + "</code>\n" +146    "πŸ“‚ <b>Category:</b> <code>" + (prodCategory === "root" ? "ANDROID ROOT" : prodCategory === "nonroot" ? "ANDROID NON ROOT" : prodCategory === "iphone" ? "iPHONE" : "BOTH") + "</code>\n\n" +147    "<i>" + (isUpdate ? "Existing plans safe rakhe gaye hain." : "Ab yeh product store me sabhi ko dikhega! Use /addplan to add pricing plans.") + "</i>",148    { parse_mode: "HTML" }149  );150 151} else {152  Bot.sendMessage("❌ You are not the admin!");153}