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

javascript · 271 lines

Raw
1/**#command2name: /onWebKeyReceive3answer: 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 response = null;74  if (typeof content === "string" && content.trim() !== "") {75    try {76      response = JSON.parse(content);77    } catch (e) {78    }79  }80  var userId = user.telegramid;81  var chatId = chat.chatid;82  var dataOptions = options || {}; 83  var prodId = dataOptions.prod_id || dataOptions.id || dataOptions.product_id || User.getProperty("last_pending_prod_id") || null;84  var rawProdName = dataOptions.prod_name || dataOptions.product || dataOptions.name || User.getProperty("last_pending_prod_name") || "Product";85  var planDays = String(dataOptions.plan_days || dataOptions.days || User.getProperty("last_pending_plan_days") || "1");86  var pDaysNumOnly = planDays.replace(/[^0-9]/g, "").trim(); 87  var planUnit = dataOptions.plan_unit || User.getProperty("last_pending_plan_unit") || "day";88  var unitLabelWordW = (planUnit === "hour") ? (Number(pDaysNumOnly) === 1 ? "Hour" : "Hours") :89                        (planUnit === "minute") ? (Number(pDaysNumOnly) === 1 ? "Minute" : "Minutes") :90                        (Number(pDaysNumOnly) === 1 ? "Day" : "Days");91  var durationDisplayW = pDaysNumOnly + " " + unitLabelWordW;92  var productList = Bot.getProperty("stored_products") || [];93  var prodName = rawProdName.trim(); 94  if (productList.length > 0) {95    var checkTerm = prodName.toLowerCase();96    var foundMatch = false;97    for (var i = 0; i < productList.length; i++) {98      var dbItem = productList[i];99      var dbName = dbItem.name ? dbItem.name.trim() : "";100      var dbId = dbItem.id || null;101      if (prodId && dbId && String(prodId) === String(dbId)) {102        prodName = dbName;103        foundMatch = true;104        break;105      }106      if (!dbName) continue;107      if (dbName.toLowerCase() === checkTerm || 108          (checkTerm !== "product" && (checkTerm.indexOf(dbName.toLowerCase()) > -1 || dbName.toLowerCase().indexOf(checkTerm) > -1))) {109        prodName = dbName; 110        if (dbId) { prodId = dbId; } // Backfill ID if name matched111        foundMatch = true;112        break;113      }114    }115    if (!foundMatch || prodName.toLowerCase() === "product") {116      var lastPending = User.getProperty("last_pending_prod_name");117      if (lastPending && lastPending.toLowerCase() !== "product") {118        prodName = lastPending.trim();119      } else if (productList.length === 1) {120        prodName = productList[0].name.trim();121        if (productList[0].id) { prodId = productList[0].id; }122      }123    }124  }125  var price = Number(dataOptions.price) || Number(User.getProperty("last_pending_price")) || 0;126  var firstName = dataOptions.first_name || user.first_name || "User";127  var usernameText = user.username ? String(user.username) : "No Username";128  var currentWalletBal = Libs.ResourcesLib.userRes("balance").value().toFixed(2);129  var generatedKey = null;130  var isApiDelivery = false;131  var isBackupUsed = false;132  var cleanProdNameUpper = prodName.trim().toUpperCase();133  var manualKeysStorageKey = "manual_keys_" + cleanProdNameUpper + "_" + pDaysNumOnly + "_" + planUnit;134  var legacyManualKeysStorageKey = "manual_keys_" + cleanProdNameUpper + "_" + pDaysNumOnly;135  var backupStockKey = "stock_" + prodName.trim() + "_" + pDaysNumOnly + "_" + planUnit;136  var legacyBackupStockKey = "stock_" + prodName.trim() + "_" + pDaysNumOnly + "_Day";137  var manualStock = Bot.getProperty(manualKeysStorageKey);138  if ((!manualStock || (Array.isArray(manualStock) && manualStock.length === 0)) && planUnit === "day") manualStock = Bot.getProperty(legacyManualKeysStorageKey);139  if (!manualStock || (Array.isArray(manualStock) && manualStock.length === 0)) {140    manualStock = Bot.getProperty(backupStockKey);141    if ((!manualStock || (Array.isArray(manualStock) && manualStock.length === 0)) && planUnit === "day") manualStock = Bot.getProperty(legacyBackupStockKey);142    isBackupUsed = true;143  }144  if (Array.isArray(manualStock)) manualStock=manualStock.slice();145  if (typeof manualStock === "string" && manualStock.trim() !== "") {146    try {147      manualStock = JSON.parse(manualStock);148    } catch(err) {149      manualStock = manualStock.split("\n").map(function(k) { return k.trim(); }).filter(Boolean);150    }151  }152  if (Array.isArray(manualStock) && manualStock.length > 0) {153    generatedKey = manualStock.shift(); 154    if (isBackupUsed) {155      Bot.setProperty(backupStockKey, manualStock, "json");156      var mainStock = Bot.getProperty(manualKeysStorageKey) || []; if(Array.isArray(mainStock)) mainStock=mainStock.slice();157      if (typeof mainStock === "string") { mainStock = mainStock.split("\n").map(function(k) { return k.trim(); }).filter(Boolean); }158      if (Array.isArray(mainStock)) {159        var idx = mainStock.indexOf(generatedKey);160        if (idx > -1) { mainStock.splice(idx, 1); }161        Bot.setProperty(manualKeysStorageKey, mainStock, "json");162      }163    } else {164      Bot.setProperty(manualKeysStorageKey, manualStock, "json");165      var backupStock = Bot.getProperty(backupStockKey) || []; if(Array.isArray(backupStock)) backupStock=backupStock.slice();166      if (typeof backupStock === "string") { backupStock = backupStock.split("\n").map(function(k) { return k.trim(); }).filter(Boolean); }167      if (Array.isArray(backupStock)) {168        var idx = backupStock.indexOf(generatedKey);169        if (idx > -1) { backupStock.splice(idx, 1); }170        Bot.setProperty(backupStockKey, backupStock, "json");171      }172    }173  }174  if (generatedKey) {175    var orderIdAuto="ORD_"+Date.now()+"_"+Math.floor(Math.random()*10000000000);176    var orderRecAuto={id:orderIdAuto,user_id:String(userId),product_name:prodName,duration:durationDisplayW,amount:price,currency:"USD",payment_method:"💰 Balance",key:generatedKey,status:"delivered",created_at:new Date().toISOString(),delivered_at:new Date().toISOString()};177    Bot.setProperty("order_"+orderIdAuto,orderRecAuto,"json");178    var autoOrderIds=Bot.getProperty("user_order_ids_"+String(userId))||[];if(!Array.isArray(autoOrderIds))autoOrderIds=[];autoOrderIds.push(orderIdAuto);if(autoOrderIds.length>100)autoOrderIds=autoOrderIds.slice(-100);Bot.setProperty("user_order_ids_"+String(userId),autoOrderIds,"json");179    Libs.ResourcesLib.userRes("balance").add(-price);180    try {181      var autoLogId = Bot.getProperty("log_channel_id");182      if (autoLogId) {183        Api.sendMessage({chat_id: autoLogId, parse_mode: "HTML",184          text: "✨ <b>[ NEW HACK SOLD ]</b> ✨\n\n" +185                "🛒 <b>Product:</b> " + prodName + "\n" +186                "🗓️ <b>Duration:</b> " + durationDisplayW + "\n" +187                "💰 <b>Price:</b> $" + price.toFixed(2) + "\n" +188                "👤 <b>Buyer:</b> " + firstName + "\n" +189                "🆔 <b>Buyer Chat ID:</b> " + userId + "\n\n" +190                "🔥 <b>Instant Delivery Done! Thank you for your business!</b>\n\n" +191                "📢 @" + String(Bot.getProperty("bot_username")||"Yasin_Xit_Shop_bot")});192      }193    } catch(autoLogErr) {}194    var pastSpent = Bot.getProperty("total_spent_by_" + userId) || 0;195    Bot.setProperty("total_spent_by_" + userId, Number(pastSpent) + price, "number");196    var userKeysHistory = User.getProperty("my_purchased_keys") || []; if(Array.isArray(userKeysHistory)) userKeysHistory=userKeysHistory.slice();197    userKeysHistory.push({198      product: prodName,199      product_id: prodId,200      days: pDaysNumOnly,201      price: price,202      key: generatedKey,203      date: new Date().toLocaleDateString()204    });205    User.setProperty("my_purchased_keys", userKeysHistory, "json");206    var remainingBal = Libs.ResourcesLib.userRes("balance").value().toFixed(2);207    var updateLinkForKey = Bot.getProperty("update_channel_link");208    var keyDeliveryButtons = [[{ text: "📋 Copy Key", copy_text: { text: generatedKey } }]];209    if (updateLinkForKey) {210      keyDeliveryButtons.push([{ text: "📥 Join Updates", url: updateLinkForKey }]);211    }212    keyDeliveryButtons.push([{ text: "Back to Main Menu", callback_data: "/back" }]);213    var keyDeliveryMarkup = JSON.stringify({ inline_keyboard: keyDeliveryButtons });214    var deliverText = "<blockquote>" +215                      "✅ <b>PURCHASE SUCCESSFUL!</b>\n\n" +216                      "━━━━━━━━━━━━━━━━━━\n" +217                      "🎮 <b>Product:</b> " + prodName + "\n" +218                      "⏱️ <b>Duration:</b> " + durationDisplayW + "\n" +219                      "💰 <b>Paid:</b> $" + price.toFixed(2) + "\n" +220                      "💳 <b>Payment:</b> 💰 Balance\n" +221                      "📝 <b>Order ID:</b> " + orderIdAuto + "\n" +222                      "━━━━━━━━━━━━━━━━━━\n\n" +223                      "🔑 <b>YOUR LICENSE KEY:</b>\n<code>" + generatedKey + "</code>\n\n" +224                      "💡 <i>Keep this key somewhere safe!</i>\n\n" +225                      "━━━━━ #⃣ <b>BALANCE DETAILS</b> ━━━━━\n" +226                      "✨ <b>Total Spent:</b> $" + price.toFixed(2) + "\n" +227                      "💵 <b>New wallet balance:</b> $" + remainingBal + "\n\n" +228                      "<i>Enjoy!  🥳</i>" +229                      "</blockquote>";230    try {231      var procMsgId = Bot.getProperty("gen_msg_id_" + userId) || User.getProperty("gen_msg_id_" + userId);232      if (procMsgId) {233        Api.deleteMessage({ chat_id: chatId, message_id: Number(procMsgId) });234        Bot.setProperty("gen_msg_id_" + userId, null, "string");235        User.setProperty("gen_msg_id_" + userId, null, "string");236      }237    } catch (cleanupErr) {}238    Api.sendMessage({239      chat_id: chatId,240      text: deliverText,241      parse_mode: "HTML",242      reply_markup: keyDeliveryMarkup243    });244    User.setProperty("last_pending_price", null);245    User.setProperty("last_pending_prod_name", null);246    User.setProperty("last_pending_plan_days", null);247    User.setProperty("last_pending_prod_id", null);248    User.setProperty("last_pending_plan_unit", null);249  } else {250    Api.sendMessage({251      chat_id: chatId,252      text: "⏳ <b>Please wait; the administrator will restock soon.</b>\n<i>No charge was taken from your balance.</i>",253      parse_mode: "HTML"254    });255    var alertAdminId = Bot.getProperty("owner_id") || "8225479428";256    var outOfStockAdminMsg = "\u26A0\uFE0F <b>OUT OF STOCK \u2014 DELIVERY FAILED</b>\n" +257                             "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n" +258                             "\uD83D\uDED2 <b>PRODUCT DETAILS:</b>\n" +259                             "\uD83D\uDCE6 <b>Product:</b> <code>" + prodName + "</code>\n" +260                             "\u23F3 <b>Duration:</b> <code>" + pDaysNumOnly + " Days</code>\n\n" +261                             "\uD83D\uDC64 <b>CUSTOMER:</b>\n" +262                             "\uD83D\uDDE3 <b>Username:</b> " + usernameText + "\n" +263                             "\uD83D\uDCDB <b>Name:</b> " + firstName + "\n" +264                             "\uD83C\uDD94 <b>User ID:</b> <code>" + userId + "</code>\n" +265                             "\uD83D\uDCB3 <b>Wallet Balance:</b> $" + currentWalletBal + "\n\n" +266                             "\uD83D\uDCCC <i>No charge was taken. Add stock with /addstock, then send the key manually.</i>";267    Api.sendMessage({ chat_id: alertAdminId, text: outOfStockAdminMsg, parse_mode: "HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"\uD83D\uDCE6 Add Stock",callback_data:"/addstock"}]]}) });268  }269} catch (e) {270  __uiSend("❌ An error occurred during delivery: " + e.message);271}