yaainnnxitstore/YASIN_XIT_BOTPublic · Bot Template
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
commands/_addkey.js
javascript · 118 lines
1/**#command2name: /addkey3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12function __esc(v){return String(v==null?"":v).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");}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");74 if(String(user.telegramid)!==adminId && !Bot.getProperty("co_admin_"+String(user.telegramid))){__uiSend("❌ You are not an administrator.");return;}75 if(!params){__uiSend("⚠️ Format:\n<code>/addkey PRODUCT NAME | DURATION | KEY1</code>\n<code>KEY2</code>\n<code>KEY3</code>\n\nExample: <code>/addkey Drip Cilent APK | 3d | KEY-001</code>",{parse_mode:"HTML"});return;}76 var lines=String(params).split(/\r?\n/), first=lines[0].split("|");77 if(first.length<3){__uiSend("⚠️ Format: <code>/addkey PRODUCT | DURATION | KEY</code>",{parse_mode:"HTML"});return;}78 var wantedName=String(first[0]).trim();79 var rawDuration=String(first[1]).trim().toLowerCase();80 var m=rawDuration.match(/^([0-9]+(?:\.[0-9]+)?)\s*(h|hr|hrs|hour|hours|m|min|mins|minute|minutes|d|day|days)?$/);81 if(!m){__uiSend("❌ Invalid duration. Use <code>1d</code>, <code>7d</code>, <code>1h</code> or <code>30m</code>.",{parse_mode:"HTML"});return;}82 var value=String(m[1]), ur=m[2]||"d";83 var unit=/^h/.test(ur)?"hour":(/^m/.test(ur)?"minute":"day");84 var keys=[String(first[2]).trim()];85 for(var i=1;i<lines.length;i++){var k=String(lines[i]).trim();if(k)keys.push(k);}86 keys=keys.filter(Boolean);87 var products=Bot.getProperty("stored_products")||[]; if(Array.isArray(products))products=products.slice(); else products=[];88 var prodIdx=-1;89 for(var p=0;p<products.length;p++)if(String(products[p].name||"").trim().toLowerCase()===wantedName.toLowerCase()){prodIdx=p;break;}90 if(prodIdx<0){__uiSend("❌ Product not found: <b>"+wantedName+"</b>",{parse_mode:"HTML"});return;}91 var product=products[prodIdx]; if(!Array.isArray(product.plans))product.plans=[];92 var planIdx=-1;93 for(var q=0;q<product.plans.length;q++){var pl=product.plans[q]||{};if(String(pl.days)===value&&String(pl.unit||"day")===unit){planIdx=q;break;}}94 if(planIdx<0){__uiSend("❌ This product has <b>"+value+" "+unit+" </b> has no such plan. Add the plan first with /addplan.",{parse_mode:"HTML"});return;}95 var cleanName=String(product.name).trim().toUpperCase();96 var stockKey="manual_keys_"+cleanName+"_"+value+"_"+unit;97 var legacyKey="manual_keys_"+cleanName+"_"+value;98 var existing=Bot.getProperty(stockKey);99 if(typeof existing==="string"){try{existing=JSON.parse(existing)}catch(e){existing=existing.split(/\r?\n/).filter(Boolean)}}100 if(Array.isArray(existing)) existing=existing.slice(); else existing=[];101 if(unit==="day" && !existing.length){var legacy=Bot.getProperty(legacyKey);if(typeof legacy==="string"){try{legacy=JSON.parse(legacy)}catch(e2){legacy=legacy.split(/\r?\n/).filter(Boolean)}}if(Array.isArray(legacy))existing=legacy.slice();}102 var seen={};for(var a=0;a<existing.length;a++)seen[String(existing[a])]=true;103 var added=0;104 for(var b=0;b<keys.length;b++){if(!seen[String(keys[b])]){existing.push(keys[b]);seen[String(keys[b])]=true;added++;}}105 Bot.setProperty(stockKey,existing,"json");106 if(unit==="day")Bot.setProperty(legacyKey,existing,"json");107 var backupKey="stock_"+__esc(product.name).trim()+"_"+value+"_"+(unit==="hour"?"Hour":unit==="minute"?"Minute":"Day");108 Bot.setProperty(backupKey,existing,"json");109 Bot.setProperty("stock_"+prodIdx+"_"+planIdx,existing,"json");110 product.plans[planIdx].stock_count=existing.length;111 Bot.setProperty("stored_products",products,"json");112 __uiSend("✅ <b>Stock updated successfully.</b>\n\n"+113 "🛒 <b>Product:</b> "+__esc(product.name)+"\n"+114 "🕒 <b>Plan:</b> "+value+" "+(unit==="hour"?"Hour":unit==="minute"?"Minute":"Days")+"\n"+115 "📦 <b>Added:</b> "+added+"\n"+116 "📊 <b>Total stock:</b> "+existing.length+"",117 {parse_mode:"HTML"});118} catch(e){__uiSend("⚠️ An error occurred while adding stock: "+String(e.message||e));}