indrajitghosh20006/Igstore_01botPublic Β· Bot Template
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
commands/_addplan.js
javascript Β· 199 lines
1/**#command2name: /addplan3answer: 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 53// Apni Admin Telegram ID yahan dalein54var adminId = Bot.getProperty("owner_id") || "7839151435";55var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));56 57if (chat.chatid != adminId && !isCoAdmin0) {58 Bot.sendMessage("β You are not the admin!");59 return;60}61 62// β
FIXED: Ab sirf "Days" nahi β Hour / Minute bhi support karta hai!63// Format: /addplan PRODUCT NAME | PID | DURATION | NORMAL PRICE | RESELLER PRICE64// DURATION examples: "7" ya "7d" ya "7days" = 7 Days | "1h" ya "1hour" = 1 Hour | "30m" ya "30min" = 30 Minutes65if (!params) {66 Bot.sendMessage(67 "β οΈ Format: `/addplan PRODUCT NAME | PID | DURATION | NORMAL PRICE | RESELLER PRICE`\n\n" +68 "*Examples:*\n" +69 "`/addplan FreeFire Hack | 91 | 7d | 350 | 300` (PID 91, 7 Days)\n" +70 "`/addplan FreeFire Hack | 92 | 1 Hours | 91 | 64` (PID 92, 1 Hour)\n" +71 "`/addplan FreeFire Hack | 93 | 30m | 10 | 8` (PID 93, 30 Minutes)",72 { parse_mode: "Markdown" }73 );74 return;75}76 77var data = params.split("|");78if (data.length < 5) {79 Bot.sendMessage("β οΈ Galat Format! Name, PID, Duration, Normal Price aur Reseller Price β 5 fields '|' se alag honi chahiye.");80 return;81}82 83var pName = data[0].trim();84var planPid = data[1].trim();85var rawDuration = data[2].trim();86var pNormal = parseFloat(data[3].trim());87var pReseller = parseFloat(data[4].trim());88 89if (!planPid) {90 Bot.sendMessage("β Is plan ka PID number zaroor dena hoga.");91 return;92}93 94if (isNaN(pNormal) || isNaN(pReseller)) {95 Bot.sendMessage("β Price numeric (number) honi chahiye!");96 return;97}98 99// π DURATION PARSER β exact API/website labels are preserved verbatim.100// Supports labels such as:101// 1 DaYS NONROOT, House, 1 DaYs, 15 DaYs All Colours Mix,102// 30 DaYs PRO, 1 DaYs Basic, 1 Year Ios Esign Gbox Certificate,103// 1 DaYs Root + Nonroot, 7 DaYS PC AIMKILL, 30 Day Pc Modmenu x86,104// 3 DaYs SAFE, 3 DaYs BRUTAL, etc.105var durationText = rawDuration.replace(/\s+/g, " ").trim();106var durMatch = durationText.toLowerCase().match(/^([0-9]+(?:\.[0-9]+)?)\s*(d|day|days|h|hr|hrs|hour|hours|m|min|mins|minute|minutes)(?:\s+(.+))?$/);107var numericOnly = durationText.match(/^([0-9]+(?:\.[0-9]+)?)/);108var pValue = durMatch ? durMatch[1] : (numericOnly ? numericOnly[1] : "0");109var unitRaw = durMatch ? durMatch[2] : "d";110var customSuffix = durMatch && durMatch[3] ? durMatch[3].trim() : "";111var pUnit = "day";112if (/^h/.test(unitRaw)) { pUnit = "hour"; }113else if (/^m/.test(unitRaw)) { pUnit = "minute"; }114 115// A non-numeric label (for example "House") is valid as an exact API duration name.116if (!durationText) {117 Bot.sendMessage("β Duration/API name empty hai!");118 return;119}120 121var pDays = String(pValue); // legacy field; exact API label is stored separately below.122 123// π’ Dynamic Global Price Keys β unit-aware (Day plans purane format me hi rehte hain,124// taaki pehle se set kiye hue Day-prices na tootein; Hour/Minute plans naye suffix format me)125var cleanProdName = pName.toUpperCase();126var priceKeySuffix = (pUnit === "day") ? pDays : (pDays + "_" + pUnit);127var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;128var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;129 130Bot.setProperty(normalKey, pNormal, "number");131Bot.setProperty(resellerKey, pReseller, "number");132 133// Database se existing products list nikalna134var productList = Bot.getProperty("stored_products") || [];135 136// Check karna ki kya yeh product pehle se list me hai?137var productIndex = -1;138for (var i = 0; i < productList.length; i++) {139 if (productList[i].name.toLowerCase() === pName.toLowerCase()) {140 productIndex = i;141 break;142 }143}144 145// π Human-readable duration label146var unitLabelWord = (pUnit === "hour") ? (Number(pDays) === 1 ? "Hour" : "Hours") :147 (pUnit === "minute") ? (Number(pDays) === 1 ? "Minute" : "Minutes") :148 (Number(pDays) === 1 ? "Day" : "Days");149var durationDisplay = durationText;150 151// πͺ EXACT WEBSITE/API DURATION LABEL152// Never rewrite casing, pluralisation, suffixes, or custom names.153// This fixes labels such as "1 DaYs NONROOT" and "1 Year Ios Esign Gbox Certificate".154var autoWebsiteName = durationText;155 156// Setup complete plan object with dynamic fallback name + unit info157var newPlan = {158 days: pDays, // ab ye numeric "value" hai (backward-compat naam)159 unit: pUnit, // "day" | "hour" | "minute" β
NEW160 durationDisplay: durationDisplay, // β
NEW β human readable, jaise "1 Hour", "30 Minutes", "7 Days"161 normal_price: pNormal,162 reseller_price: pReseller,163 name_on_website: autoWebsiteName,164 api_duration: autoWebsiteName,165 // β
PID belongs to the individual plan, not the hack/product.166 pid: planPid,167 product_id: planPid,168 variant_id: planPid169};170 171if (productIndex !== -1) {172 if (!productList[productIndex].plans) { productList[productIndex].plans = []; }173 174 var planUpdated = false;175 for (var p = 0; p < productList[productIndex].plans.length; p++) {176 var existingUnit = productList[productIndex].plans[p].unit || "day";177 if (String(productList[productIndex].plans[p].days) === pDays && existingUnit === pUnit) {178 productList[productIndex].plans[p] = newPlan;179 planUpdated = true;180 break;181 }182 }183 184 if (!planUpdated) {185 productList[productIndex].plans.push(newPlan);186 }187 Bot.sendMessage("β
Product <b>" + pName + "</b> me PID <code>" + planPid + "</code> ka <code>" + durationDisplay + "</code> plan βΉ" + pNormal + " (Reseller: βΉ" + pReseller + ") par set ho gaya!\nβΉοΈ <i>API Target Format: " + autoWebsiteName + "</i>", { parse_mode: "HTML" });188} else {189 var defaultEmoji = "5226656353744862682"; 190 productList.push({191 name: pName,192 emoji: defaultEmoji,193 plans: [newPlan]194 });195 Bot.sendMessage("β
Naya Product <b>" + pName + "</b> successfully register ho gaya! PID <code>" + planPid + "</code> ke saath.\nβΉοΈ <i>API Target Format: " + autoWebsiteName + "</i>", { parse_mode: "HTML" });196}197 198// Database array update execution199Bot.setProperty("stored_products", productList, "json");