pnxh2371/Ankit_mods_store_botPublic · Bot Template

ProfileTelegram

AI𝐀ɴᴋɪᴛ 𝐌ᴏᴅꜱ 𝐒ᴛᴏʀᴇ 🛍 appears to be a Telegram automation bot. Commands include /*, /addbal, /addbal_all, /addbal_binance, /addbal_binance_approve, /addbal_binance_paid, /addbal_upi, /addcat_id. Observed in code: messaging, http, libs, keyboards, payments.

Utilityutility
133 commands0 envUpdated 8h agoCreated Sep 10, 2026
Back to folder

commands/_onQR.js

javascript · 153 lines

Raw
1/**#command2name: /onQR3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  if (!content) { 14    Bot.sendMessage("❌ Error: No response received from server.");15    return; 16  }17 18  var res = (typeof content === "object") ? content : JSON.parse(content);19 20  if (!res || res.status != "success" || !res.data) {21    Api.sendMessage({22      chat_id: chat.chatid,23      text: "<tg-emoji emoji-id='6219547832169273793'>❌</tg-emoji> <b>QR Generation Failed /</b>",24      parse_mode: "HTML"25    });26    return;27  }28 29  var order_id = res.data.order_id;30  var qr = res.data.qr_url;31  var expire = res.data.expires_at_ist ? res.data.expires_at_ist : "5 Minutes";32  33  var userId = user.telegramid;34  35  var deposit_amount = res.data.amount ||36                       Bot.getProperty("pending_pay_amount_" + userId) || 37                       User.getProperty("pending_pay_amount_" + userId) || 38                       Bot.getProperty("deposit_amount_" + userId) || 39                       User.getProperty("deposit_amount") || 40                       "0";41 42  if (!qr) {43    Bot.sendMessage("❌ Error: QR Code link missing from API response.");44    return;45  }46 47  var finalAmount = parseFloat(deposit_amount);48  if (isNaN(finalAmount) || finalAmount <= 0) {49    finalAmount = 0.00; 50  }51 52  var gatewayMsg = "<blockquote><tg-emoji emoji-id='6100170496077204999'>📋</tg-emoji> <b>Instructions</b></blockquote>\n" +53    "• Scan the QR using any UPI app.\n" +54    "• Pay the exact amount shown below.\n" +55    "• Wait a few seconds after payment.\n" +56    "• Tap <b>Verify Payment</b> below.\n\n" +57    "🧾 <b>Order ID:</b> <code>" + order_id + "</code>\n" +58    "<tg-emoji emoji-id='6312263493051489212'>💰</tg-emoji> <b>Amount:</b> ₹<code>" + finalAmount.toFixed(2) + "</code>\n" +59    "<tg-emoji emoji-id='6100657257605763582'>⏳</tg-emoji> <b>Expires:</b> <code>" + expire + "</code>\n\n" +60    "<tg-emoji emoji-id='6102856637343600044'>✅</tg-emoji> <i>Your balance will be credited automatically after successful verification.</i>";61 62  var inlineButtons = [63    [64      {65        text: "Verify Payment",66        callback_data: "/check " + order_id,67        style: "success",68        icon_custom_emoji_id: "6102856637343600044"69      }70    ],71    [72      {73        text: "Cancel",74        callback_data: "/cancel_topup " + order_id,75        style: "default",76        icon_custom_emoji_id: "6219547832169273793"77      }78    ]79  ];80 81  // ⚡ SPEED FIX: QR photo pehle bhejo taaki user ko turant dikhe, "Generating..."82  // wala purana message uske baad (background me) delete karo — pehle ye ulta83  // tha (pehle delete, fir photo), jisse QR dikhne me extra gap lagta tha.84  var genMsgId = null;85  try {86    genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);87  } catch (genErr) {}88 89  var sentQrMsg = Api.sendPhoto({90    chat_id: chat.chatid,91    photo: qr,92    caption: gatewayMsg,93    parse_mode: "HTML",94    reply_markup: JSON.stringify({ inline_keyboard: inlineButtons })95  });96 97  if (genMsgId) {98    try { Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId }); } catch (delGenErr) {}99    Bot.setProperty("gen_msg_id_" + userId, null, "string");100    User.setProperty("gen_msg_id_" + userId, null, "string");101  }102 103  var qrMsgId = null;104  try {105    if (sentQrMsg) {106      if (sentQrMsg.result && sentQrMsg.result.message_id) {107        qrMsgId = sentQrMsg.result.message_id;108      } else if (sentQrMsg.message_id) {109        qrMsgId = sentQrMsg.message_id;110      }111    }112 113    if (qrMsgId) {114      Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");115      User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");116    }117 118    if (order_id) {119      // Save the exact amount against this order so verification can reject120      // accidental/wrong payments instead of crediting an unrelated amount.121      Bot.setProperty("qr_order_amount_" + userId, String(finalAmount), "string");122      User.setProperty("qr_order_amount_" + userId, String(finalAmount), "string");123      Bot.setProperty("qr_order_id_" + userId, order_id, "string");124      User.setProperty("qr_order_id_" + userId, order_id, "string");125      User.setProperty("pending_order_id", order_id, "string");126      User.setProperty("pending_pay_order_id", order_id, "string");127 128      // ✅ Ye "watch id" hai — expiry callback isse compare karega ki order abhi bhi wahi hai ya resolve ho chuka129      Bot.setProperty("qr_watch_order_" + userId, order_id, "string");130      User.setProperty("qr_watch_order_" + userId, order_id, "string");131    }132 133    Bot.setProperty("qr_caption_" + userId, gatewayMsg, "string");134    User.setProperty("qr_caption_" + userId, gatewayMsg, "string");135    Bot.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");136    User.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");137 138    var nowTs = String(new Date().getTime());139    Bot.setProperty("qr_created_ts_" + userId, nowTs, "string");140    User.setProperty("qr_created_ts_" + userId, nowTs, "string");141 142    Bot.setProperty("verifying_lock_" + userId, false, "boolean");143    User.setProperty("verifying_lock_" + userId, false, "boolean");144  } catch (saveErr) {}145 146  // ✅ CHANGED (per request): koi auto-expiry timer nahi hai ab. QR tab tak147  // valid rehta hai jab tak user khud "Cancel" na dabaye ya payment verify148  // na ho jaaye. Order kabhi background me apne aap "expire" nahi hoga —149  // sirf manual Cancel button se hi QR vanish hoga (see /cancel_topup).150 151} catch (err) {152  Bot.sendMessage("⚠️ System Error: " + err.message);153}