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/_buyitem.js

javascript · 112 lines

Raw
1/**#command2name: /buyitem3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12function __esc(v){return String(v==null?"":v).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");}13var __swfUpdate = (typeof update !== "undefined" && update) ? update : null;14var __swfCb = (__swfUpdate && __swfUpdate.callback_query) ? __swfUpdate.callback_query : null;15var __swfCbMsg = (__swfCb && __swfCb.message) ? __swfCb.message : null;16var __swfMsgId = __swfCbMsg && __swfCbMsg.message_id ? Number(__swfCbMsg.message_id) : 0;17var __swfCbId = __swfCb && __swfCb.id ? String(__swfCb.id) : "";18try {19  if (typeof request !== "undefined" && request && __swfCb) {20    if (__swfCb.message) request.message = __swfCb.message;21    if (!request.id && __swfCb.id) request.id = __swfCb.id;22  }23} catch(__swf_norm_err) {}24function __swfEditMessage(a) {25  a = a || {};26  var mid = Number(a.message_id || __swfMsgId || 0);27  var cid = a.chat_id || (typeof chat !== "undefined" && chat ? (chat.id || chat.chatid) : null);28  if (!mid || !cid) throw new Error("Callback message ID not found");29  var markup = a.reply_markup;30  if (typeof markup === "string") { try { markup = JSON.parse(markup); } catch(_) {} }31  var base = {chat_id:cid,message_id:mid,parse_mode:a.parse_mode,reply_markup:markup};32  var cm = __swfCbMsg;33  if (cm && (cm.photo || cm.video || cm.document || cm.audio || cm.animation)) {34    return Api.editMessageCaption({chat_id:cid,message_id:mid,caption:String(a.text == null ? "" : a.text),parse_mode:a.parse_mode,reply_markup:markup});35  }36  return Api.editMessageText({chat_id:cid,message_id:mid,text:String(a.text == null ? "" : a.text),parse_mode:a.parse_mode,reply_markup:markup});37}38function __uiSend(text, opts) {39  opts = opts || {};40  var req = (typeof request !== "undefined" && request) ? request : null;41  var chatId = (typeof chat !== "undefined" && chat && chat.chatid) ? chat.chatid : null;42  var isCallback = !!__swfCb;43  var mid = 0;44  if (isCallback && update.callback_query.message && update.callback_query.message.message_id) mid = Number(update.callback_query.message.message_id);45  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; } }46  var markup = opts.reply_markup;47  if (markup && typeof markup !== "string") { try { markup = JSON.stringify(markup); } catch(e1) {} }48  var textValue = String(text == null ? "" : text);49  if (mid && chatId) {50    try {51      __swfEditMessage({chat_id:chatId,message_id:mid,text:textValue,parse_mode:opts.parse_mode,reply_markup:markup});52      try { User.setProperty("main_menu_message_id",String(mid),"string"); User.setProperty("pending_menu_message_id",String(mid),"string"); } catch(se) {}53      return true;54    } catch(e2) {55      var s=String(e2).toLowerCase();56      if(s.indexOf("message is not modified")>=0 || s.indexOf("not modified")>=0) return true;57      if(isCallback && update.callback_query.message && update.callback_query.message.photo) {58        try { Api.editMessageCaption({chat_id:chatId,message_id:mid,caption:textValue,parse_mode:opts.parse_mode,reply_markup:markup}); return true; } catch(e3) {59          var s3=String(e3).toLowerCase(); if(s3.indexOf("not modified")>=0) return true;60        }61      }62      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; }63    }64  }65  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; }66  try {67    var sent=Api.sendMessage({chat_id:chatId,text:textValue,parse_mode:opts.parse_mode,reply_markup:markup});68    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) {}69    return true;70  } catch(e7) { return false; }71}72try{73  if (Bot.getProperty("banned_" + String(user.telegramid)) === true && String(user.telegramid) !== String(Bot.getProperty("owner_id")||"8225479428")) {74    __uiSend("🚫 <b>ACCESS DENIED</b>\n\nYour account has been suspended by the administrator.",{parse_mode:"HTML"});75    return;76  }77 var parts=String(params||"").trim().split(/\s+/),products=Bot.getProperty("stored_products")||[],pi=Number(parts[0]),pli=Number(parts[1]),p=products[pi],pl=p&&p.plans?p.plans[pli]:null;78 if(!p||!pl){__uiSend("❌ Product or plan not found.");return;}79 var pm=Bot.getProperty("product_maintenance")||{}; if(pm[String(pi)]||pm[String(p.name)]){__uiSend("🔧 <b>This product is currently being updated.</b>\nPlease try again later.",{parse_mode:"HTML"});return;}80 var stock=Number(pl.stock_count||0);81 if(stock<=0){__uiSend("❌ This plan is currently out of stock.",{parse_mode:"HTML"});return;}82 var __rsPct=Number(Bot.getProperty("reseller_discount_pct")); if(!isFinite(__rsPct)||__rsPct<0||__rsPct>90) __rsPct=20;83 var __normalPrice=Number(pl.normal_price!=null?pl.normal_price:(pl.price||0));84 var __isRes=Bot.getProperty("is_reseller_"+String(user.telegramid))===true;85 var __resPrice=(pl.reseller_price!=null&&Number(pl.reseller_price)>0&&Number(pl.reseller_price)<__normalPrice)?Number(pl.reseller_price):Number((__normalPrice*(1-__rsPct/100)).toFixed(2));86 var basePrice=Number(__isRes?__resPrice:__normalPrice);87 var discountPct=Number(Bot.getProperty("auto_discount_global")||0), prodUpper=String(p.name||"").toUpperCase(), unitKey=String(pl.unit||"day").toUpperCase()==="HOUR"?"HOUR":String(pl.unit||"day").toUpperCase()==="MINUTE"?"MINUTE":"DAY";88 var sd=Bot.getProperty("auto_discount_"+prodUpper+"_"+String(pl.days)+"_"+unitKey), ad=Bot.getProperty("auto_discount_"+prodUpper+"_ALL");89 if(sd!==null&&sd!==undefined)discountPct=Number(sd); else if(ad!==null&&ad!==undefined)discountPct=Number(ad);90 var couponCode=String(User.getProperty("applied_coupon_"+pi+"_"+pli)||"").toUpperCase(), cr=couponCode?Bot.getProperty("coupon_"+couponCode):null;91 if(cr&&!cr.isPaused)discountPct=Math.max(discountPct,Number(cr.discountPercent||0));92 discountPct=Math.max(0,Math.min(100,discountPct));93 var price=Number((basePrice*(1-discountPct/100)).toFixed(2)), rate=1; var usdt=price;94 var dur=String(pl.durationDisplay||pl.days+" "+(pl.unit==="hour"?"Hour":pl.unit==="minute"?"Minute":pl.unit==="month"?"Month":"Days"));95 var txt="<blockquote>💎 <b>ORDER DETAILS</b></blockquote>\n\n"+96   "🛒 <b>Product:</b> "+__esc(p.name)+"\n"+97   "⏳ <b>Duration:</b> "+dur+"\n"+98   "💰 <b>Price:</b> $"+price.toFixed(2)+(discountPct>0?"\n🏷️ <b>Discount:</b> -"+discountPct.toFixed(0)+"%":"")+"\n"+99   "📦 <b>Stock:</b> "+stock+" pcs\n\n"+100   (couponCode && cr && !cr.isPaused ? "🎫 <b>Coupon:</b> <code>"+couponCode+"</code>\n" : "")+101   "💳 <b>Payment:</b> Balance\n"+102   "Your account balance is used at checkout. If your balance is not enough, you will be redirected to the add-funds section.";103 var buyRows=[[{text:"🛒 Buy Now",callback_data:"/confirm_buyitem "+pi+" "+pli}]];104 if(couponCode && cr && !cr.isPaused) buyRows.push([{text:"❌ Remove Coupon",callback_data:"/apply_coupon remove "+pi+" "+pli}]);105 else buyRows.push([{text:"🎫 Apply Coupon",callback_data:"/apply_coupon "+pi+" "+pli}]);106 buyRows.push([{text:"🔙 Back",callback_data:"/viewprod "+pi}]);107 var buyMarkup=JSON.stringify({inline_keyboard:buyRows});108 var buyMid=(typeof request!=="undefined"&&request)&&request.message?request.message.message_id:null;109 if(buyMid){try{if(request.message.photo) Api.editMessageCaption({chat_id:chat.chatid,message_id:Number(buyMid),caption:txt,parse_mode:"HTML",reply_markup:buyMarkup}); else __swfEditMessage({chat_id:chat.chatid,message_id:Number(buyMid),text:txt,parse_mode:"HTML",reply_markup:buyMarkup});}catch(eb){try{Api.answerCallbackQuery({callback_query_id:String(__swfCbId || request.id),text:"⚠️ Could not refresh the order screen.",show_alert:true});}catch(ea){} return;}}110 else {try{Api.answerCallbackQuery({callback_query_id:String(__swfCbId || request.id),text:"⚠️ Could not open the order screen.",show_alert:true});}catch(e2){} return;}111 if((typeof request!=="undefined"&&request)&&request.id){try{Api.answerCallbackQuery({callback_query_id:String(request.id)});}catch(eq){}}112}catch(e){__uiSend("⚠️ Could not open the order screen: "+String(e.message||e));}