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

javascript · 127 lines

Raw
1/**#command2name: /addplan3answer: 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  var adminId=String(Bot.getProperty("owner_id")||"8225479428"), caller=String(chat.chatid);74  if(caller!==adminId && !Bot.getProperty("co_admin_"+caller)){__uiSend("❌ You are not authorized.");return;}75  var raw=String(params||"").trim();76  if(!raw){__uiSend("<blockquote>🗓 <b>ADD PLAN</b></blockquote>\n\n<code>/addplan Product | Days | Price</code>\n\nExample:\n<code>/addplan Drip Client APKMOD | 1 | 30</code>\n<code>/addplan Drip Client APKMOD | 3 | 65</code>\n<code>/addplan Drip Client APKMOD | 7 | 110</code>\n<code>/addplan Drip Client APKMOD | 15 | 180</code>\n<code>/addplan Drip Client APKMOD | 30 | 275</code>",{parse_mode:"HTML"});return;}77  var a=raw.split("|").map(function(x){return String(x).trim();});78  if(a.length<3){__uiSend("⚠️ Format: <code>/addplan Product | Days | Price</code>",{parse_mode:"HTML"});return;}79  var name=a[0], dur=a[1].toLowerCase(), price=Number(a[2]);80  if(!name){__uiSend("❌ The product name cannot be empty.");return;}81  if(!isFinite(price)||price<0){__uiSend("❌ Invalid price.");return;}82  var m=dur.match(/^([0-9]+)\s*(h|hr|hour|hours|saat|d|day|days|gün)?$/), unit=(m&&/^(h|hr|hour|hours|saat)$/.test(String(m[2]||"")))?"hour":"day";83  if(!m || Number(m[1])<=0){__uiSend("❌ Invalid duration. Examples: <code>1h</code>, <code>12h</code>, <code>5d</code>, <code>60d</code>",{parse_mode:"HTML"});return;}84  var days=String(Number(m[1]));85  var durationDisplay=unit==="hour"?(days==="1"?"1 Hour":days+" Hours"):(days==="1"?"1 Day":days+" Days");86  var products=Bot.getProperty("stored_products")||[]; if(Array.isArray(products)) products=products.slice(); if(!Array.isArray(products))products=[];87  function norm(v){return String(v||"").toLowerCase().trim().replace(/[ğĞ]/g,"g").replace(/[üÜ]/g,"u").replace(/[şŞ]/g,"s").replace(/[ıİ]/g,"i").replace(/[öÖ]/g,"o").replace(/[çÇ]/g,"c").replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim();}88  var target=norm(name), idx=-1;89  for(var i=0;i<products.length;i++){90    var pn=products[i]||{};91    if(norm(pn.name)===target || (pn.id && norm(pn.id)===target)){idx=i;break;}92  }93  if(idx<0){94    var cats=Bot.getProperty("ff_categories")||{}; if(cats && typeof cats === "object") cats=Object.assign({}, cats);95    outer: for(var slug in cats){96      if(!cats.hasOwnProperty(slug) || !cats[slug] || !Array.isArray(cats[slug].products))continue;97      for(var ci=0;ci<cats[slug].products.length;ci++){98        var cp=cats[slug].products[ci]||{};99        if(norm(cp.name)===target || (cp.pid && norm(cp.pid)===target)){100          var merged={name:cp.name||name,emoji:cp.emoji_id||cp.emoji||"",id:cp.pid||"",category_slug:slug,plans:[]};101          var legacyDays=cp.day||"", legacyPrice=cp.price;102          if(legacyDays && isFinite(Number(String(legacyDays).replace(/[^0-9.]/g,"")))){103            var ld=String(Number(String(legacyDays).replace(/[^0-9.]/g,"")));104            merged.plans.push({days:ld,unit:"day",durationDisplay:ld==="30"?"1 Month":ld+" Days",normal_price:Number(legacyPrice)||0,reseller_price:Number(legacyPrice)||0,stock_count:Array.isArray(cp.stock)?cp.stock.length:0,emoji_id:null});105          }106          products.push(merged); idx=products.length-1; break outer;107        }108      }109    }110  }111  if(idx<0 && target){for(var j=0;j<products.length;j++){var pnm=norm(products[j]&&products[j].name);if(pnm && (pnm.indexOf(target)>=0 || target.indexOf(pnm)>=0)){idx=j;break;}}}112  if(idx<0){__uiSend("❌ <b>Product not found.</b>\n\nAdd the product to a category first, then add the plan using the same product name.",{parse_mode:"HTML"});return;}113  if(!Array.isArray(products[idx].plans))products[idx].plans=[];114  var pi=-1;115  for(var k=0;k<products[idx].plans.length;k++) if(String(products[idx].plans[k].days)===days&&String(products[idx].plans[k].unit||"day")===unit){pi=k;break;}116  if(pi<0){products[idx].plans.push({days:days,unit:unit,durationDisplay:durationDisplay,normal_price:price,reseller_price:price,stock_count:0,emoji_id:null});pi=products[idx].plans.length-1;}117  else {products[idx].plans[pi].normal_price=price;if(products[idx].plans[pi].reseller_price==null)products[idx].plans[pi].reseller_price=price;products[idx].plans[pi].unit=unit;products[idx].plans[pi].durationDisplay=durationDisplay;if(products[idx].plans[pi].stock_count==null)products[idx].plans[pi].stock_count=0;}118  Bot.setProperty("stored_products",products,"json");119  var p=products[idx], plan=p.plans[pi];120  Bot.setProperty("price_normal_"+String(p.name).toUpperCase()+"_"+days+"_"+unit,price,"number");121  __uiSend("<blockquote>🛒 <b>PLAN ADDED</b></blockquote>\n\n"+122    "📦 <b>Product:</b> "+__esc(p.name)+"\n"+123    "🗓 <b>Duration:</b> "+plan.durationDisplay+"\n"+124    "💰 <b>Price:</b> $"+price.toFixed(2)+"\n"+125    "📦 <b>Stock:</b> "+Number(plan.stock_count||0)+"\n\n"+126    "🎯 <i>The plan is now live in the shop.</i>",{parse_mode:"HTML"});127}catch(e){__uiSend("⚠️ Error adding plan: "+String(e&&e.message||e));}