kkapil9112/Aestheticmodes9_botPublic · Bot Template
AIA Telegram-based digital goods store bot with a full admin panel for managing products, plans, stock, keys, categories, resellers, balances, and coupons. It uses TeleBotHost APIs like Bot, Api, User, Libs.ResourcesLib, and HTTP to run a shop interface, handle admin-only commands, track users, and send inventory/balance summaries. The implementation appears focused on selling game-related accounts and keys such as FreeFire items, with customer-facing store, balance, coupon, and back-to-menu flows.
Commerceshopadmin-panelbalanceresellercouponsstock-management
102 commands1 envUpdated 29d agoCreated Aug 9, 2026
commands/_onQR.js
javascript · 145 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 try {82 var genMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);83 if (genMsgId) {84 try {85 Api.deleteMessage({ chat_id: chat.chatid, message_id: genMsgId });86 } catch (delGenErr) {}87 Bot.setProperty("gen_msg_id_" + userId, null, "string");88 User.setProperty("gen_msg_id_" + userId, null, "string");89 }90 } catch (genErr) {}91 92 var sentQrMsg = Api.sendPhoto({93 chat_id: chat.chatid,94 photo: qr,95 caption: gatewayMsg,96 parse_mode: "HTML",97 reply_markup: JSON.stringify({ inline_keyboard: inlineButtons })98 });99 100 var qrMsgId = null;101 try {102 if (sentQrMsg) {103 if (sentQrMsg.result && sentQrMsg.result.message_id) {104 qrMsgId = sentQrMsg.result.message_id;105 } else if (sentQrMsg.message_id) {106 qrMsgId = sentQrMsg.message_id;107 }108 }109 110 if (qrMsgId) {111 Bot.setProperty("qr_msg_id_" + userId, qrMsgId, "string");112 User.setProperty("qr_msg_id_" + userId, qrMsgId, "string");113 }114 115 if (order_id) {116 Bot.setProperty("qr_order_id_" + userId, order_id, "string");117 User.setProperty("qr_order_id_" + userId, order_id, "string");118 User.setProperty("pending_order_id", order_id, "string");119 120 // ✅ Ye "watch id" hai — expiry callback isse compare karega ki order abhi bhi wahi hai ya resolve ho chuka121 Bot.setProperty("qr_watch_order_" + userId, order_id, "string");122 User.setProperty("qr_watch_order_" + userId, order_id, "string");123 }124 125 Bot.setProperty("qr_caption_" + userId, gatewayMsg, "string");126 User.setProperty("qr_caption_" + userId, gatewayMsg, "string");127 Bot.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");128 User.setProperty("qr_buttons_" + userId, JSON.stringify(inlineButtons), "string");129 130 var nowTs = String(new Date().getTime());131 Bot.setProperty("qr_created_ts_" + userId, nowTs, "string");132 User.setProperty("qr_created_ts_" + userId, nowTs, "string");133 134 Bot.setProperty("verifying_lock_" + userId, false, "boolean");135 User.setProperty("verifying_lock_" + userId, false, "boolean");136 } catch (saveErr) {}137 138 // ✅ CHANGED (per request): koi auto-expiry timer nahi hai ab. QR tab tak139 // valid rehta hai jab tak user khud "Cancel" na dabaye ya payment verify140 // na ho jaaye. Order kabhi background me apne aap "expire" nahi hoga —141 // sirf manual Cancel button se hi QR vanish hoga (see /cancel_topup).142 143} catch (err) {144 Bot.sendMessage("⚠️ System Error: " + err.message);145}