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/_clearstock.js
javascript Β· 158 lines
1/**#command2name: /clearstock3answer: 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 53try {54 var ADMIN_ID = "7839151435";55 56 if (String(user.telegramid) !== ADMIN_ID) {57 return;58 }59 60 // FIX 1: Message aur Params dono check karein (Button callback aur Direct typing dono handle karne ke liye)61 var input = (message || "").trim();62 var catSlug = "";63 64 if (params && params.trim() !== "") {65 catSlug = params.trim().toLowerCase();66 } else if (input.indexOf(" ") !== -1) {67 catSlug = input.split(" ")[1].trim().toLowerCase();68 } else {69 Bot.sendMessage("β οΈ <b>Format:</b> <code>/clearstock [category_slug]</code>\n\n<i>Example: /clearstock lodu</i>", { parse_mode: "HTML" });70 return;71 }72 73 var categories = Bot.getProperty("ff_categories") || {};74 75 if (!categories[catSlug]) {76 Bot.sendMessage(77 "β Category <code>" + catSlug + "</code> not found.",78 { parse_mode: "HTML" }79 );80 return;81 }82 83 // Stock check84 var oldStock = categories[catSlug].stock_list || Bot.getProperty("ff_stock_" + catSlug) || [];85 if (!Array.isArray(oldStock)) { oldStock = []; }86 87 var catName = categories[catSlug].name ? categories[catSlug].name.toUpperCase() : catSlug.toUpperCase();88 89 // HTML Content Builder90 var text = "<blockquote><tg-emoji emoji-id='5447644880824181073'>β οΈ</tg-emoji> <b>CONFIRM STOCK DELETION</b></blockquote>\n" +91 "ββββββββββββββββββββββββββ\n" +92 "π <b>Category:</b> <code>" + catName + "</code>\n" +93 "π¦ <b>Total Items:</b> <code>" + oldStock.length + "</code>\n" +94 "ββββββββββββββββββββββββββ\n\n" +95 "π <b>LIVE STOCK LIST:</b>\n\n";96 97 if (oldStock.length > 0) {98 for (var i = 0; i < oldStock.length; i++) {99 var rawItem = oldStock[i];100 var email = "N/A";101 var pass = "N/A";102 var price = "N/A"; // Added Price Variable103 104 // FIX 2: email|password|price dynamic parsing logic105 if (typeof rawItem === "string") {106 if (rawItem.indexOf("|") !== -1) {107 var parts = rawItem.split("|");108 email = parts[0] ? parts[0].trim() : "N/A";109 pass = parts[1] ? parts[1].trim() : "N/A";110 price = parts[2] ? parts[2].trim() : "N/A"; // Extra Price extraction111 } else {112 email = rawItem.trim();113 }114 } else if (rawItem && typeof rawItem === "object") {115 email = rawItem.email || rawItem.username || "N/A";116 pass = rawItem.password || rawItem.pass || "N/A";117 price = rawItem.price || "N/A";118 }119 120 text += "π <b>Item #" + (i + 1) + "</b>\n" +121 "π§ <b>Email:</b> <code>" + email + "</code>\n" +122 "π <b>Pass:</b> <code>" + pass + "</code>\n" +123 "π° <b>Price:</b> <code>βΉ" + price + "</code>\n\n"; // Rendered Price beautifully124 }125 } else {126 text += "β <i>Stock is already empty!</i>\n";127 }128 129 text += "ββββββββββββββββββββββββββ\n" +130 "<i>Are you sure you want to permanently delete all items?</i>";131 132 // Inline Buttons133 var inlineButtons = [];134 if (oldStock.length > 0) {135 inlineButtons.push([136 { 137 text: "ποΈ Delete All Stock", 138 callback_data: "/confirm_delete_stock " + catSlug 139 }140 ]);141 }142 inlineButtons.push([143 { text: "β Cancel", callback_data: "/back" }144 ]);145 146 Api.sendMessage({147 chat_id: chat.chatid,148 text: text,149 reply_markup: JSON.stringify({ inline_keyboard: inlineButtons }),150 parse_mode: "HTML"151 });152 153} catch (e) {154 Bot.sendMessage(155 "β <b>Error:</b>\n<code>" + e.message + "</code>",156 { parse_mode: "HTML" }157 );158}