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
ProfileTelegram
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
Back to folder

commands/_bulkadd.js

javascript · 120 lines

Raw
1/**#command2name: /bulkadd3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  var adminId = String(Bot.getProperty("owner_id") || Bot.getProperty("admin_id") || "8477746023");14  var userId = String(user.telegramid);15  var isCoAdmin = Bot.getProperty("co_admin_" + userId) === true;16  if (userId !== adminId && !isCoAdmin) {17    Bot.sendMessage("❌ Only admin can use this command.");18    return;19  }20 21  var raw = (typeof message !== "undefined" && message) ? String(message) : "";22  raw = raw.replace(/^\/bulkadd(?:@\w+)?/i, "").trim();23 24  if (!raw || raw.indexOf("|") === -1) {25    Bot.sendMessage(26      "⚠️ <b>Format:</b>\n<code>/bulkadd\nBGMI 60 UC | 75\nBGMI 300 UC | 380\nFree Fire 100 Diamonds | 80</code>\n\n" +27      "Price ko 30 Days plan ke roop me add/update kiya jayega.",28      {parse_mode:"HTML"}29    );30    return;31  }32 33  var products = Bot.getProperty("stored_products");34  if (!Array.isArray(products)) products = [];35 36  var lines = raw.split(/\r?\n/);37  var count = 0;38  var invalid = 0;39 40  for (var i = 0; i < lines.length; i++) {41    var line = lines[i].trim();42    if (!line) continue;43 44    var parts = line.split("|");45    if (parts.length < 2) { invalid++; continue; }46 47    var name = parts[0].trim();48    var price = Number(String(parts.slice(1).join("|")).trim());49 50    if (!name || !isFinite(price) || price < 0) {51      invalid++;52      continue;53    }54 55    var idx = -1;56    for (var j = 0; j < products.length; j++) {57      if (products[j] && products[j].name &&58          String(products[j].name).trim().toLowerCase() === name.toLowerCase()) {59        idx = j;60        break;61      }62    }63 64    if (idx === -1) {65      products.push({66        name: name,67        emoji: "",68        id: "",69        manual_key_product: true,70        category: "both",71        plans: [{72          id: "bulk_" + Date.now() + "_" + i,73          name: "30 Days",74          days: 30,75          unit: "day",76          durationDisplay: "30 Days",77          normal_price: price,78          reseller_price: price,79          price: price80        }]81      });82    } else {83      if (!Array.isArray(products[idx].plans)) products[idx].plans = [];84      var pidx = -1;85      for (var k = 0; k < products[idx].plans.length; k++) {86        var pl = products[idx].plans[k];87        if (pl && (String(pl.days) === "30" || String(pl.durationDisplay || "").toLowerCase() === "30 days")) {88          pidx = k;89          break;90        }91      }92 93      var newPlan = {94        id: (pidx >= 0 && products[idx].plans[pidx].id) ? products[idx].plans[pidx].id : ("bulk_" + Date.now() + "_" + i),95        name: "30 Days",96        days: 30,97        unit: "day",98        durationDisplay: "30 Days",99        normal_price: price,100        reseller_price: price,101        price: price102      };103 104      if (pidx >= 0) products[idx].plans[pidx] = newPlan;105      else products[idx].plans.push(newPlan);106    }107    count++;108  }109 110  Bot.setProperty("stored_products", products, "json");111  Bot.sendMessage(112    "✅ <b>Bulk Add Complete!</b>\n\n" +113    "📦 Added/Updated: <code>" + count + "</code>\n" +114    "⚠️ Invalid lines: <code>" + invalid + "</code>\n" +115    "💡 Price: 30 Days plan",116    {parse_mode:"HTML"}117  );118} catch (e) {119  Bot.sendMessage("❌ Bulk add error: " + e.message);120}