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 7h agoCreated Oct 30, 2026
Back to folder

commands/_select_id_product.js

javascript Β· 204 lines

Raw
1/**#command2name: /select_id_product3answer: 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  // πŸ”₯ CALLBACK DATA CLEARING & PARAM EXTRACTION PIPELINE55  var rawParams = "";56  if (typeof params !== "undefined" && params) {57    rawParams = String(params).trim();58  }59 60  // Fallback check agar dynamic params system bypass ho gaya ho61  if (!rawParams && typeof request !== "undefined" && request) {62    var callbackQuery = request.callback_query || request;63    if (callbackQuery && callbackQuery.data) {64      var dataStr = String(callbackQuery.data).trim();65      var parts = dataStr.split(" ");66      if (parts.length > 1) {67        rawParams = parts.slice(1).join(" ").trim();68      } else {69        rawParams = dataStr;70      }71    }72    73    // Clear loading spinner instantly74    let queryId = request.id || (request.callback_query && request.callback_query.id);75    if (queryId) {76      try { Api.answerCallbackQuery({ callback_query_id: queryId }); } catch (qErr){}77    }78  }79 80  // Safe Chat ID fallback81  var targetChatId = (chat && chat.chatid) ? chat.chatid : ((chat && chat.id) ? chat.id : (user ? user.telegramid : null));82 83  if (!targetChatId) return; // Silent guard if no context exists84 85  // πŸ›‘οΈ SECURITY & EMPTY PARAM CHECK FIX86  if (!rawParams || rawParams.indexOf("/") === 0) { 87    Api.sendMessage({88      chat_id: targetChatId,89      text: "<tg-emoji emoji-id='5244837092042750681'>⚠️</tg-emoji> <b>Session Expired or Invalid Selection.</b>\n\nKripya main menu se phir se product select karein.",90      parse_mode: "HTML"91    });92    return;93  }94 95  var categories = Bot.getProperty("ff_categories") || {};96 97  if (!categories[rawParams]) {98    Api.sendMessage({99      chat_id: targetChatId,100      text: "❌ <b>Product nahi mila ya remove ho chuka hai!</b>\nSelected Slug: <code>" + rawParams + "</code>",101      parse_mode: "HTML"102    });103    return;104  }105 106  var item = categories[rawParams];107  var stockList = Bot.getProperty("ff_stock_" + rawParams) || [];108 109  if (!Array.isArray(stockList)) stockList = [];110 111  // Safe user role derivation112  var userId = (user && user.telegramid) ? user.telegramid : targetChatId;113  var isReseller = Bot.getProperty("is_reseller_" + userId);114  var hasResellerAccess = (isReseller === true || String(isReseller).toLowerCase() === "true");115 116  var price = hasResellerAccess117    ? (item.reseller_price !== undefined && item.reseller_price !== null ? item.reseller_price : (item.normal_price || 0))118    : (item.normal_price || 0);119 120  // πŸ’Ž MULTIPLE PREMIUM EMOJIS INTEGRATION & BOLD LAYOUT (NEW EMOJIS MIXED)121  var text =122    "┏━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +123    "┃ <tg-emoji emoji-id='6267140231632262769'>❀️‍πŸ”₯</tg-emoji> <b>ALL DETAILS</b> <tg-emoji emoji-id='6267140231632262769'>❀️‍πŸ”₯</tg-emoji> ┃\n" +124    "┗━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +125    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +126    "<tg-emoji emoji-id='5244837092042750681'>✨</tg-emoji> <b>PRODUCT DETAILS:</b>\n\n" +127    "<tg-emoji emoji-id='6267129592998270736'>πŸ“£</tg-emoji> <b>Product Name :</b> <code>" + item.name + "</code>\n\n" +128    "<tg-emoji emoji-id='6062310436672377598'>πŸͺ</tg-emoji> <b>Current Stocks :</b> <code>" + stockList.length + " accounts</code>\n\n" +129    "<tg-emoji emoji-id='6266995104687330978'>πŸ“ˆ</tg-emoji> <b>Price:</b> <code>β‚Ή" + price + "</code>\n\n" +130    "<tg-emoji emoji-id='4967656361073574498'>πŸ‘‘</tg-emoji> <b>Account Type :</b> <b>" + (hasResellerAccess ? "Reseller" : "User") + "</b>\n" +131    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" +132    "<tg-emoji emoji-id='6057728771719435723'>⚑</tg-emoji> <i>Kripya confirmation ke liye niche diye gaye button par click karein.</i>";133 134  // Dynamic Button Configuration135  var purchaseButtonText = "Confirm Purchase";136  var purchaseButtonStyle = "success"; 137  var purchaseEmojiId = "6062310436672377598"; 138 139  if (stockList.length === 0) {140    purchaseButtonText = "❌ Out of Stock";141    purchaseButtonStyle = "danger"; 142    purchaseEmojiId = "5197288647275071607"; 143  }144 145  var buttons = {146    inline_keyboard: [147      [148        {149          text: purchaseButtonText,150          callback_data: stockList.length > 0 ? "/execute_id_buy " + rawParams : "/ff_id_menu",151          style: purchaseButtonStyle,152          icon_custom_emoji_id: purchaseEmojiId153        }154      ],155      [156        {157          text: "Back to Menu",158          callback_data: "/ff_id_menu",159          style: "danger",160          icon_custom_emoji_id: "5893163582194978381"161        }162      ]163    ]164  };165 166  var targetMessageId = (typeof request !== "undefined" && request && request.message) ? request.message.message_id : null;167 168  // Render logic handling169  if (targetMessageId) {170    try {171      Api.editMessageText({172        chat_id: targetChatId,173        message_id: targetMessageId,174        text: text,175        parse_mode: "HTML",176        reply_markup: JSON.stringify(buttons)177      });178    } catch (err) {179      Api.sendMessage({180        chat_id: targetChatId,181        text: text,182        parse_mode: "HTML",183        reply_markup: JSON.stringify(buttons)184      });185    }186  } else {187    Api.sendMessage({188      chat_id: targetChatId,189      text: text,190      parse_mode: "HTML",191      reply_markup: JSON.stringify(buttons)192    });193  }194 195} catch (e) {196  var errorChatId = (chat && chat.chatid) ? chat.chatid : ((user && user.telegramid) ? user.telegramid : "7839151435");197  try {198    Api.sendMessage({199      chat_id: errorChatId,200      text: "❌ <b>Checkout Error:</b>\n<code>" + e.message + "</code>",201      parse_mode: "HTML"202    });203  } catch(fatal){}204}