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/_viewprod.js
javascript · 138 lines
1/**#command2name: /viewprod3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 📦 Shows a product's plans (Step 2 of the buy flow)14// ✅ CRITICAL BUG FIX: pehle "<tg-emoji emoji-id='X'></tg-emoji>" ek EMPTY15// tag tha (koi fallback character nahi) — Telegram ka HTML parser aise16// malformed tg-emoji tag par POORA MESSAGE hi reject kar deta hai. Isi17// wajah se product par click karne par plan-list screen kabhi aati hi nahi18// thi — poora buy flow yahi pe tootta tha!19// ✅ Photo-message-edit bug bhi fix, aur missing else-branch (fresh send)20// bhi add kiya.21// =========================================================22 23try {24 var productList = Bot.getProperty("stored_products") || [];25 var callbackId = request ? request.id : null;26 var chatId = chat.chatid;27 var messageId = request && request.message ? request.message.message_id : (request ? request.message_id : null);28 var isPhotoMsg = !!(request && request.message && request.message.photo);29 30 var userId = user.telegramid;31 var isReseller = Bot.getProperty("is_reseller_" + userId) === true;32 33 var productIndex = params ? params.trim() : "";34 if (productIndex === "") {35 var cbData = request && request.callback_query ? request.callback_query.data : "";36 productIndex = cbData.replace("/viewprod ", "").replace("viewprod ", "");37 }38 39 var selectedProduct = productList[Number(productIndex)];40 41 if (!selectedProduct) {42 if (callbackId) {43 try { Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "⚠️ Product not found!", show_alert: true }); } catch (e) {}44 }45 return;46 }47 48 var planButtons = [];49 var plans = selectedProduct.plans || [];50 51 if (plans.length === 0) {52 plans = [53 { days: "1", normal_price: "79", reseller_price: "65" },54 { days: "7", normal_price: "350", reseller_price: "300" }55 ];56 }57 58 for (var j = 0; j < plans.length; j++) {59 var plan = plans[j];60 var planUnit = plan.unit || "day";61 62 var cleanProdName = selectedProduct.name.trim().toUpperCase();63 var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();64 65 var priceKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);66 var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;67 var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;68 69 var adminNormalPrice = Bot.getProperty(normalKey);70 var adminResellerPrice = Bot.getProperty(resellerKey);71 72 var currentNormal = (adminNormalPrice !== undefined && adminNormalPrice !== null) ? adminNormalPrice : plan.normal_price;73 var currentReseller = (adminResellerPrice !== undefined && adminResellerPrice !== null) ? adminResellerPrice : plan.reseller_price;74 75 var displayPrice = isReseller ? currentReseller : currentNormal;76 var unitLabelWord = (planUnit === "hour") ? (Number(cleanPlanDays) === 1 ? "Hour" : "Hours") :77 (planUnit === "minute") ? (Number(cleanPlanDays) === 1 ? "Minute" : "Minutes") :78 (Number(cleanPlanDays) === 1 ? "Day" : "Days");79 var dayLabel = plan.durationDisplay || (cleanPlanDays + " " + unitLabelWord);80 81 // 🎉 Discount badge preview (auto-discount only, coupon shown later on confirm screen)82 var discPreviewKey1 = "auto_discount_" + cleanProdName + "_" + cleanPlanDays + "_" + planUnit.toUpperCase();83 var discPreviewKey2 = "auto_discount_" + cleanProdName + "_ALL";84 var discPreview = Bot.getProperty(discPreviewKey1) || Bot.getProperty(discPreviewKey2) || Bot.getProperty("auto_discount_global") || 0;85 var badgeText = discPreview > 0 ? " 🎉-" + discPreview + "%" : "";86 87 planButtons.push([88 {89 text: dayLabel + " — ₹" + displayPrice + badgeText,90 callback_data: "/buyitem " + productIndex + " " + j,91 style: "primary",92 icon_custom_emoji_id: "6100657257605763582"93 }94 ]);95 }96 97 planButtons.push([98 {99 text: "Back to Shop",100 callback_data: "/buy_hack",101 style: "danger",102 icon_custom_emoji_id: "5893163582194978381"103 }104 ]);105 106 // ✅ FIX: empty tg-emoji tag hata diya — ab sirf plain product emoji text hai107 var planText =108 "<blockquote><tg-emoji emoji-id='6102856637343600044'>👑</tg-emoji> <b>PRODUCT: " + selectedProduct.name.toUpperCase() + "</b></blockquote>\n\n" +109 "<tg-emoji emoji-id='6093677128295914531'>✏️</tg-emoji> <b>CHOOSE YOUR PLAN</b> <tg-emoji emoji-id='6093677128295914531'>✏️</tg-emoji>\n\n" +110 "<blockquote><tg-emoji emoji-id='6093854128193152827'>🎉</tg-emoji> Select your validity plan below to proceed with the secure order <tg-emoji emoji-id='6091571559233755994'>👉</tg-emoji></blockquote>";111 112 var replyMarkupStr = JSON.stringify({ inline_keyboard: planButtons });113 114 if (messageId) {115 if (isPhotoMsg) {116 try { Api.deleteMessage({ chat_id: chatId, message_id: messageId }); } catch (e) {}117 Api.sendMessage({ chat_id: chatId, text: planText, parse_mode: "HTML", reply_markup: replyMarkupStr });118 } else {119 Api.editMessageText({120 chat_id: chatId,121 message_id: Number(messageId),122 text: planText,123 parse_mode: "HTML",124 reply_markup: replyMarkupStr125 });126 }127 } else {128 // ✅ FIX: pehle is case me kuch bhejta hi nahi tha129 Api.sendMessage({ chat_id: chatId, text: planText, parse_mode: "HTML", reply_markup: replyMarkupStr });130 }131 132 if (callbackId) {133 try { Api.answerCallbackQuery({ callback_query_id: String(callbackId) }); } catch (e) {}134 }135 136} catch (err) {137 Bot.sendMessage("⚠️ View Product Error: " + err.message, { parse_mode: "HTML" });138}