yaainnnxitstore/YASIN_XIT_BOTPublic · Bot Template

ProfileTelegram

AIYASIN XIT FREE KEY appears to be a Telegram automation bot. Commands include /menu, /addfund, /confirm_buyitem, /rembal, /sendorderkey_input, /removeproduct, /add_reseller, /addkey. Observed in code: messaging, keyboards, payments, games, libs, web.

Utilityutility
140 commands0 envUpdated 1mo agoCreated Sep 11, 2026
Back to folder

commands/_viewprod.js

javascript · 225 lines

Raw
1/**#command2name: /viewprod3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12var __swfUpdate = (typeof update !== "undefined" && update) ? update : null;13var __swfCb = (__swfUpdate && __swfUpdate.callback_query) ? __swfUpdate.callback_query : null;14var __swfCbMsg = (__swfCb && __swfCb.message) ? __swfCb.message : null;15var __swfMsgId = __swfCbMsg && __swfCbMsg.message_id ? Number(__swfCbMsg.message_id) : 0;16var __swfCbId = __swfCb && __swfCb.id ? String(__swfCb.id) : "";17try {18  if (typeof request !== "undefined" && request && __swfCb) {19    if (__swfCb.message) request.message = __swfCb.message;20    if (!request.id && __swfCb.id) request.id = __swfCb.id;21  }22} catch(__swf_norm_err) {}23function __swfEditMessage(a) {24  a = a || {};25  var mid = Number(a.message_id || __swfMsgId || 0);26  var cid = a.chat_id || (typeof chat !== "undefined" && chat ? (chat.id || chat.chatid) : null);27  if (!mid || !cid) throw new Error("Callback message ID not found");28  var markup = a.reply_markup;29  if (typeof markup === "string") { try { markup = JSON.parse(markup); } catch(_) {} }30  var base = {chat_id:cid,message_id:mid,parse_mode:a.parse_mode,reply_markup:markup};31  var cm = __swfCbMsg;32  if (cm && (cm.photo || cm.video || cm.document || cm.audio || cm.animation)) {33    return Api.editMessageCaption({chat_id:cid,message_id:mid,caption:String(a.text == null ? "" : a.text),parse_mode:a.parse_mode,reply_markup:markup});34  }35  return Api.editMessageText({chat_id:cid,message_id:mid,text:String(a.text == null ? "" : a.text),parse_mode:a.parse_mode,reply_markup:markup});36}37function __uiSend(text, opts) {38  opts = opts || {};39  var req = (typeof request !== "undefined" && request) ? request : null;40  var chatId = (typeof chat !== "undefined" && chat && chat.chatid) ? chat.chatid : null;41  var isCallback = !!__swfCb;42  var mid = 0;43  if (isCallback && update.callback_query.message && update.callback_query.message.message_id) mid = Number(update.callback_query.message.message_id);44  if (!mid) { try { mid = Number(User.getProperty("pending_menu_message_id") || User.getProperty("main_menu_message_id") || User.getProperty("support_message_id") || 0); } catch(e0) { mid = 0; } }45  var markup = opts.reply_markup;46  if (markup && typeof markup !== "string") { try { markup = JSON.stringify(markup); } catch(e1) {} }47  var textValue = String(text == null ? "" : text);48  if (mid && chatId) {49    try {50      __swfEditMessage({chat_id:chatId,message_id:mid,text:textValue,parse_mode:opts.parse_mode,reply_markup:markup});51      try { User.setProperty("main_menu_message_id",String(mid),"string"); User.setProperty("pending_menu_message_id",String(mid),"string"); } catch(se) {}52      return true;53    } catch(e2) {54      var s=String(e2).toLowerCase();55      if(s.indexOf("message is not modified")>=0 || s.indexOf("not modified")>=0) return true;56      if(isCallback && update.callback_query.message && update.callback_query.message.photo) {57        try { Api.editMessageCaption({chat_id:chatId,message_id:mid,caption:textValue,parse_mode:opts.parse_mode,reply_markup:markup}); return true; } catch(e3) {58          var s3=String(e3).toLowerCase(); if(s3.indexOf("not modified")>=0) return true;59        }60      }61      if(isCallback) { try { Api.answerCallbackQuery({callback_query_id:String(update.callback_query.id),text:"⚠️ Could not update the screen.",show_alert:true}); } catch(e4) {} return false; }62    }63  }64  if (isCallback) { try { Api.answerCallbackQuery({callback_query_id:String(update.callback_query.id),text:"⚠️ Screen message not found.",show_alert:true}); } catch(e5) {} return false; }65  try {66    var sent=Api.sendMessage({chat_id:chatId,text:textValue,parse_mode:opts.parse_mode,reply_markup:markup});67    try { if(sent&&sent.message_id){User.setProperty("pending_menu_message_id",String(sent.message_id),"string");User.setProperty("main_menu_message_id",String(sent.message_id),"string");} } catch(e6) {}68    return true;69  } catch(e7) { return false; }70}71try {72  if (typeof request !== "undefined" && request && __swfCb && __swfCb.message) {73    request.message = __swfCb.message;74  }75  var products = Bot.getProperty("stored_products") || [];76  if (!Array.isArray(products)) products = [];77  var productIndex = Number(String(params || "").trim());78  if (!isFinite(productIndex) && request && __swfCb) {79    var data = String(__swfCb.data || "");80    productIndex = Number(data.replace("/viewprod","").trim());81  }82  var product = products[productIndex];83  if (!product || !String(product.name || "").trim()) {84    if (request && request.id) {85      try { Api.answerCallbackQuery({callback_query_id:String(request.id),text:"⚠️ Product not found.",show_alert:true}); } catch(e) {}86    }87    return;88  }89  var maintenanceMap = Bot.getProperty("product_maintenance") || {};90  var productMaintenance = !!(maintenanceMap[String(productIndex)] || maintenanceMap[String(product.name)]);91  function esc(v) {92    return String(v || "").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");93  }94  if(productMaintenance){95    var maintenanceText="🔧 <b>PRODUCT BEING UPDATED</b>\n\n"+esc(String(product.name).trim())+" is currently under maintenance.\nPlease wait until the update is finished.";96    var maintenanceMarkup=JSON.stringify({inline_keyboard:[[{text:"🔙 Back to Products",callback_data:"/vipshop"}]]});97    var pmMid=request && ((__swfCb&&__swfCb.message&&__swfCb.message.message_id)||(request.message&&request.message.message_id)) ? request.message.message_id : null;98    try{99      if(pmMid){100        if(request.message.photo) Api.editMessageCaption({chat_id:chat.chatid,message_id:Number(pmMid),caption:maintenanceText,parse_mode:"HTML",reply_markup:maintenanceMarkup});101        else __swfEditMessage({chat_id:chat.chatid,message_id:Number(pmMid),text:maintenanceText,parse_mode:"HTML",reply_markup:maintenanceMarkup});102      }103      if(request&&request.id) Api.answerCallbackQuery({callback_query_id:String(request.id),text:"🔧 Product is being updated."});104    }catch(_pmErr){try{if(request&&request.id)Api.answerCallbackQuery({callback_query_id:String(request.id),text:"⚠️ Could not update the screen.",show_alert:true});}catch(_){}}105    return;106  }107  function durationLabel(pl) {108    var n = String(pl.days || "").replace(/[^0-9.]/g,"");109    var unit = String(pl.unit || "day");110    if (pl.durationDisplay) return String(pl.durationDisplay);111    if (unit === "hour") return n + " Hours";112    if (unit === "minute") return n + " Minutes";113    if (unit === "month") return n + " Ay";114    return n === "30" ? "1 Month" : n + " Days";115  }116  var plans = Array.isArray(product.plans) ? product.plans : [];117  var visible = [];118  for (var i = 0; i < plans.length; i++) {119    var pl = plans[i] || {};120    var qty = Math.max(0, Number(pl.stock_count || 0));121    var isResellerView = Bot.getProperty("is_reseller_" + String(user.telegramid)) === true;122    var __vRsPct = Number(Bot.getProperty("reseller_discount_pct")); if(!isFinite(__vRsPct)||__vRsPct<0||__vRsPct>90) __vRsPct=20;123    var __vNormal = Number(pl.normal_price != null ? pl.normal_price : (pl.price || 0));124    var __vRes = (pl.reseller_price != null && Number(pl.reseller_price) > 0 && Number(pl.reseller_price) < __vNormal) ? Number(pl.reseller_price) : Number((__vNormal*(1-__vRsPct/100)).toFixed(2));125    var price = Number(isResellerView ? __vRes : __vNormal);126    var discount = Number(Bot.getProperty("auto_discount_global") || 0);127    var pUpper = String(product.name || "").toUpperCase();128    var uKey = String(pl.unit || "day").toUpperCase() === "HOUR" ? "HOUR" : String(pl.unit || "day").toUpperCase() === "MINUTE" ? "MINUTE" : "DAY";129    var sdKey = Bot.getProperty("auto_discount_" + pUpper + "_" + String(pl.days) + "_" + uKey);130    var allKey = Bot.getProperty("auto_discount_" + pUpper + "_ALL");131    if(sdKey !== null && sdKey !== undefined && isFinite(Number(sdKey))) discount = Number(sdKey);132    else if(allKey !== null && allKey !== undefined && isFinite(Number(allKey))) discount = Number(allKey);133    discount = Math.max(0, Math.min(100, discount));134    price = Number((price * (1 - discount / 100)).toFixed(2));135    if (!isFinite(price) || price < 0) continue;136    var label = durationLabel(pl);137    var status = qty > 0 ? "✅ In Stock" : "❌ Out of Stock";138    var icon = qty > 0 ? "✅" : "❌";139    var vRate = 1; // 1 USDT = $1.00 (fixed)140    var usdtPrice = vRate > 0 ? price / vRate : 0;141    var normalShown = Number((__vNormal * (1 - discount / 100)).toFixed(2));142    var resellerShown = Number((__vRes * (1 - discount / 100)).toFixed(2));143    if (resellerShown > normalShown) resellerShown = normalShown;144    visible.push({145      index:i,146      label:label,147      price:price,148      normal:normalShown,149      reseller:resellerShown,150      usdt:usdtPrice,151      qty:qty,152      discount:discount,153      icon:icon,154      status:status155    });156  }157  var lines = [];158  var buttons = [];159  if (productMaintenance) {160    lines.push("🔧 <b>PRODUCT UNDER MAINTENANCE</b>\nIt is being updated right now. Please try again later.");161  }162  for (var j = 0; j < visible.length; j++) {163    var v = visible[j];164    var saving = Number((v.normal - v.reseller).toFixed(2));165    lines.push(166      v.icon + " <b>" + esc(v.label) + "</b>\n" +167      "├ 📦 <b>Stock:</b> " + esc(v.status) + "\n" +168      (v.discount > 0 ? "├ 🏷️ <b>Discount:</b> -" + v.discount.toFixed(0) + "%\n" : "") +169      "├ 💰 <b>Price:</b> $" + v.normal.toFixed(2) + "\n" +170      "└ 👑 <b>Reseller:</b> $" + v.reseller.toFixed(2) + (saving > 0 ? " (-$" + saving.toFixed(2) + ")" : "")171    );172    if (v.qty > 0) {173      buttons.push([{174        text:(productMaintenance ? "🔧 " : "🛒 ") + v.label + " - $" + v.price.toFixed(2),175        callback_data:productMaintenance ? "/viewprod " + productIndex : "/buyitem " + productIndex + " " + v.index176      }]);177    }178  }179  var shopName = String(Bot.getProperty("shop_name") || "YASİN XİT STORE");180  var supportRow = "📞 <b>Support:</b> Contact Us";181  var text =182    "🏪 <b>" + esc(shopName) + "</b>\n" +183    "🎮 🛒 " + esc(String(product.name).trim()) + "\n" +184    "━━━━━━━━━━━━━━━━━━━━━━\n\n" +185    "📦 <b>STOCK &amp; PRICING:</b>\n\n" +186    (lines.length ? lines.join("\n\n") : "❌ <b>There are no plans available right now.</b>") +187    "\n\n━━━━━━━━━━━━━━━━━━━━━━\n" +188    supportRow + "\n" +189    "🎯 <b>Select your plan below:</b>";190  buttons.push([{text:"📞 Support",callback_data:"/support"},{text:"🔙 Back",callback_data:"/vipshop"}]);191  var markup = JSON.stringify({inline_keyboard:buttons});192  var mid = request && ((__swfCb && __swfCb.message && __swfCb.message.message_id) || (request.message && request.message.message_id)) ? request.message.message_id : null;193  if (mid) {194    try {195      if (request.message.photo) {196        Api.editMessageCaption({197          chat_id: chatId,198          message_id: Number(mid),199          caption: text,200          parse_mode: "HTML",201          reply_markup: markup202        });203      } else {204      __swfEditMessage({205        chat_id:chat.chatid,206        message_id:Number(mid),207        text:text,208        parse_mode:"HTML",209        reply_markup:markup210      });211      }212    } catch(e1) {213      try { Api.answerCallbackQuery({callback_query_id:String(__swfCbId || request.id), text:"⚠️ Could not refresh the product screen.", show_alert:true}); } catch(ea) {}214      return;215    }216  } else {217    try { Api.answerCallbackQuery({callback_query_id:String(__swfCbId || request.id), text:"⚠️ Could not open the product screen.", show_alert:true}); } catch(e2) {}218    return;219  }220  if (request && request.id) {221    try { Api.answerCallbackQuery({callback_query_id:String(request.id)}); } catch(e2) {}222  }223} catch (e) {224  try { __uiSend("⚠️ Could not load the product details. Please try again."); } catch(e3) {}225}