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

javascript Β· 151 lines

Raw
1/**#command2name: /addbal_binance3answer: 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// 🟑 "Binance Pay" chosen on Add Balance screen β€” shows the admin-set55// Binance QR (photo file_id OR image URL, whichever admin configured) with56// the amount converted to USD, plus Binance Pay ID + USDT Address.57// Koi live-verify API nahi hai, isliye "I Paid" ek manual Support flow58// shuru karta hai (UTR + screenshot -> admin ko forward).59// =========================================================60 61try {62  let userId = user.telegramid;63  let callbackId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;64 65  let inrAmount = String(parseInt(params ? String(params).trim() : "0"));66  if (!inrAmount || inrAmount === "0" || isNaN(parseInt(inrAmount)) || parseInt(inrAmount) <= 0) {67    Bot.sendMessage("❌ Invalid amount!");68    return;69  }70 71  let qrFileId = Bot.getProperty("binance_qr_file_id");72  let qrUrl = Bot.getProperty("binance_qr_url");73  let qrSource = qrFileId || qrUrl;74 75  let binanceId = Bot.getProperty("binance_pay_id");76  let usdtAddress = Bot.getProperty("binance_usdt_address");77  let usdRate = Number(Bot.getProperty("usd_rate") || 91);78  let usdAmount = (parseInt(inrAmount) / usdRate).toFixed(2);79 80  if (!qrSource || !binanceId || !usdtAddress) {81    if (callbackId) {82      Api.answerCallbackQuery({83        callback_query_id: String(callbackId),84        text: "⚠️ Binance Pay abhi configure nahi hua hai. Kripya Support se contact karein.",85        show_alert: true86      });87    }88    return;89  }90 91  User.setProperty("binance_pending_amount_inr", inrAmount, "string");92  User.setProperty("binance_pending_amount_usd", usdAmount, "string");93 94  let e_binance = "<tg-emoji emoji-id='6312263493051489212'>🟑</tg-emoji>";95  let e_check = "<tg-emoji emoji-id='6100657257605763582'>βœ”οΈ</tg-emoji>";96 97  let caption =98    "<blockquote>" + e_binance + " <b>BINANCE PAY</b></blockquote>\n" +99    "━━━━━━━━━━━━━━━━━━━━━\n\n" +100    "<tg-emoji emoji-id='6312263493051489212'>πŸ’°</tg-emoji> <b>Amount:</b> $<code>" + usdAmount + "</code> <i>(β‚Ή" + inrAmount + ")</i>\n\n" +101    "<b>Binance Pay ID</b>\n<code>" + binanceId + "</code>\n\n" +102    "<b>USDT Address</b>\n<code>" + usdtAddress + "</code>\n\n" +103    "━━━━━━━━━━━━━━━━━━━━━\n" +104    "<tg-emoji emoji-id='6100170496077204999'>πŸ“‹</tg-emoji> <b>Instructions</b>\n" +105    "β€’ Scan the QR in your Binance app, or pay to the ID/Address above.\n" +106    "β€’ Pay the exact amount shown.\n" +107    "β€’ Tap <b>I Paid</b> below and follow the steps to submit proof.\n\n" +108    e_check + " <i>Support team will verify and credit your balance.</i>";109 110  let inlineButtons = [111    [{ text: "I Paid", callback_data: "/addbal_binance_paid", style: "success", icon_custom_emoji_id: "6100657257605763582" }],112    [{ text: "Cancel", callback_data: "/cancel_topup", style: "danger", icon_custom_emoji_id: "6219547832169273793" }]113  ];114 115  // Agar purani QR/generating message chat me hai, use hata do116  try {117    let genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);118    if (genMsgId) {119      try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (e) {}120      Bot.setProperty("gen_msg_id_" + userId, null, "string");121      User.setProperty("gen_msg_id_" + userId, null, "string");122    }123  } catch (e) {}124 125  if (request && request.message && !request.message.photo) {126    try { Api.deleteMessage({ chat_id: chat.chatid, message_id: request.message.message_id }); } catch (e) {}127  }128 129  let sentMsg = Api.sendPhoto({130    chat_id: chat.chatid,131    photo: qrSource,132    caption: caption,133    parse_mode: "HTML",134    reply_markup: JSON.stringify({ inline_keyboard: inlineButtons })135  });136 137  try {138    let qrMsgId = (sentMsg && sentMsg.result && sentMsg.result.message_id) ? sentMsg.result.message_id : (sentMsg && sentMsg.message_id ? sentMsg.message_id : null);139    if (qrMsgId) {140      Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");141      User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");142    }143  } catch (e) {}144 145  if (callbackId) {146    Api.answerCallbackQuery({ callback_query_id: String(callbackId) });147  }148 149} catch (err) {150  Bot.sendMessage("⚠️ System Error: " + err.message);151}