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

javascript Β· 202 lines

Raw
1/**#command2name: /press3answer: 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// Command Name: /press (Premium Calculator Keypad Handler)54// βœ… FIXED: "Back" button pehle "/dmenu" call kar raha tha jo bot me exist hi nahi karta55// (dead button β€” click karne par kuch nahi hota tha). Ab "/back" (real menu command) use hota hai.56// βœ… Number buttons ab addfund screen jaisi hi blue "primary" styling ke saath hain (pehle plain/colorless the).57 58try {59  // Purana set default check: Agar user ne naya deposit shuru kiya hai toh default 0 rahe60  let current_amount = User.getProperty("deposit_amount");61  if (!current_amount) {62    current_amount = "0";63  }64 65  let pressed = params ? params.trim() : "";66  let queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;67 68  // πŸ’Ž Premium Emoji Set (same IDs as /addfund β€” keeps the screen visually identical, no flicker)69  let e_money   = "<tg-emoji emoji-id='6312263493051489212'>πŸ’°</tg-emoji>";70  let e_clear   = "<tg-emoji emoji-id='5348224471050238603'>✏</tg-emoji>";71  let e_confirm = "<tg-emoji emoji-id='5348191451341668809'>βœ…</tg-emoji>";72  let e_back    = "<tg-emoji emoji-id='5893163582194978381'>⬅️</tg-emoji>";73  let e_hour    = "<tg-emoji emoji-id='6100657257605763582'>βœ”οΈ</tg-emoji>";74  let e_check   = "<tg-emoji emoji-id='6311870645277825763'>βœ”οΈ</tg-emoji>";75  let e_gear    = "<tg-emoji emoji-id='5348292765325212780'>βš™</tg-emoji>";76 77  // --- CONFIRM BUTTON CLICK ---78  if (pressed == "confirm") {79    if (parseInt(current_amount) <= 0 || current_amount == "" || current_amount == "0") {80      if (queryId) {81        Api.answerCallbackQuery({82          callback_query_id: queryId,83          text: "πŸ‘€ PLEASE ENTER A VALID AMOUNT!",84          show_alert: true85        });86      }87      return;88    }89 90    // βœ… NEW: ab seedhe QR generate nahi hota β€” pehle "Choose Payment Method"91    // screen dikhti hai (UPI Pay / Binance Pay), jaise buyitem checkout me hoti hai.92    let finalAmount = String(parseInt(current_amount));93    let usdRate = Number(Bot.getProperty("usd_rate") || 91);94    let usdAmount = (parseInt(current_amount) / usdRate).toFixed(2);95 96    let e_upi = "<tg-emoji emoji-id='5348392971207194994'>πŸ’³</tg-emoji>";97    let e_binance = "<tg-emoji emoji-id='6312263493051489212'>🟑</tg-emoji>";98 99    let methodText =100      "<blockquote>" + e_money + " <b>CHOOSE PAYMENT METHOD</b></blockquote>\n" +101      "━━━━━━━━━━━━━━━━━━━━━\n\n" +102      e_money + " <b>Amount:</b> β‚Ή<code>" + finalAmount + "</code> <i>(β‰ˆ $" + usdAmount + ")</i>\n\n" +103      "━━━━━━━━━━━━━━━━━━━━━\n" +104      "<i>Select a payment gateway below:</i>";105 106    let methodButtons = [107      [{ text: "UPI Pay β‚Ή" + finalAmount, callback_data: "/addbal_upi " + finalAmount, style: "success", icon_custom_emoji_id: "5348392971207194994" }],108      [{ text: "Binance Pay $" + usdAmount, callback_data: "/addbal_binance " + finalAmount, style: "primary", icon_custom_emoji_id: "6312263493051489212" }],109      [{ text: "Back", callback_data: "/back", style: "danger", icon_custom_emoji_id: "5893163582194978381" }]110    ];111 112    Api.editMessageText({113      chat_id: chat.chatid,114      message_id: request.message.message_id,115      text: methodText,116      parse_mode: "HTML",117      reply_markup: JSON.stringify({ inline_keyboard: methodButtons })118    });119 120    // Amount reset to 0 so next time it starts fresh121    User.setProperty("deposit_amount", "0", "string");122 123    if (queryId) {124      Api.answerCallbackQuery({ callback_query_id: queryId });125    }126 127    return;128  }129 130  // --- KEYPAD INPUT LOGIC ---131  if (pressed == "clear") {132    if (current_amount.length > 1) {133      current_amount = current_amount.slice(0, -1);134    } else {135      current_amount = "0";136    }137  } else if (pressed !== "") {138    if (current_amount == "0") {139      current_amount = pressed;140    } else {141      if ((current_amount + pressed).length <= 6) {142        current_amount = current_amount + pressed;143      }144    }145  }146 147  // Save current keypad amount state148  User.setProperty("deposit_amount", current_amount, "string");149 150  if (queryId) {151    Api.answerCallbackQuery({ callback_query_id: queryId });152  }153 154  // 🎨 Keypad Buttons β€” same premium colored styling as /addfund155  let inlineKeyboardPayload = [156    [157      { text: "1", callback_data: "/press 1", style: "primary" },158      { text: "2", callback_data: "/press 2", style: "primary" },159      { text: "3", callback_data: "/press 3", style: "primary" }160    ],161    [162      { text: "4", callback_data: "/press 4", style: "primary" },163      { text: "5", callback_data: "/press 5", style: "primary" },164      { text: "6", callback_data: "/press 6", style: "primary" }165    ],166    [167      { text: "7", callback_data: "/press 7", style: "primary" },168      { text: "8", callback_data: "/press 8", style: "primary" },169      { text: "9", callback_data: "/press 9", style: "primary" }170    ],171    [172      { text: "Clear", callback_data: "/press clear", style: "danger", icon_custom_emoji_id: "5348224471050238603" },173      { text: "0", callback_data: "/press 0", style: "primary" },174      { text: "Confirm", callback_data: "/press confirm", style: "success", icon_custom_emoji_id: "5348191451341668809" }175    ],176    [177      // βœ… FIXED: "/dmenu" -> "/back" (dead command replaced with the real menu handler)178      { text: "Back", callback_data: "/back", style: "danger", icon_custom_emoji_id: "5893163582194978381" }179    ]180  ];181 182  let keypadMsg =183    "<blockquote>" + e_money + " <b>ADD BALANCE β€” ENTER AMOUNT</b> <tg-emoji emoji-id='6312263493051489212'>πŸ’Ž</tg-emoji></blockquote>\n" +184    "━━━━━━━━━━━━━━━━━━━━━\n\n" +185    "<tg-emoji emoji-id='6312263493051489212'>πŸ’Ž</tg-emoji> <b>Amount:</b> β‚Ή<code>" + current_amount + "</code>\n\n" +186    "━━━━━━━━━━━━━━━━━━━━━\n" +187    e_check + " <i>Instant Auto-Credit</i>\n" +188    "<tg-emoji emoji-id='6215386799133433653'>πŸ”’</tg-emoji> <i>100% Secure UPI Payment</i>\n" +189    e_hour + " <i>Verified in Seconds</i>\n\n" +190    "<tg-emoji emoji-id='6100170496077204999'>πŸ‘‘</tg-emoji> <i>Use the keypad below to enter amount</i>";191 192  Api.editMessageText({193    chat_id: chat.chatid,194    message_id: request.message.message_id,195    text: keypadMsg,196    parse_mode: "HTML",197    reply_markup: JSON.stringify({ inline_keyboard: inlineKeyboardPayload })198  });199 200} catch (err) {201  Bot.sendMessage("⚠️ System Error in Keypad: " + err.message);202}