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/_buy_hack_cat.js

javascript Β· 165 lines

Raw
1/**#command2name: /buy_hack_cat3answer: 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// =========================================================54// πŸ›’ SHOP MENU β€” Product listing filtered by category (Step 1.5)55// Called after user selects "ANDROID ROOT" or "ANDROID NON ROOT" from56// /buy_hack. Shows only products matching that category. Products added57// with category "both" (or no category set at all β€” legacy products)58// show up under BOTH root and nonroot listings.59// =========================================================60 61try {62  var rawData = Bot.getProperty("stored_products");63  var productList = [];64 65  if (Array.isArray(rawData)) {66    productList = rawData;67  } else if (typeof rawData === "string") {68    try {69      productList = JSON.parse(rawData);70      if (!Array.isArray(productList)) { productList = []; }71    } catch (e) {72      productList = [];73    }74  }75 76  var chatId = chat.chatid;77  var firstName = user && user.first_name ? user.first_name : "User";78 79  // Category param β€” "root" or "nonroot"80  var category = params ? params.trim().toLowerCase() : "";81  if (category === "") {82    var cbData = request && request.callback_query ? request.callback_query.data : "";83    category = cbData.replace("/buy_hack_cat ", "").replace("buy_hack_cat ", "").trim().toLowerCase();84  }85  if (category !== "root" && category !== "nonroot" && category !== "iphone") { category = "nonroot"; }86 87  var categoryLabel = (category === "root") ? "ANDROID ROOT" : (category === "iphone") ? "iPHONE" : "ANDROID NON ROOT";88 89  var productButtons = [];90 91  for (var i = 0; i < productList.length; i++) {92    var item = productList[i];93    if (!item) { continue; }94 95    // Legacy products (no category field) ya "both" wale β€” dono categories me dikhte hain.96    var itemCategory = item.category ? String(item.category).toLowerCase() : "both";97    if (itemCategory !== "both" && itemCategory !== category) { continue; }98 99    var itemName = item.name ? String(item.name) : "Product " + (i + 1);100    var itemEmoji = item.emoji ? String(item.emoji) : "5226656353744862682";101 102    // πŸ›  PANEL-WISE MAINTENANCE DISPLAY103    // Maintenance ON panel stays visible, but becomes RED and clearly shows104    // the maintenance logo/status. Clicking it still reaches /viewprod,105    // where the purchase is blocked by the maintenance guard.106    var itemMaintKey = "panel_maintenance_" +107      String(item.id || item.name || i).toUpperCase().replace(/[^A-Z0-9_-]/g, "_");108    var itemUnderMaintenance = Bot.getProperty(itemMaintKey) === true;109 110    productButtons.push([111      {112        text: itemUnderMaintenance ? "πŸ› οΈ " + itemName + " β€’ MAINTENANCE" : itemName,113        callback_data: "/viewprod " + i,114        style: itemUnderMaintenance ? "danger" : "primary",115        icon_custom_emoji_id: itemUnderMaintenance116          ? "6100657257605763582"117          : itemEmoji118      }119    ]);120  }121 122  var storeName = String(Bot.getProperty("store_name") || "𝙄𝙂 π™Žπ™π™Šπ™π™€");123  storeName = storeName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");124 125  var storeText =126    "<blockquote><b>πŸ›’ " + storeName + " πŸ›’</b></blockquote>\n" +127    "━━━━━━━━━━━━━━━━━━━━━\n\n" +128    "<tg-emoji emoji-id='6064280370667332428'>πŸ”₯</tg-emoji> <b>Choose a product:</b>\n" +129    "━━━━━━━━━━━━━━━━━━━━━";130 131  productButtons.push([132    {133      text: "Back",134      callback_data: "/buy_hack",135      style: "danger",136      icon_custom_emoji_id: "5893163582194978381"137    }138  ]);139 140  var replyMarkupStr = JSON.stringify({ inline_keyboard: productButtons });141 142  if (request && request.message && request.message.message_id) {143    if (request.message.photo) {144      try { Api.deleteMessage({ chat_id: chatId, message_id: request.message.message_id }); } catch (e) {}145      Api.sendMessage({ chat_id: chatId, text: storeText, parse_mode: "HTML", reply_markup: replyMarkupStr });146    } else {147      Api.editMessageText({148        chat_id: chatId,149        message_id: request.message.message_id,150        text: storeText,151        parse_mode: "HTML",152        reply_markup: replyMarkupStr153      });154    }155  } else {156    Api.sendMessage({ chat_id: chatId, text: storeText, parse_mode: "HTML", reply_markup: replyMarkupStr });157  }158 159  if (request && request.id) {160    try { Api.answerCallbackQuery({ callback_query_id: request.id }); } catch (e) {}161  }162 163} catch (err) {164  Bot.sendMessage("⚠️ Shop Menu Error: " + err.message, { parse_mode: "HTML" });165}