ashoksarande3/ASHOK_HACK_STORE_BOTPublic ยท Bot Template

AIThis bot operates as a commercial storefront for selling Free Fire game hacks and cheats via UPI QR code payments. It features a dynamic pricing system with separate normal and reseller prices, product plans with flexible durations (days, hours, minutes), and a reseller program requiring a one-time upgrade fee. The bot handles payment verification through QR code generation and expiry tracking, user verification via Telegram contact sharing, and admin tools for stock management, plan creation, and ownership transfer. It includes a balance system, maintenance mode, and Telegram Stars payment fallback. The codebase uses TeleBotHost's TBL JavaScript APIs (Bot, Api, HTTP, db properties, Libs) for all logic.

Commercefreefiregame-hacksupi-paymentsqr-codesreseller-systemdynamic-pricing
ProfileTelegram
102 commands0 envUpdated 16d agoCreated Aug 22, 2026
Back to folder

commands/_viewprod.js

javascript ยท 138 lines

Raw
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}