devbro468/Dev_x_store_botPublic · Bot Template
AIThis bot operates a digital storefront (DEV X STORE) selling subscription-based products — likely game hacks, accounts, or access keys — categorized by platform (Android Root, Non-Root, iPhone). It features a reseller program with discounted pricing, a dual-currency wallet (INR balance + Telegram Stars/XTR), and a full admin/co-admin panel for managing products, plans, per-plan pricing, stock (keys/accounts), coupons, and API endpoints. Purchases flow through a plan selection screen offering wallet payment, Stars invoices (sendInvoice with XTR currency), and coupon application. Successful Stars payments are handled via successful_payment webhook, crediting wallet or delivering keys directly. Admin tools include user listing with chunked messaging, stock viewing/deletion with inline keyboards, co-admin management, and API registry updates. The bot registers users on first interaction and
commands/_addproduct.js
javascript · 110 lines
1/**#command2name: /addproduct3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12var adminId = Bot.getProperty("owner_id") || "8875810358";13var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));14 15if (chat.chatid == adminId || isCoAdmin0) {16 // Format: /addproduct Name | EmojiID | PID | Category(root/nonroot/iphone/both) | Download Link17 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 | Download Link</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</code>",26 { parse_mode: "HTML" }27 );28 return;29 }30 31 var parts = params.split("|");32 if (parts.length < 5) {33 Bot.sendMessage("⚠️ Sabhi details (Name, Emoji ID, PID, Category, Download Link) '|' 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 var prodDownloadLink = parts[4].trim();41 42 // 4th field = category (root / nonroot / iphone / both), 5th field = product download link.43 var rawCategory = parts.length >= 4 ? parts[3].trim().toLowerCase() : "both";44 var prodCategory = "both";45 if (rawCategory === "root" || rawCategory === "android root" || rawCategory === "androidroot") {46 prodCategory = "root";47 } else if (rawCategory === "nonroot" || rawCategory === "non root" || rawCategory === "android non root" || rawCategory === "androidnonroot") {48 prodCategory = "nonroot";49 } else if (rawCategory === "iphone" || rawCategory === "ios" || rawCategory === "i phone" || rawCategory === "apple") {50 prodCategory = "iphone";51 } else {52 prodCategory = "both";53 }54 55 // Safe database fetch56 var productList = Bot.getProperty("stored_products");57 if (!Array.isArray(productList)) {58 productList = [];59 }60 61 // ✅ BUG FIX: pehle har /addproduct call ek NAYA duplicate entry bana deta tha,62 // chahe wahi product naam se pehle se maujood ho — isse shop me same product63 // do baar dikhta tha aur plans purani wali entry se hi attached rehte the.64 // Ab existing product (case-insensitive match) ho to usi ko UPDATE karta hai,65 // uske plans (agar honge) safe rehte hain.66 var existingIdx = -1;67 for (var pi = 0; pi < productList.length; pi++) {68 if (productList[pi].name && productList[pi].name.trim().toLowerCase() === prodName.toLowerCase()) {69 existingIdx = pi;70 break;71 }72 }73 74 var isUpdate = existingIdx > -1;75 76 if (isUpdate) {77 productList[existingIdx].name = prodName;78 productList[existingIdx].emoji = prodEmoji;79 productList[existingIdx].id = prodId;80 productList[existingIdx].category = prodCategory;81 productList[existingIdx].download_link = prodDownloadLink;82 if (!Array.isArray(productList[existingIdx].plans)) { productList[existingIdx].plans = []; }83 } else {84 productList.push({85 name: prodName,86 emoji: prodEmoji,87 id: prodId,88 category: prodCategory,89 download_link: prodDownloadLink,90 plans: []91 });92 }93 94 // Save karo95 Bot.setProperty("stored_products", productList, "json");96 97 Bot.sendMessage(98 "<blockquote>✅ <b>Product " + (isUpdate ? "Updated" : "Successfully Added") + "!</b></blockquote>\n\n" +99 "📦 <b>Name:</b> " + prodName + "\n" +100 "💎 <b>Emoji:</b> <code>" + prodEmoji + "</code>\n" +101 "🔑 <b>PID:</b> <code>" + prodId + "</code>\n" +102 "📂 <b>Category:</b> <code>" + (prodCategory === "root" ? "ANDROID ROOT" : prodCategory === "nonroot" ? "ANDROID NON ROOT" : prodCategory === "iphone" ? "iPHONE" : "BOTH") + "</code>\n" +103 "🔗 <b>Download Link:</b> <code>" + prodDownloadLink + "</code>\n\n" +104 "<i>" + (isUpdate ? "Existing plans safe rakhe gaye hain." : "Ab yeh product store me sabhi ko dikhega! Use /addplan to add pricing plans.") + "</i>",105 { parse_mode: "HTML" }106 );107 108} else {109 Bot.sendMessage("❌ You are not the admin!");110}