indrajitghosh20006/Testseller_01botPublic · Bot Template
AIThis bot provides an admin‑controlled system for managing user balances, products, and reseller roles. It includes commands to add balances (via manual input, Binance Pay, or UPI), approve and credit payments, and set up product listings with categories and pricing. Admins can also add resellers, view reseller info, and manage stock entries. The bot uses built‑in TeleBotHost APIs such as Bot, Api, HTTP, and Libs for database operations and message handling.
Commerceadminbalanceproductresellerpaymentsbinance
138 commands0 envUpdated 17h agoCreated Sep 27, 2026
commands/_onQR.js
javascript · 148 lines
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: "danger",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 Bot.setProperty("qr_order_id_" + userId, order_id, "string");120 User.setProperty("qr_order_id_" + userId, order_id, "string");121 User.setProperty("pending_order_id", order_id, "string");122 123 // ✅ Ye "watch id" hai — expiry callback isse compare karega ki order abhi bhi wahi hai ya resolve ho chuka124 Bot.setProperty("qr_watch_order_" + userId, order_id, "string");125 User.setProperty("qr_watch_order_" + userId, order_id, "string");126 }127 128 Bot.setProperty("qr_caption_" + userId, gatewayMsg, "string");129 User.setProperty("qr_caption_" + userId, gatewayMsg, "string");130 Bot.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");131 User.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");132 133 var nowTs = String(new Date().getTime());134 Bot.setProperty("qr_created_ts_" + userId, nowTs, "string");135 User.setProperty("qr_created_ts_" + userId, nowTs, "string");136 137 Bot.setProperty("verifying_lock_" + userId, false, "boolean");138 User.setProperty("verifying_lock_" + userId, false, "boolean");139 } catch (saveErr) {}140 141 // ✅ CHANGED (per request): koi auto-expiry timer nahi hai ab. QR tab tak142 // valid rehta hai jab tak user khud "Cancel" na dabaye ya payment verify143 // na ho jaaye. Order kabhi background me apne aap "expire" nahi hoga —144 // sirf manual Cancel button se hi QR vanish hoga (see /cancel_topup).145 146} catch (err) {147 Bot.sendMessage("⚠️ System Error: " + err.message);148}