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/_start.js
javascript · 1101 lines
1/**#command2name: /start3answer: 4keyboard: 5parse_mode: markdown6aliases: /START,/Start,/STArt,/stARt7allow_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 __ownerIdRaw = Bot.getProperty("owner_id");74 var adminId = __ownerIdRaw || "8225479428";75 var userId = String(user.telegramid);76 var __isAdminOrCo = (String(userId) === String(adminId)) || !!Bot.getProperty("co_admin_" + userId);77 if (!__ownerIdRaw) Bot.setProperty("owner_id", adminId, "string");78 var req = (typeof request !== "undefined" && request) ? request : null;79 var msgText = "";80 try {81 if (typeof message !== "undefined" && message != null) {82 if (typeof message === "string") msgText = message.trim();83 else if (message.text != null) msgText = String(message.text).trim();84 else if (message.caption != null) msgText = String(message.caption).trim();85 }86 } catch (msgTextErr) { msgText = ""; }87 var incomingMessage = (req && req.message) ? req.message : req;88 var callbackData = (__swfCb && __swfCb.data) ? __swfCb.data : "";89 if (Bot.getProperty("banned_" + userId) === true && String(userId) !== String(adminId)) {90 var banMsg = "🚫 <b>ACCESS DENIED</b>\n\nYour account has been suspended by the administrator.\n\n<i>Contact support if you believe this is a mistake.</i>";91 try {92 if (__swfCb) { try { Api.answerCallbackQuery({callback_query_id:String(__swfCb.id),text:"🚫 Your account has been suspended.",show_alert:true}); } catch(bcq) {} }93 else { Api.sendMessage({chat_id: chat.chatid, text: banMsg, parse_mode: "HTML"}); }94 } catch(banErr) {}95 return;96 }97 if (String(userId) === String(adminId) && User.getProperty("awaiting_logid") === true && msgText && msgText.charAt(0) !== "/") {98 var incomingLogId = msgText.trim();99 if (!/^-100\d+$/.test(incomingLogId)) { __uiSend("❌ Invalid channel ID. Send it in <code>-100...</code> format.",{parse_mode:"HTML"}); return; }100 Bot.setProperty("log_channel_id",incomingLogId,"string"); User.setProperty("awaiting_logid",false,"boolean");101 __uiSend("✅ <b>Log channel set.</b>\n🆔 <code>"+incomingLogId+"</code>",{parse_mode:"HTML"}); return;102 }103 if (User.getProperty("support_user_reply_to") && msgText && msgText.charAt(0) !== "/") {104 var uTkId = String(User.getProperty("support_user_reply_to"));105 User.setProperty("support_user_reply_to", null, "string");106 var uAll = Bot.getProperty("all_support_tickets") || []; if (!Array.isArray(uAll)) uAll = [];107 var uIdx = -1; for (var ui = 0; ui < uAll.length; ui++) { if (String(uAll[ui].id) === uTkId) { uIdx = ui; break; } }108 if (uIdx < 0 || String(uAll[uIdx].user_id) !== userId) { __uiSend("❌ Ticket not found."); return; }109 var uTk = uAll[uIdx];110 if (!Array.isArray(uTk.messages)) uTk.messages = [];111 uTk.messages.push({sender: "user", text: msgText, created_at: new Date().toISOString()});112 uAll[uIdx] = uTk; Bot.setProperty("all_support_tickets", uAll, "json");113 try {114 Api.sendMessage({chat_id: String(adminId), parse_mode: "HTML",115 text: "💬 <b>TICKET REPLY</b>\n\n🆔 <code>" + uTkId + "</code>\n👤 " + String(uTk.name || "User") + "\n\n" + msgText,116 reply_markup: JSON.stringify({inline_keyboard: [[{text: "💬 Reply", callback_data: "/support_reply " + uTkId},{text: "✅ Close", callback_data: "/support_close " + uTkId}]]})});117 } catch(uRepErr) {}118 __uiSend("✅ <b>Message sent.</b>\n\n<i>The team will get back to you shortly.</i>", {parse_mode: "HTML", reply_markup: JSON.stringify({inline_keyboard: [[{text: "🎫 View Ticket", callback_data: "/support_view " + uTkId}]]})});119 return;120 }121 if ((__isAdminOrCo) && User.getProperty("support_reply_to") && msgText && msgText.charAt(0) !== "/") {122 var replyTicketId = String(User.getProperty("support_reply_to"));123 User.setProperty("support_reply_to", null, "string");124 var allTk = Bot.getProperty("all_support_tickets") || []; if (!Array.isArray(allTk)) allTk = [];125 var tkIdx = -1; for (var ti = 0; ti < allTk.length; ti++) { if (String(allTk[ti].id) === replyTicketId) { tkIdx = ti; break; } }126 if (tkIdx < 0) { __uiSend("❌ Ticket not found."); return; }127 var tkRec = allTk[tkIdx];128 if (!Array.isArray(tkRec.messages)) tkRec.messages = [];129 tkRec.messages.push({sender: "admin", text: msgText, created_at: new Date().toISOString()});130 tkRec.status = "Open";131 allTk[tkIdx] = tkRec; Bot.setProperty("all_support_tickets", allTk, "json");132 try {133 Api.sendMessage({chat_id: String(tkRec.user_id), parse_mode: "HTML",134 text: "💬 <b>SUPPORT REPLY</b>\n\n🆔 Ticket: <code>" + replyTicketId + "</code>\n\n" + msgText,135 reply_markup: JSON.stringify({inline_keyboard: [[{text: "🎫 My Tickets", callback_data: "/support"}]]})});136 } catch(replyErr) { __uiSend("⚠️ Could not deliver the reply to the customer."); return; }137 __uiSend("✅ <b>Reply sent.</b>\n\n🆔 <code>" + replyTicketId + "</code>", {parse_mode: "HTML", reply_markup: JSON.stringify({inline_keyboard: [[{text: "🔙 Tickets", callback_data: "/support_list"}]]})});138 return;139 }140 if (String(userId) === String(adminId) && User.getProperty("awaiting_spin_range") === true && msgText && msgText.charAt(0) !== "/") {141 var spinParts = String(msgText).trim().replace(/,/g,".").split(/\s+/);142 var spinLo = Number(spinParts[0]), spinHi = Number(spinParts[1]);143 if (!isFinite(spinLo) || !isFinite(spinHi) || spinLo < 0 || spinHi <= 0) { __uiSend("❌ Send it as <code>min max</code>. Example: <code>0.01 0.25</code>",{parse_mode:"HTML"}); return; }144 if (spinHi < spinLo) { var spinSw = spinLo; spinLo = spinHi; spinHi = spinSw; }145 Bot.setProperty("spin_min",spinLo,"number"); Bot.setProperty("spin_max",spinHi,"number");146 User.setProperty("awaiting_spin_range",false,"boolean");147 __uiSend("✅ <b>Spin range updated.</b>\n\n🎰 $"+spinLo.toFixed(2)+" - $"+spinHi.toFixed(2),{parse_mode:"HTML"}); return;148 }149 if (String(userId) === String(adminId) && User.getProperty("awaiting_reseller_min") === true && msgText && msgText.charAt(0) !== "/") {150 var incomingMin = Number(String(msgText).trim().replace(",", "."));151 if (!isFinite(incomingMin) || incomingMin <= 0) { __uiSend("❌ Enter a positive amount. Example: <code>5</code>",{parse_mode:"HTML"}); return; }152 Bot.setProperty("reseller_min_spend",incomingMin,"number"); User.setProperty("awaiting_reseller_min",false,"boolean");153 __uiSend("✅ <b>Threshold updated.</b>\n\n⚙️ Auto-upgrade at $"+incomingMin.toFixed(2),{parse_mode:"HTML"}); return;154 }155 if (String(userId) === String(adminId) && User.getProperty("awaiting_referral_pct") === true && msgText && msgText.charAt(0) !== "/") {156 var incomingPct = Number(String(msgText).trim().replace(",", "."));157 if (!isFinite(incomingPct) || incomingPct < 0 || incomingPct > 100) { __uiSend("❌ Enter a value between 0 and 100. Example: <code>20</code>",{parse_mode:"HTML"}); return; }158 Bot.setProperty("referral_percent",incomingPct,"number"); User.setProperty("awaiting_referral_pct",false,"boolean");159 __uiSend("✅ <b>Referral commission updated.</b>\n\n🎁 "+incomingPct+"% per purchase",{parse_mode:"HTML"}); return;160 }161 if ((__isAdminOrCo) && msgText && msgText.charAt(0) !== "/") {162 if (User.getProperty("awaiting_reseller_add") === true) {163 User.setProperty("awaiting_reseller_add", false, "boolean");164 Bot.run({command: "/add_reseller " + msgText.trim()});165 return;166 }167 if (User.getProperty("awaiting_reseller_remove") === true) {168 User.setProperty("awaiting_reseller_remove", false, "boolean");169 Bot.run({command: "/rem_reseller " + msgText.trim()});170 return;171 }172 if (User.getProperty("awaiting_reseller_pct") === true) {173 User.setProperty("awaiting_reseller_pct", false, "boolean");174 Bot.run({command: "/set_reseller_pct " + msgText.trim()});175 return;176 }177 }178 if ((__isAdminOrCo) && User.getProperty("awaiting_maint_msg") === true && msgText && msgText.charAt(0) !== "/") {179 User.setProperty("awaiting_maint_msg", false, "boolean");180 Bot.run({command: "/set_maintmsg " + msgText.trim()});181 return;182 }183 if (String(userId) === String(adminId) && User.getProperty("awaiting_payid") === true && msgText && msgText.charAt(0) !== "/") {184 var incomingPayId = String(msgText).trim();185 if (!/^[0-9]{6,20}$/.test(incomingPayId)) { __uiSend("❌ Invalid Pay ID. It must be 6-20 digits.",{parse_mode:"HTML"}); return; }186 Bot.setProperty("binance_pay_id",incomingPayId,"string"); User.setProperty("awaiting_payid",false,"boolean");187 __uiSend("✅ <b>Binance Pay ID updated.</b>\n\n🆔 <code>"+incomingPayId+"</code>",{parse_mode:"HTML"}); return;188 }189 if ((__isAdminOrCo) && msgText && msgText.charAt(0) !== "/") {190 if (User.getProperty("awaiting_fj_channel") === true) {191 User.setProperty("awaiting_fj_channel", false, "boolean");192 var __cp = String(msgText).split("|");193 var __cid = String(__cp[0] || "").trim(), __curl = "", __ctt = "";194 if (__cp.length >= 3) { __curl = String(__cp[1]).trim(); __ctt = String(__cp[2]).trim(); }195 else if (__cp.length === 2) { __ctt = String(__cp[1]).trim(); }196 var __chBack = JSON.stringify({inline_keyboard:[[{text:"\ud83d\udce2 Channels", callback_data:"/points_admin ch"}]]});197 if (!__cid) { __uiSend("\u274c Invalid format. Example: <code>@mychannel | My Channel</code>", {parse_mode:"HTML", reply_markup:__chBack}); return; }198 if (!__curl) {199 if (__cid.charAt(0) === "@") __curl = "https://t.me/" + __cid.substring(1);200 else { __uiSend("\u274c A numeric channel ID needs an invite link.\n\n<code>-1001234567890 | https://t.me/+abc | VIP</code>", {parse_mode:"HTML", reply_markup:__chBack}); return; }201 }202 if (!__ctt) __ctt = (__cid.charAt(0) === "@") ? __cid.substring(1) : "Channel";203 var __warn = "";204 try { Api.getChat({chat_id: __cid}); } catch(__gcErr) { __warn = "\n\n\u26a0 The bot cannot read this chat. Make it an administrator there, otherwise the check is skipped."; }205 var __chs = Bot.getProperty("fj_channels") || []; if (!Array.isArray(__chs)) __chs = [];206 __chs.push({id: __cid, url: __curl, title: __ctt});207 Bot.setProperty("fj_channels", __chs, "json");208 __uiSend("\u2705 <b>Channel added.</b>\n\n\ud83d\udce2 " + __esc(__ctt) + "\n\ud83c\udd94 <code>" + __esc(__cid) + "</code>" + __warn, {parse_mode:"HTML", reply_markup:__chBack});209 return;210 }211 if (User.getProperty("awaiting_ref_points") === true) {212 var __rpv = Number(String(msgText).trim());213 if (!isFinite(__rpv) || __rpv < 0 || __rpv > 100000) { __uiSend("\u274c Send a number between 0 and 100000. Example: <code>10</code>", {parse_mode:"HTML"}); return; }214 User.setProperty("awaiting_ref_points", false, "boolean");215 Bot.setProperty("ref_points", Math.floor(__rpv), "number");216 __uiSend("\u2705 <b>Referral reward updated.</b>\n\n\ud83c\udf81 " + Math.floor(__rpv) + " points per verified referral.", {parse_mode:"HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"\ud83d\udc8e Points System", callback_data:"/points_admin"}]]})});217 return;218 }219 var __ppSt = User.getProperty("awaiting_point_price");220 if (__ppSt) {221 var __pps = null; try { __pps = (typeof __ppSt === "string") ? JSON.parse(__ppSt) : __ppSt; } catch(__ppe) { __pps = null; }222 if (__pps) {223 var __ppv = Number(String(msgText).trim());224 if (!isFinite(__ppv) || __ppv < 0 || __ppv > 1000000) { __uiSend("\u274c Send a number. Example: <code>50</code> (or <code>0</code> to disable)", {parse_mode:"HTML"}); return; }225 User.setProperty("awaiting_point_price", "", "string");226 Bot.setProperty("point_price_" + Number(__pps.p) + "_" + Number(__pps.pl), __ppv > 0 ? Math.floor(__ppv) : 0, "number");227 __uiSend(__ppv > 0 ? ("\u2705 <b>Point price set:</b> " + Math.floor(__ppv) + " points.") : "\u2705 <b>Removed from the points shop.</b>", {parse_mode:"HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"\ud83d\udcb0 Plans", callback_data:"/points_admin ppp " + Number(__pps.p)}],[{text:"\ud83d\udc8e Points System", callback_data:"/points_admin"}]]})});228 return;229 }230 }231 if (User.getProperty("awaiting_points_give") === true) {232 var __gp = String(msgText).split("|");233 var __gid = String(__gp[0] || "").trim(), __gam = Number(String(__gp[1] || "").trim());234 if (!/^\d+$/.test(__gid) || !isFinite(__gam) || __gam === 0) { __uiSend("\u274c Format: <code>UserID | Amount</code>\nExample: <code>123456789 | 100</code>", {parse_mode:"HTML"}); return; }235 User.setProperty("awaiting_points_give", false, "boolean");236 var __gnew = Number(Bot.getProperty("points_" + __gid) || 0) + Math.floor(__gam);237 if (__gnew < 0) __gnew = 0;238 Bot.setProperty("points_" + __gid, __gnew, "number");239 try { Api.sendMessage({chat_id: __gid, parse_mode:"HTML", text: (__gam > 0 ? "\ud83d\udc8e <b>You received " + Math.floor(__gam) + " points!</b>" : "\u26a0\ufe0f <b>" + Math.abs(Math.floor(__gam)) + " points were removed.</b>") + "\n\n\ud83d\udcb0 Balance: <b>" + __gnew + " points</b>", reply_markup: JSON.stringify({inline_keyboard:[[{text:"\ud83d\udc8e Free Points", callback_data:"/freepoints"}]]})}); } catch(__gErr) {}240 __uiSend("\u2705 <b>Done.</b>\n\n\ud83c\udd94 <code>" + __gid + "</code>\n\ud83d\udc8e New balance: <b>" + __gnew + " points</b>", {parse_mode:"HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"\ud83d\udc8e Points System", callback_data:"/points_admin"}]]})});241 return;242 }243 }244 var records = Bot.getProperty("all_users_records") || []; if(Array.isArray(records))records=records.slice();245 if (!Array.isArray(records)) records = [];246 var recIndex = -1;247 for (var ri=0; ri<records.length; ri++) { if (String(records[ri].id)===userId) { recIndex=ri; break; } }248 var nowIso = new Date().toISOString();249 var displayName = ((user.first_name||"") + (user.last_name ? " "+user.last_name : "")).trim() || "Unknown";250 var __joinDisp = nowIso.slice(0,10);251 if (recIndex < 0) {252 records.push({id:userId,name:displayName,first_name:user.first_name||"",last_name:user.last_name||"",phone:User.getProperty("phone_number")||"",username:user.username?String(user.username):"None",first_seen:__joinDisp,last_seen:__joinDisp});253 try { if(!Bot.getProperty("joined_date_"+userId)) Bot.setProperty("joined_date_"+userId,__joinDisp,"string"); } catch(__jd){}254 } else {255 records[recIndex].name=displayName; records[recIndex].first_name=user.first_name||""; records[recIndex].last_name=user.last_name||""; records[recIndex].phone=User.getProperty("phone_number")||records[recIndex].phone||""; records[recIndex].username=user.username?String(user.username):"None";256 if(!records[recIndex].first_seen) records[recIndex].first_seen=__joinDisp;257 records[recIndex].last_seen=__joinDisp;258 try { if(!Bot.getProperty("joined_date_"+userId)) Bot.setProperty("joined_date_"+userId,records[recIndex].first_seen,"string"); } catch(__jd2){}259 }260 Bot.setProperty("all_users_records",records,"json");261 try {262 var existingCats = Bot.getProperty("ff_categories") || {};263 if (!existingCats || typeof existingCats !== "object" || Array.isArray(existingCats)) existingCats = {};264 var changedCats = false;265 var catAliases = {androidnonroot:"android_nonroot", androidroot:"android_root", iphoneios:"iphone_ios", ios:"iphone_ios", emulatorpc:"pc"};266 for (var oldCat in catAliases) {267 var canonicalCat = catAliases[oldCat];268 if (!existingCats[oldCat]) continue;269 if (!existingCats[canonicalCat]) existingCats[canonicalCat] = existingCats[oldCat];270 else if (Array.isArray(existingCats[oldCat].products)) {271 if (!Array.isArray(existingCats[canonicalCat].products)) existingCats[canonicalCat].products=[];272 for (var ap=0; ap<existingCats[oldCat].products.length; ap++) existingCats[canonicalCat].products.push(existingCats[oldCat].products[ap]);273 }274 delete existingCats[oldCat]; changedCats = true;275 }276 if (changedCats) Bot.setProperty("ff_categories", existingCats, "json");277 } catch (catalogMigrationErr) {}278 if (msgText.toLowerCase() === "/start") {279 try { User.setProperty("main_menu_message_id",null,"string"); User.setProperty("pending_menu_message_id",null,"string"); } catch(eStartMenu) {}280 try { var startIncomingMid = incomingMessage && incomingMessage.message_id ? Number(incomingMessage.message_id) : 0; if (startIncomingMid) Api.deleteMessage({chat_id:chat.chatid,message_id:startIncomingMid}); } catch(eStartDelete) {}281 User.setProperty("awaiting_binance_txid",false,"boolean");282 User.setProperty("deposit_method","","string");283 User.setProperty("pending_pay_amount",null);284 User.setProperty("payment_session_expires_at",0,"number");285 User.setProperty("manual_payment_expires_at",0,"number");286 }287 var manualExpiry = Number(User.getProperty("manual_payment_expires_at") || 0);288 var awaitingBinance = User.getProperty("awaiting_binance_txid") === true;289 if (awaitingBinance && manualExpiry && Date.now() > manualExpiry) {290 User.setProperty("awaiting_binance_txid",false,"boolean");291 User.setProperty("deposit_method","","string"); User.setProperty("pending_pay_amount",null);292 __uiSend("⏰ <b>The payment window has closed.</b>\n\nReopen Add Funds to deposit again.",{parse_mode:"HTML"});293 return;294 }295 if (awaitingBinance && msgText && msgText.charAt(0)!=="/") {296 var payOrderId=msgText.trim();297 if(payOrderId.length<4 || payOrderId.length>128){__uiSend("❌ <b>Invalid Pay Order ID.</b>",{parse_mode:"HTML"});return;}298 var depId2=String(User.getProperty("active_deposit_id")||"");299 var payrec2=depId2?Bot.getProperty("manual_payment_"+depId2):null;300 if(!payrec2 || String(payrec2.user_id)!==userId || payrec2.method!=="binance" || String(payrec2.status)!=="pending"){301 __uiSend("❌ <b>Transaction not found!</b>\n\nThere is no active deposit for this pay order.",{parse_mode:"HTML"});return;302 }303 if(Date.now()>Number(payrec2.expires_at||0)){payrec2.status="expired";Bot.setProperty("manual_payment_"+depId2,payrec2,"json");__uiSend("⏰ <b>The payment window has expired.</b>",{parse_mode:"HTML"});return;}304 var __poKey = "used_pay_order_" + payOrderId.toUpperCase();305 var __poPrev = Bot.getProperty(__poKey);306 if (__poPrev && String(__poPrev) !== String(depId2)) {307 __uiSend("❌ <b>This Pay Order ID has already been used.</b>\n\nEach payment needs its own Binance Pay Order ID.",{parse_mode:"HTML"});308 return;309 }310 Bot.setProperty(__poKey, String(depId2), "string");311 payrec2.pay_order_id=payOrderId; payrec2.txid=payOrderId; payrec2.submitted_at=new Date().toISOString(); payrec2.status="pending_receipt";312 Bot.setProperty("manual_payment_"+depId2,payrec2,"json");313 User.setProperty("awaiting_binance_txid",false,"boolean");314 try {315 var adminForBinance = adminId;316 Api.sendMessage({chat_id:adminForBinance,text:"<blockquote>🟡 <b>NEW BINANCE PAY REQUEST</b></blockquote>\n\n👤 "+(payrec2.name||"User")+" | "+(payrec2.username||"None")+"\n🆔 <code>"+userId+"</code>\n💰 $"+Number(payrec2.amount).toFixed(2)+"\n🔢 Pay Order ID: <code>"+payOrderId+"</code>\n📝 Deposit ID: <code>"+depId2+"</code>\n\nCheck this payment in your Binance Pay history and approve it.",parse_mode:"HTML",reply_markup:JSON.stringify({inline_keyboard:[[{text:"✅ Approve",callback_data:"/approve_manual_payment "+depId2},{text:"❌ Reject",callback_data:"/reject_manual_payment "+depId2}]]})});317 __uiSend("⏳ <b>Your pay order has been received.</b>\n\n📝 Deposit ID: <code>"+depId2+"</code>\n🔢 Pay Order ID: <code>"+payOrderId+"</code>\n\n⏳ An administrator will check the Binance Pay history and approve it.",{parse_mode:"HTML"});318 } catch(binSendErr) {319 payrec2.status="awaiting_binance_verification"; Bot.setProperty("manual_payment_"+depId2,payrec2,"json"); User.setProperty("awaiting_binance_txid",true,"boolean");320 __uiSend("❌ <b>The pay order could not be sent to the administrator.</b> Please try again.",{parse_mode:"HTML"});321 }322 return;323 }324 var currentStep = User.getProperty("add_product_step");325 var isAwaitingBroadcast = User.getProperty("awaiting_broadcast_data");326 var EMJ_VERIFIED_CHECK = "✔️";327 var EMJ_CROWN = "👑";328 var EMJ_DROP = "💧";329 var EMJ_CHECK = "✅";330 var EMJ_ROCKET = "🚀";331 var EMJ_RADAR = "📡";332 var EMJ_STAR = "✨";333 var EMJ_RED_DOT = "🔴";334 var EMJ_NEW_ACCESS = "✔️";335 function sendMainMenu() {336 try {337 Bot.run({command:"/menu"});338 return true;339 } catch (menuErr) {340 try { Bot.runCommand("/menu"); return true; } catch (menuErr2) {}341 __uiSend("⚠️ Could not open the main menu. Please type /start again.");342 return false;343 }344 }345function __ptsGet(u){var v=Number(Bot.getProperty("points_"+String(u))||0);return isFinite(v)?v:0;}346function __ptsSet(u,v){if(!isFinite(v)||v<0)v=0;Bot.setProperty("points_"+String(u),Number(v),"number");return Number(v);}347function __refPoints(){var v=Number(Bot.getProperty("ref_points"));return (isFinite(v)&&v>=0)?v:10;}348function __fjList(){var c=Bot.getProperty("fj_channels")||[];return Array.isArray(c)?c:[];}349function __fjMissing(uid){var l=__fjList(),o=[];for(var i=0;i<l.length;i++){var ok=true;try{var r=Api.getChatMember({chat_id:String(l[i].id),user_id:String(uid)});var st=r?String(r.status||(r.result&&r.result.status)||""):"";if(st)ok=(st==="member"||st==="administrator"||st==="creator");}catch(e8){ok=true;}if(!ok)o.push(l[i]);}return o;}350function __fjScreen(ms){var kb=[];for(var i=0;i<ms.length;i++)kb.push([{text:"\ud83d\udce2 "+String(ms[i].title||"Channel"),url:String(ms[i].url)}]);kb.push([{text:"\u2705 Check Subscription",callback_data:"/fjcheck"}]);__uiSend("\ud83d\udd12 <b>ACCESS LOCKED</b>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\u27a1 You must join our channel(s) to use this bot.\n\u27a1 Join all of them, then tap <b>Check Subscription</b>.",{parse_mode:"HTML",reply_markup:{inline_keyboard:kb}});}351function __awardRefPoints(uid){try{uid=String(uid);var ref=Bot.getProperty("referred_by_"+uid);if(!ref)return;ref=String(ref);if(ref===uid)return;if(Bot.getProperty("ref_points_paid_"+uid)===true)return;var rp=__refPoints();Bot.setProperty("ref_points_paid_"+uid,true,"boolean");if(rp<=0)return;var nb=__ptsSet(ref,__ptsGet(ref)+rp);Bot.setProperty("ref_points_total_"+ref,Number(Bot.getProperty("ref_points_total_"+ref)||0)+rp,"number");try{Api.sendMessage({chat_id:ref,parse_mode:"HTML",text:"\ud83c\udf89 <b>NEW REFERRAL VERIFIED</b>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u27a1 Reward: <b>+"+rp+" points</b>\n\u27a1 Balance: <b>"+nb+" points</b>",reply_markup:JSON.stringify({inline_keyboard:[[{text:"\ud83d\udc8e Free Points",callback_data:"/freepoints"}]]})});}catch(e9){}}catch(e10){}}352function __pointPrice(p,pl){var v=Number(Bot.getProperty("point_price_"+p+"_"+pl));return (isFinite(v)&&v>0)?v:0;}353function __fjGate(){try{var g=String(user.telegramid);var ms=__fjMissing(g);if(ms.length){__fjScreen(ms);return false;}__awardRefPoints(g);return true;}catch(eG){return true;}}354 var trackedUsers = Bot.getProperty("all_users_list") || []; if (Array.isArray(trackedUsers)) trackedUsers = trackedUsers.slice();355 if (!trackedUsers.includes(userId)) {356 trackedUsers.push(userId);357 Bot.setProperty("all_users_list", trackedUsers, "json");358 }359 var verified = User.getProperty("phone_verified") === true;360 var incoming = (req && req.message) ? req.message : req;361 var contact = incoming && incoming.contact ? incoming.contact : null;362 if (contact) {363 var contactUserId = String(contact.user_id || "");364 if (!contact.phone_number || contactUserId !== userId) {365 __uiSend("❌ <b>Phone verification failed.</b> Please use the Telegram phone verification button below.", {parse_mode:"HTML"});366 return;367 }368 var normalizedPhone = String(contact.phone_number).replace(/[^0-9+]/g,"");369 User.setProperty("phone_number", normalizedPhone, "string");370 User.setProperty("phone_verified", true, "boolean");371 var freshRecords = Bot.getProperty("all_users_records") || []; if(Array.isArray(freshRecords))freshRecords=freshRecords.slice(); if (!Array.isArray(freshRecords)) freshRecords=[];372 var found=-1;373 for(var fri=0;fri<freshRecords.length;fri++){ if(String(freshRecords[fri].id)===userId){found=fri;break;} }374 var freshRec={id:userId,name:displayName,first_name:user.first_name||"",last_name:user.last_name||"",phone:normalizedPhone,username:user.username?String(user.username):"None"};375 if(found<0) freshRecords.push(freshRec); else freshRecords[found]=freshRec;376 Bot.setProperty("all_users_records",freshRecords,"json");377 var ownerForVerify=String(adminId);378 try {379 var verifyText="✅ <b>NEW USER VERIFIED</b>\n━━━━━━━━━━━━━━━━━━\n👤 Username: "+displayName+" "+(user.username?String(user.username):"")+"\n📞 Phone Number: "+normalizedPhone+"\n🆔 User ID :"+userId+"\n✉️ Full Name: "+displayName;380 Api.sendMessage({chat_id:ownerForVerify,text:verifyText,parse_mode:"HTML"});381 } catch(eVerifyLog) {}382 var verifySuccessText =383 "<b>✅ Verified!</b>\n\n" +384 "🎉 Verification complete!\n\n" +385 "━━━━━━━━━━━━━━━━━━\n" +386 "🛒 You can start shopping now!\n" +387 "💎 Browse the premium keys\n" +388 "⚡ Instant delivery\n" +389 "🔒 100% Secure\n" +390 "━━━━━━━━━━━━━━━━━━\n\n" +391 "Opening the shop... 🚀";392 var verifyMidBefore = Number(User.getProperty("verification_message_id") || 0);393 try { if (verifyMidBefore) Api.deleteMessage({chat_id:chat.chatid,message_id:verifyMidBefore}); } catch(verifyDeleteErr) {}394 User.setProperty("verification_message_id","", "string");395 User.setProperty("main_menu_message_id",null,"string");396 User.setProperty("pending_menu_message_id",null,"string");397 try {398 Api.sendMessage({chat_id:chat.chatid,text:verifySuccessText,parse_mode:"HTML",reply_markup:JSON.stringify({remove_keyboard:true})});399 } catch(verifySuccessErr) {400 __uiSend(verifySuccessText,{parse_mode:"HTML"});401 }402 try {403 var __pr = String(User.getProperty("pending_ref") || "");404 if (__pr && __pr !== userId && !Bot.getProperty("referred_by_" + userId)) {405 Bot.setProperty("referred_by_" + userId, __pr, "string");406 Bot.setProperty("referral_count_" + __pr, Number(Bot.getProperty("referral_count_" + __pr) || 0) + 1, "number");407 Bot.setProperty("active_referrals_" + __pr, Number(Bot.getProperty("active_referrals_" + __pr) || 0), "number");408 }409 User.setProperty("pending_ref", "", "string");410 } catch(__prErr) {}411 try { var __vm = __fjMissing(userId); if (__vm.length) { __fjScreen(__vm); return; } __awardRefPoints(userId); } catch(__vgErr) {}412 try { Bot.run({command:"/menu",run_after:3}); } catch(menuDelayErr) { try { Bot.runCommand("/menu"); } catch(menuErr2) {} }413 return;414 }415 if (msgText.toLowerCase().indexOf("/start ref_") === 0) {416 var refArg = msgText.substring(7).trim();417 if (/^ref_\d+$/.test(refArg)) {418 var refId = refArg.substring(4);419 if (refId !== userId) {420 if (verified) {421 if (!Bot.getProperty("referred_by_" + userId)) {422 Bot.setProperty("referred_by_" + userId, refId, "string");423 Bot.setProperty("referral_count_" + refId, Number(Bot.getProperty("referral_count_" + refId) || 0) + 1, "number");424 Bot.setProperty("active_referrals_" + refId, Number(Bot.getProperty("active_referrals_" + refId) || 0), "number");425 }426 } else { User.setProperty("pending_ref", refId, "string"); }427 }428 }429 if (!verified) {430 var vkR = {keyboard:[[{text:"\ud83d\udcf1 Verify Phone Number",request_contact:true}]],resize_keyboard:true,one_time_keyboard:true};431 var vpR = "\ud83c\udfea \u2501 <b>YAS\u0130N X\u0130T STORE</b> \u2501 \ud83c\udfea\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udc4b Welcome!\n\n\ud83d\udd12 <b>VERIFICATION REQUIRED</b>\n\nPlease verify your phone number to start.\n\n\ud83d\udc47 Tap the button below:";432 try {433 var vsR = Api.sendMessage({chat_id:chat.chatid,text:vpR,parse_mode:"HTML",reply_markup:JSON.stringify(vkR)});434 if (vsR && vsR.message_id) User.setProperty("verification_message_id",String(vsR.message_id),"string");435 } catch(vErrR) {}436 return;437 }438 if (!__fjGate()) return;439 sendMainMenu();440 return;441 }442 if (msgText.toLowerCase() === "/start" || callbackData === "/start") {443 var isAdminForMaint = __isAdminOrCo;444 if (Bot.getProperty("bot_maintenance_mode") === true && !isAdminForMaint) {445 var maintenanceText = String(Bot.getProperty("bot_maintenance_message") || "").trim() ||446 "🛠️ <b>YASİN XİT STORE is currently under maintenance.</b>\n\n" +447 "We're working on improvements and will be back shortly.\n" +448 "Please try again later — thanks for your patience! 🙏";449 try { Api.sendMessage({chat_id:chat.chatid,text:maintenanceText,parse_mode:"HTML"}); }450 catch (maintSendErr) { __uiSend(maintenanceText,{parse_mode:"HTML"}); }451 return;452 }453 if (!verified) {454 var verifyKeyboard={keyboard:[[{text:"📱 Verify Phone Number",request_contact:true}]],resize_keyboard:true,one_time_keyboard:true};455 var verifyPrompt="🏪 ━ <b>YASİN XİT STORE</b> ━ 🏪\n━━━━━━━━━━━━━━━━━━\n\n👋 Welcome!\n\n🔒 <b>VERIFICATION REQUIRED</b>\n━━━━━━━━━━━━━━━━━━\n\nPlease verify your phone number to start shopping.\n\n✅ <b>Why we need this:</b>\n• To secure your purchases\n• To deliver your keys\n• To protect your account\n\n👇 Tap the button below:";456 try {457 var verifySent = Api.sendMessage({chat_id:chat.chatid,text:verifyPrompt,parse_mode:"HTML",reply_markup:JSON.stringify(verifyKeyboard)});458 if (verifySent && verifySent.message_id) User.setProperty("verification_message_id",String(verifySent.message_id),"string");459 } catch(verifySendErr) {460 __uiSend("❌ <b>Could not open the verification screen.</b> Please type /start again.",{parse_mode:"HTML"});461 }462 return;463 }464 if (!__fjGate()) return;465 sendMainMenu();466 return;467 }468 var couponGenStep = User.getProperty("coupon_gen_step");469 var awaitingCouponFor = User.getProperty("awaiting_coupon_for");470 var keyDeliveryStateForGate = User.getProperty("key_delivery_step");471 var isAdminKeyDeliveryFlow = (__isAdminOrCo) && !!keyDeliveryStateForGate;472 var isAdminMidFlow = (__isAdminOrCo) && (currentStep || isAwaitingBroadcast || couponGenStep ||473 User.getProperty("addbal_step") || User.getProperty("rembal_step") || User.getProperty("checkbal_step") || isAdminKeyDeliveryFlow ||474 User.getProperty("add_admin_step") || User.getProperty("remove_admin_step") || User.getProperty("set_how_link_step"));475 var isUserMidFlow = !!awaitingCouponFor;476 if (User.getProperty("awaiting_custom_topup") === true && msgText && msgText.charAt(0) !== "/") {477 var customTopup = Number(String(msgText).trim().replace(",", "."));478 if (!isFinite(customTopup) || customTopup < 1 || customTopup > 50) {479 __uiSend("❌ <b>The amount must be between $1 and $50.</b>",{parse_mode:"HTML"});480 return;481 }482 User.setProperty("awaiting_custom_topup",false,"boolean");483 Bot.runCommand("/topupmethod binance " + String(Math.round(customTopup*100)/100));484 return;485 }486 var quickPlanStateRaw = User.getProperty("quick_plan_state");487 var quickPlanState = null;488 try { quickPlanState = quickPlanStateRaw ? JSON.parse(quickPlanStateRaw) : null; } catch(qpsErr) { quickPlanState = null; }489 if ((__isAdminOrCo) && quickPlanState && msgText && msgText.charAt(0) !== "/" && quickPlanState.step === "price") {490 var enteredPlanPrice = Number(String(msgText).trim().replace(",", "."));491 if (!isFinite(enteredPlanPrice) || enteredPlanPrice < 0) { __uiSend("❌ Invalid price. Type something like <code>100</code>.",{parse_mode:"HTML"}); return; }492 var qProducts = Bot.getProperty("stored_products") || [], qIdx = Number(quickPlanState.product_index);493 if (!Array.isArray(qProducts) || !qProducts[qIdx]) { User.setProperty("quick_plan_state",null,"string"); __uiSend("❌ Product not found."); return; }494 var qProduct=qProducts[qIdx]; if(!Array.isArray(qProduct.plans))qProduct.plans=[];495 var qDays=String(quickPlanState.days), qUnit=String(quickPlanState.unit||"day"), qPlanIndex=-1;496 for(var qpi=0;qpi<qProduct.plans.length;qpi++) if(String(qProduct.plans[qpi].days)===qDays&&String(qProduct.plans[qpi].unit||"day")===qUnit){qPlanIndex=qpi;break;}497 var qDuration=String(quickPlanState.durationDisplay||(qUnit==="hour"?qDays+" Hours":(qDays==="30"?"1 Month":qDays+" Days")));498 if(qPlanIndex<0){qProduct.plans.push({days:qDays,unit:qUnit,durationDisplay:qDuration,normal_price:enteredPlanPrice,reseller_price:enteredPlanPrice,stock_count:0,emoji_id:null});qPlanIndex=qProduct.plans.length-1;}499 else {qProduct.plans[qPlanIndex].normal_price=enteredPlanPrice;if(qProduct.plans[qPlanIndex].reseller_price==null)qProduct.plans[qPlanIndex].reseller_price=enteredPlanPrice;qProduct.plans[qPlanIndex].durationDisplay=qDuration;qProduct.plans[qPlanIndex].unit=qUnit;if(qProduct.plans[qPlanIndex].stock_count==null)qProduct.plans[qPlanIndex].stock_count=0;}500 Bot.setProperty("stored_products",qProducts,"json");501 Bot.setProperty("price_normal_"+String(qProduct.name).toUpperCase()+"_"+qDays+"_"+qUnit,enteredPlanPrice,"number");502 User.setProperty("quick_plan_state",null,"string");503 __uiSend("<blockquote>🛒 <b>PLAN ADDED</b></blockquote>\n\n📦 <b>Product:</b> "+qProduct.name+"\n🗓 <b>Duration:</b> "+qDuration+"\n💰 <b>Price:</b> $"+enteredPlanPrice.toFixed(2)+"\n📦 <b>Stock:</b> "+Number(qProduct.plans[qPlanIndex].stock_count||0),{parse_mode:"HTML"});504 return;505 }506 var supportState=String(User.getProperty("support_state")||"");507 if (supportState && msgText && msgText.charAt(0)!=="/") {508 var supportMid=Number(User.getProperty("support_message_id")||0);509 function editSupport(text,markup){510 if(supportMid){511 try{512 __swfEditMessage({chat_id:chat.chatid,message_id:supportMid,text:text,parse_mode:"HTML",reply_markup:markup?JSON.stringify(markup):undefined});513 return true;514 }catch(eEdit){}515 }516 try{__uiSend(text,{parse_mode:"HTML",reply_markup:markup?JSON.stringify(markup):undefined});}catch(eSend){}517 return false;518 }519 if(supportState==="waiting_id"){520 var tx=String(msgText).trim();521 if(/^(skip|-|none|yok)$/i.test(tx)){522 User.setProperty("support_state","waiting_issue","string");523 User.setProperty("support_transaction_id","","string");524 editSupport("🎫 <b>SUPPORT TICKET</b>\n\n🧾 Transaction ID: <i>none</i>\n\n📝 <b>Describe your issue.</b>\nPlease describe the problem you are having in detail.",{inline_keyboard:[[{text:"❌ Cancel",callback_data:"/support"}]]});525 return;526 }527 if(!/^(ORD|DEP)_[A-Za-z0-9_]+$/i.test(tx)){528 editSupport("❌ <b>Invalid transaction ID.</b>\n\nExample:\n<code>ORD_1234567890</code>\n<code>DEP_1234567890</code>\n\n⏭️ <i>No order? Tap Skip.</i>",{inline_keyboard:[[{text:"⏭️ Skip",callback_data:"/support_skip"}],[{text:"🔙 Support",callback_data:"/support"}]]});529 return;530 }531 var txRec=null, txType=tx.toUpperCase().indexOf("ORD_")===0?"order":"deposit";532 if(txType==="order") txRec=Bot.getProperty("order_"+tx)||Bot.getProperty("manual_order_"+tx);533 else txRec=Bot.getProperty("manual_payment_"+tx);534 if(!txRec || String(txRec.user_id)!==String(userId)){535 editSupport("❌ <b>Transaction not found.</b>\n\nThis transaction ID does not match your account.",{inline_keyboard:[[{text:"🔙 Support",callback_data:"/support"}]]});536 return;537 }538 User.setProperty("support_state","waiting_issue","string");539 User.setProperty("support_transaction_id",tx,"string");540 editSupport(541 "🎫 <b>SUPPORT TICKET</b>\n\n"+542 "🧾 Transaction ID: <code>"+tx+"</code>\n\n"+543 "📝 <b>Describe your issue.</b>\n"+544 "Please describe the problem you are having in detail.",545 {inline_keyboard:[[{text:"❌ Cancel",callback_data:"/support"}]]}546 );547 return;548 }549 if(supportState==="waiting_issue"){550 var issue=String(msgText).trim();551 if(issue.length<3){552 editSupport("❌ <b>Please describe your issue in a little more detail.</b>",{inline_keyboard:[[{text:"❌ Cancel",callback_data:"/support"}]]});553 return;554 }555 var ticketId="TCK_"+Date.now()+"_"+Math.floor(Math.random()*10000);556 var ticketNo=Number(Bot.getProperty("ticket_counter")||0)+1;557 Bot.setProperty("ticket_counter",ticketNo,"number");558 var ticket={559 id:ticketId,560 ticket_no:ticketNo,561 user_id:String(userId),562 name:((user.first_name||"")+(user.last_name?" "+user.last_name:"")).trim()||"User",563 username:user.username?String(user.username):"None",564 transaction_id:String(User.getProperty("support_transaction_id")||""),565 issue:issue,566 messages:[{sender:"user",text:issue,created_at:new Date().toISOString()}],567 status:"Open",568 created_at:new Date().toISOString()569 };570 var tickets=Bot.getProperty("all_support_tickets")||[]; if(Array.isArray(tickets))tickets=tickets.slice(); if(!Array.isArray(tickets)) tickets=[];571 if(!Array.isArray(tickets))tickets=[];572 tickets.push(ticket);573 Bot.setProperty("all_support_tickets",tickets,"json");574 var myTickets=User.getProperty("support_tickets")||[]; if(!Array.isArray(myTickets)) myTickets=[];575 myTickets.push({id:ticketId,status:ticket.status,created_at:ticket.created_at,text:issue,transaction_id:ticket.transaction_id});576 if(myTickets.length>50) myTickets=myTickets.slice(-50);577 User.setProperty("support_tickets",myTickets,"json");578 var owner=adminId;579 try{580 Api.sendMessage({chat_id:owner,text:581 "🎫 <b>NEW SUPPORT TICKET</b>\n\n"+582 "🆔 Ticket: <code>"+ticketId+"</code>\n"+583 "👤 User: "+ticket.name+" "+ticket.username+"\n"+584 "🆔 User ID: <code>"+userId+"</code>\n"+585 "🧾 Transaction ID: <code>"+ticket.transaction_id+"</code>\n\n"+586 "📝 "+issue,parse_mode:"HTML"});587 }catch(eAdminSupport){}588 User.setProperty("support_state","","string");589 User.setProperty("support_message_id",0,"number");590 User.setProperty("support_transaction_id","","string");591 editSupport(592 "✅ <b>SUPPORT TICKET CREATED</b>\n\n"+593 "🆔 Ticket ID: <code>"+ticketId+"</code>\n"+594 "🧾 Transaction ID: <code>"+ticket.transaction_id+"</code>\n\n"+595 "📨 Your ticket has been forwarded to the administrator.",596 {inline_keyboard:[[{text:"🔙 Main Menu",callback_data:"/back"}]]}597 );598 return;599 }600 }601 var updatePriceStateRaw = User.getProperty("update_price_state");602 if ((__isAdminOrCo) && updatePriceStateRaw && msgText && msgText.charAt(0) !== "/") {603 var ups = null;604 try { ups = JSON.parse(updatePriceStateRaw); } catch(eUps) { ups = null; }605 var newPrice = Number(String(msgText).trim().replace(",", "."));606 if (!ups || !isFinite(newPrice) || newPrice <= 0) {607 __uiSend("❌ Invalid price. Type something like <code>250</code>.",{parse_mode:"HTML"});608 return;609 }610 var upProducts=Bot.getProperty("stored_products")||[]; if(!Array.isArray(upProducts)) upProducts=[];611 var upProduct=upProducts[Number(ups.product_index)];612 var upPlan=upProduct&&upProduct.plans?upProduct.plans[Number(ups.plan_index)]:null;613 if(!upProduct||!upPlan){User.setProperty("update_price_state",null,"string");__uiSend("❌ Product or plan not found.");return;}614 var __oldNormal = Number(upPlan.normal_price != null ? upPlan.normal_price : (upPlan.price || 0));615 var __oldReseller = (upPlan.reseller_price == null) ? null : Number(upPlan.reseller_price);616 upPlan.normal_price = newPrice;617 if (__oldReseller == null || !isFinite(__oldReseller)) upPlan.reseller_price = newPrice;618 else if (__oldNormal > 0 && __oldReseller < __oldNormal) {619 upPlan.reseller_price = Number((newPrice * (__oldReseller / __oldNormal)).toFixed(2));620 } else if (__oldReseller > newPrice) upPlan.reseller_price = newPrice;621 upProducts[Number(ups.product_index)]=upProduct;622 Bot.setProperty("stored_products",upProducts,"json");623 try {624 var __upName = String(upProduct.name).toUpperCase();625 var __upDays = String(upPlan.days);626 var __upUnit = String(upPlan.unit || "day");627 Bot.setProperty("price_normal_"+__upName+"_"+__upDays+"_"+__upUnit, newPrice, "number");628 Bot.setProperty("price_reseller_"+__upName+"_"+__upDays+"_"+__upUnit, Number(upPlan.reseller_price), "number");629 Bot.setProperty("price_normal_"+__upName+"_"+__upDays, newPrice, "number");630 Bot.setProperty("price_reseller_"+__upName+"_"+__upDays, Number(upPlan.reseller_price), "number");631 } catch(__upErr) {}632 User.setProperty("update_price_state",null,"string");633 __uiSend("✅ <b>Price Updated!</b>\n\n🎮 <b>Game:</b> "+__esc(upProduct.name)+"\n⏳ <b>Duration:</b> "+__esc(String(upPlan.durationDisplay||upPlan.days+" Days"))+"\n💰 <b>Price:</b> $"+newPrice.toFixed(2)+"\n🔰 <b>Reseller:</b> $"+Number(upPlan.reseller_price||newPrice).toFixed(2),{parse_mode:"HTML"});634 return;635 }636 if ((__isAdminOrCo) && msgText && msgText.charAt(0) !== "/") {637 var __apsRaw = User.getProperty("awaiting_plan_stock");638 if (__apsRaw) {639 var __aps = null; try { __aps = (typeof __apsRaw === "string") ? JSON.parse(__apsRaw) : __apsRaw; } catch(__e){ __aps = null; }640 if (__aps) {641 User.setProperty("awaiting_plan_stock", "", "string");642 var __prods = Bot.getProperty("stored_products") || []; if(!Array.isArray(__prods)) __prods = [];643 var __pr = __prods[Number(__aps.product_index)];644 var __pl = (__pr && Array.isArray(__pr.plans)) ? __pr.plans[Number(__aps.plan_index)] : null;645 if (!__pr || !__pl) { __uiSend("❌ <b>Product or plan no longer exists.</b>", {parse_mode:"HTML"}); return; }646 var __before = Number(__pl.stock_count || 0);647 var __isQty = /^[0-9]{1,6}$/.test(msgText.trim());648 var __mode = "", __added = 0;649 if (__isQty) {650 __added = Number(msgText.trim());651 __pl.stock_count = __before + __added;652 __mode = "Quantity";653 } else {654 var __lines = String(msgText).split(/\r?\n/).map(function(x){return x.trim();}).filter(function(x){return x.length>0;});655 if (!__lines.length) { __uiSend("❌ Send a quantity (e.g. <code>5</code>) or paste your keys, one per line.", {parse_mode:"HTML"}); return; }656 var __nameU = String(__pr.name).trim().toUpperCase();657 var __days = String(__aps.days), __unit = String(__aps.unit || "day");658 var __sk = "manual_keys_" + __nameU + "_" + __days + "_" + __unit;659 var __ex = Bot.getProperty(__sk);660 if (typeof __ex === "string") { try { __ex = JSON.parse(__ex); } catch(__e2){ __ex = __ex.split(/\r?\n/).filter(Boolean); } }661 __ex = Array.isArray(__ex) ? __ex.slice() : [];662 var __seen = {}; for (var __i=0; __i<__ex.length; __i++) __seen[String(__ex[__i])] = true;663 for (var __j=0; __j<__lines.length; __j++) { if(!__seen[__lines[__j]]) { __ex.push(__lines[__j]); __seen[__lines[__j]] = true; __added++; } }664 Bot.setProperty(__sk, __ex, "json");665 if (__unit === "day") Bot.setProperty("manual_keys_" + __nameU + "_" + __days, __ex, "json");666 Bot.setProperty("stock_" + Number(__aps.product_index) + "_" + Number(__aps.plan_index), __ex, "json");667 Bot.setProperty("stock_" + String(__pr.name).trim() + "_" + __days + "_" + (__unit==="hour"?"Hour":__unit==="minute"?"Minute":"Day"), __ex, "json");668 __pl.stock_count = __ex.length;669 __mode = "Keys";670 }671 __prods[Number(__aps.product_index)] = __pr;672 Bot.setProperty("stored_products", __prods, "json");673 __uiSend("<blockquote>✅ <b>STOCK UPDATED</b></blockquote>\n\n🛒 <b>Product:</b> " + __esc(__pr.name) +674 "\n🗓 <b>Duration:</b> " + __esc(__pl.durationDisplay || (__aps.days + " " + __aps.unit)) +675 "\n➡ <b>Mode:</b> " + __mode +676 "\n➡ <b>Added:</b> " + __added +677 "\n➡ <b>Total stock:</b> " + Number(__pl.stock_count || 0),678 {parse_mode:"HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"📦 Stock Menu",callback_data:"/addstock"}],[{text:"⬅️ Admin",callback_data:"/admin"}]]})});679 return;680 }681 }682 var __apsdRaw = User.getProperty("awaiting_plan_stock_delete");683 if (__apsdRaw) {684 var __apsd = null; try { __apsd = (typeof __apsdRaw === "string") ? JSON.parse(__apsdRaw) : __apsdRaw; } catch(__e3){ __apsd = null; }685 if (__apsd) {686 User.setProperty("awaiting_plan_stock_delete", "", "string");687 var __dp = Bot.getProperty("stored_products") || []; if(!Array.isArray(__dp)) __dp = [];688 var __dpr = __dp[Number(__apsd.product_index)];689 var __dpi = -1;690 if (__dpr && Array.isArray(__dpr.plans)) {691 for (var __k=0; __k<__dpr.plans.length; __k++) {692 if (String(__dpr.plans[__k].days) === String(__apsd.plan_days) && String(__dpr.plans[__k].unit || "day") === String(__apsd.unit || "day")) { __dpi = __k; break; }693 }694 }695 if (__dpi < 0) { __uiSend("❌ <b>Plan no longer exists.</b>", {parse_mode:"HTML"}); return; }696 var __dpl = __dpr.plans[__dpi];697 var __have = Number(__dpl.stock_count || 0);698 if (!/^[0-9]{1,6}$/.test(msgText.trim())) { __uiSend("❌ Send how many units to remove. Example: <code>5</code>", {parse_mode:"HTML"}); return; }699 var __rem = Number(msgText.trim());700 if (__rem > __have) __rem = __have;701 __dpl.stock_count = __have - __rem;702 var __dnameU = String(__dpr.name).trim().toUpperCase();703 var __dsk = "manual_keys_" + __dnameU + "_" + String(__apsd.plan_days) + "_" + String(__apsd.unit || "day");704 var __dex = Bot.getProperty(__dsk);705 if (typeof __dex === "string") { try { __dex = JSON.parse(__dex); } catch(__e4){ __dex = __dex.split(/\r?\n/).filter(Boolean); } }706 if (Array.isArray(__dex) && __dex.length) {707 __dex = __dex.slice(0, Math.max(0, __dex.length - __rem));708 Bot.setProperty(__dsk, __dex, "json");709 if (String(__apsd.unit || "day") === "day") Bot.setProperty("manual_keys_" + __dnameU + "_" + String(__apsd.plan_days), __dex, "json");710 Bot.setProperty("stock_" + Number(__apsd.product_index) + "_" + __dpi, __dex, "json");711 __dpl.stock_count = __dex.length;712 }713 __dp[Number(__apsd.product_index)] = __dpr;714 Bot.setProperty("stored_products", __dp, "json");715 __uiSend("<blockquote>🗑 <b>STOCK REMOVED</b></blockquote>\n\n🛒 <b>Product:</b> " + __esc(__dpr.name) +716 "\n🗓 <b>Duration:</b> " + __esc(__dpl.durationDisplay || (__apsd.plan_days + " " + (__apsd.unit || "day"))) +717 "\n➡ <b>Removed:</b> " + __rem +718 "\n➡ <b>Remaining:</b> " + Number(__dpl.stock_count || 0),719 {parse_mode:"HTML", reply_markup: JSON.stringify({inline_keyboard:[[{text:"📦 Stock Menu",callback_data:"/remstock"}],[{text:"⬅️ Admin",callback_data:"/admin"}]]})});720 return;721 }722 }723 }724 if ((__isAdminOrCo) && currentStep) {725 if (currentStep === "waiting_for_name") {726 if (!msgText || msgText.charAt(0)==="/") { __uiSend("❌ Send a valid product name."); return; }727 User.setProperty("temp_product_name",msgText.trim(),"string");728 User.setProperty("add_product_step","waiting_for_duration","string");729 __uiSend("⏱️ <b>Send the product duration.</b>\n\nExample: <code>1h</code> = 1 hour\n<code>1d</code> = 1 day\n<code>80d</code> = 80 days\n\nUse <code>h</code> for hours and <code>d</code> for days.",{parse_mode:"HTML"}); return;730 }731 if (currentStep === "waiting_for_duration") {732 var ds=msgText.trim().toLowerCase();733 var dm=ds.match(/^(\d+)\s*(h|hr|hour|hours|saat|d|day|days|gün)$/i);734 if(!dm || Number(dm[1])<1){__uiSend("❌ Invalid duration. Example: <code>1h</code>, <code>1 hour</code>, <code>1d</code>, <code>1 day</code>, <code>80d</code>",{parse_mode:"HTML"});return;}735 var dnum=Number(dm[1]), dunit=/^(h|hr|hour|hours|saat)$/i.test(dm[2])?"h":"d";736 User.setProperty("temp_duration_value",String(dnum),"string");737 User.setProperty("temp_duration_unit",dunit==="h"?"hour":"day","string");738 User.setProperty("temp_duration_display",dunit==="h"?(dnum+" Hours"):(dnum+" Days"),"string");739 User.setProperty("add_product_step","waiting_for_price","string");740 __uiSend("💰 <b>Send the price of this plan in USD.</b>\n\nExample: <code>100</code>",{parse_mode:"HTML"}); return;741 }742 if (currentStep === "waiting_for_price") {743 var pr=Number(String(msgText).trim().replace(",",".")); 744 if(!isFinite(pr)||pr<=0){__uiSend("❌ Invalid price. Example: <code>100</code>",{parse_mode:"HTML"});return;}745 User.setProperty("temp_price",String(pr),"string");746 User.setProperty("add_product_step","waiting_for_reseller_price","string");747 var __apPct=Number(Bot.getProperty("reseller_discount_pct")); if(!isFinite(__apPct)||__apPct<0||__apPct>90) __apPct=20;748 __uiSend("🔰 <b>Send the reseller price.</b>\n\n💰 <b>Normal:</b> $"+pr.toFixed(2)+"\n🔰 <b>Auto (-"+__apPct+"%):</b> $"+(pr*(1-__apPct/100)).toFixed(2)+"\n\n➡ Send a number for a custom price\n➡ Or send <code>auto</code> to use -"+__apPct+"%",{parse_mode:"HTML"}); return;749 }750 if (currentStep === "waiting_for_reseller_price") {751 var __rpRaw=String(msgText||"").trim().toLowerCase().replace(",",".");752 var __rpNormal=Number(User.getProperty("temp_price")||0);753 var __rpPct=Number(Bot.getProperty("reseller_discount_pct")); if(!isFinite(__rpPct)||__rpPct<0||__rpPct>90) __rpPct=20;754 var __rpVal;755 if(__rpRaw==="auto"||__rpRaw==="") __rpVal=Number((__rpNormal*(1-__rpPct/100)).toFixed(2));756 else { __rpVal=Number(__rpRaw); if(!isFinite(__rpVal)||__rpVal<=0){__uiSend("❌ Send a price like <code>2.50</code>, or <code>auto</code>.",{parse_mode:"HTML"});return;} }757 if(__rpVal>__rpNormal){__uiSend("❌ The reseller price cannot be higher than the normal price ($"+__rpNormal.toFixed(2)+").",{parse_mode:"HTML"});return;}758 User.setProperty("temp_reseller_price",String(__rpVal),"string");759 User.setProperty("add_product_step","waiting_for_stock","string");760 __uiSend("📦 <b>Send the stock.</b>\n\n➡ Quantity: <code>10</code>\n➡ Or paste your keys, one per line",{parse_mode:"HTML"}); return;761 }762 if (currentStep === "waiting_for_stock") {763 var __wsRaw = String(msgText == null ? "" : msgText).trim();764 var __wsKeys = null, st = 0;765 if (/^[0-9]{1,6}$/.test(__wsRaw)) { st = Number(__wsRaw); }766 else {767 __wsKeys = __wsRaw.split(/\r?\n/).map(function(x){return x.trim();}).filter(function(x){return x.length>0;});768 var __wsSeen={}, __wsOut=[];769 for(var __w=0;__w<__wsKeys.length;__w++){ if(!__wsSeen[__wsKeys[__w]]){__wsSeen[__wsKeys[__w]]=true;__wsOut.push(__wsKeys[__w]);} }770 __wsKeys = __wsOut; st = __wsKeys.length;771 }772 if(!isFinite(st)||st<0){__uiSend("❌ Send a quantity (e.g. <code>10</code>) or paste your keys, one per line.",{parse_mode:"HTML"});return;}773 var products=Bot.getProperty("stored_products")||[]; if(!Array.isArray(products)) products=[];774 var pname=User.getProperty("temp_product_name")||"";775 var durv=String(User.getProperty("temp_duration_value")||"1"), unit=String(User.getProperty("temp_duration_unit")||"day"), disp=String(User.getProperty("temp_duration_display")||durv+" Days"), price=Number(User.getProperty("temp_price")||0);776 var idx=-1; for(var pi=0;pi<products.length;pi++){if(String(products[pi].name||"").trim().toLowerCase()===pname.trim().toLowerCase()){idx=pi;break;}}777 if(idx<0){products.push({name:pname,plans:[]});idx=products.length-1;}778 if(!Array.isArray(products[idx].plans))products[idx].plans=[];779 var planIdx=-1; for(var pj=0;pj<products[idx].plans.length;pj++){var q=products[idx].plans[pj];if(String(q.days)===durv&&String(q.unit||"day")===unit){planIdx=pj;break;}}780 var __planRes=Number(User.getProperty("temp_reseller_price"));781 if(!isFinite(__planRes)||__planRes<=0||__planRes>price){var __dpc=Number(Bot.getProperty("reseller_discount_pct"));if(!isFinite(__dpc)||__dpc<0||__dpc>90)__dpc=20;__planRes=Number((price*(1-__dpc/100)).toFixed(2));}782 var planObj={days:durv,unit:unit,durationDisplay:disp,normal_price:price,reseller_price:__planRes,stock_count:st};783 if(planIdx<0)products[idx].plans.push(planObj);else products[idx].plans[planIdx]=planObj;784 Bot.setProperty("stored_products",products,"json");785 if (__wsKeys && __wsKeys.length) {786 var __wsIdx = (planIdx<0) ? (products[idx].plans.length-1) : planIdx;787 var __wsNameU = String(pname).trim().toUpperCase();788 Bot.setProperty("manual_keys_"+__wsNameU+"_"+durv+"_"+unit, __wsKeys, "json");789 if (unit === "day") Bot.setProperty("manual_keys_"+__wsNameU+"_"+durv, __wsKeys, "json");790 Bot.setProperty("stock_"+idx+"_"+__wsIdx, __wsKeys, "json");791 Bot.setProperty("stock_"+String(pname).trim()+"_"+durv+"_"+(unit==="hour"?"Hour":unit==="minute"?"Minute":"Day"), __wsKeys, "json");792 }793 try {794 var __apNameU=String(pname).trim().toUpperCase();795 Bot.setProperty("price_normal_"+__apNameU+"_"+durv+"_"+unit,price,"number");796 Bot.setProperty("price_reseller_"+__apNameU+"_"+durv+"_"+unit,__planRes,"number");797 } catch(__apPErr) {}798 User.setProperty("add_product_step",null,"string"); User.setProperty("temp_product_name",null,"string"); User.setProperty("temp_duration_value",null,"string"); User.setProperty("temp_duration_unit",null,"string"); User.setProperty("temp_duration_display",null,"string"); User.setProperty("temp_price",null,"string"); User.setProperty("temp_reseller_price",null,"string");799 __uiSend("✅ <b>PRODUCT PLAN ADDED</b>\n━━━━━━━━━━━━━━━━━━\n📦 Product: <b>"+pname+"</b>\n⏱️ Duration: <b>"+disp+"</b>\n💰 Price: <b>$"+price.toFixed(2)+"</b>\n👑 Reseller: <b>$"+__planRes.toFixed(2)+"</b>\n📦 Stock: <b>"+st+(__wsKeys?" keys":" pcs")+"</b>",{parse_mode:"HTML"}); return;800 }801 }802 if (__isAdminOrCo) {803 var addbalStep = User.getProperty("addbal_step");804 var rembalStep = User.getProperty("rembal_step");805 var checkbalStep = User.getProperty("checkbal_step");806 if (addbalStep === "waiting_input" && msgText) {807 var addParts = msgText.trim().split("|");808 if (addParts.length !== 2 || isNaN(Number(addParts[1])) || Number(addParts[1]) <= 0) {809 __uiSend("❌ Format: <code>UserID|Amount</code>",{parse_mode:"HTML"}); return;810 }811 var addUid = addParts[0].trim(), addAmount = Number(addParts[1]);812 try {813 var addRes = Libs.ResourcesLib.anotherUserRes("balance", addUid); addRes.add(addAmount);814 var addRemaining=Number(addRes.value()||0), addPaymentMethod="USDT";815 var addTransactionId="DEP_"+Date.now()+"_"+Math.floor(Math.random()*10000);816 var addInvestorName="User";817 try { var addRecords=Bot.getProperty("all_users_records")||[]; if(Array.isArray(addRecords)) for(var ari=0;ari<addRecords.length;ari++) if(String(addRecords[ari].id)===String(addUid)){ addInvestorName=String(addRecords[ari].name||addInvestorName); break; } } catch(addNameErr) {}818 Bot.setProperty("total_deposit_by_"+addUid, Number(Bot.getProperty("total_deposit_by_"+addUid)||0)+addAmount, "number");819 try {820 if (Bot.getProperty("is_reseller_"+addUid) !== true) {821 var __abMin = Number(Bot.getProperty("reseller_min_spend")); if(!isFinite(__abMin)||__abMin<=0) __abMin=5;822 var __abDep = Number(Bot.getProperty("total_deposit_by_"+addUid)||0);823 if (__abDep >= __abMin) {824 var __abPct = Number(Bot.getProperty("reseller_discount_pct")); if(!isFinite(__abPct)||__abPct<0||__abPct>90) __abPct=20;825 Bot.setProperty("is_reseller_"+addUid, true, "boolean");826 Bot.setProperty("reseller_since_"+addUid, new Date().toISOString(), "string");827 var __abList = Bot.getProperty("reseller_ids")||[]; if(Array.isArray(__abList))__abList=__abList.slice(); if(!Array.isArray(__abList))__abList=[];828 if(__abList.indexOf(String(addUid))<0){__abList.push(String(addUid));Bot.setProperty("reseller_ids",__abList,"json");}829 try { Api.sendMessage({chat_id: addUid, parse_mode:"HTML", text:"\uD83C\uDF89 <b>Reseller Unlocked!</b>\n\n\uD83D\uDCB5 <b>Total deposited:</b> $"+__abDep.toFixed(2)+"\n\uD83C\uDFF7 <b>Your discount:</b> -"+__abPct+"% on every product\n\n\uD83D\uDE4F Open Reseller Dashboard from the main menu."}); } catch(__abE){}830 }831 }832 } catch(__abErr) {}833 User.setProperty("addbal_step", null, "string");834 __uiSend("✅ <b>Balance added.</b>\n\n👤 ID: <code>"+addUid+"</code>\n💰 Amount: <b>$"+addAmount.toFixed(2)+"</b>",{parse_mode:"HTML"});835 Api.sendMessage({chat_id:addUid,text:"💰 <b>Balance credited to your account.</b>\n\n➕ Amount: <b>$"+addAmount.toFixed(2)+"</b>\n💳 New balance: <b>$"+addRemaining.toFixed(2)+"</b>",parse_mode:"HTML"});836 var balanceLogId=Bot.getProperty("log_channel_id");837 if(balanceLogId) { try { Api.sendMessage({chat_id:balanceLogId,text:838 "💵 <b>[ NEW DEPOSIT RECEIVED ]</b> 💵\n\n"+839 "👤 <b>Depositor:</b> "+__esc(addInvestorName)+"\n"+840 "🆔 <b>Depositor Chat ID:</b> "+String(addUid)+"\n"+841 "💰 <b>Amount:</b> $"+addAmount.toFixed(2)+"\n"+842 "💳 <b>Transaction ID:</b> "+addTransactionId+"\n\n"+843 "✅ <b>Wallet Balance Updated Successfully!</b>\n\n"+844 "📢 @"+String(Bot.getProperty("bot_username")||"Yasin_Xit_Shop_bot"),parse_mode:"HTML"}); } catch(logSendErr) { try{Api.sendMessage({chat_id:String(adminId),text:"\u26A0\uFE0F Log channel delivery failed. Check it with /logtest."});}catch(dbgErr){} } }845 } catch(e) { __uiSend("⚠️ Could not add balance: "+e.message); }846 return;847 }848 if (rembalStep === "waiting_input" && msgText) {849 var remParts = msgText.trim().split("|");850 if (remParts.length !== 2 || isNaN(Number(remParts[1])) || Number(remParts[1]) <= 0) {851 __uiSend("❌ Format: <code>UserID|Amount</code>",{parse_mode:"HTML"}); return;852 }853 var remUid = remParts[0].trim(), remAmount = Number(remParts[1]);854 try {855 var remRes = Libs.ResourcesLib.anotherUserRes("balance", remUid);856 var currentRem = Number(remRes.value()) || 0;857 var actualRem = Math.min(currentRem, remAmount);858 remRes.remove(actualRem);859 User.setProperty("rembal_step", null, "string");860 __uiSend("✅ <b>Balance removed.</b>\n\n👤 ID: <code>"+remUid+"</code>\n➖ Amount: <b>$"+actualRem.toFixed(2)+"</b>",{parse_mode:"HTML"});861 Api.sendMessage({chat_id:remUid,text:"⚠️ <b>An amount was deducted from your balance.</b>\n\n➖ Amount: <b>$"+actualRem.toFixed(2)+"</b>\n💳 New balance: <b>$"+Number(remRes.value()).toFixed(2)+"</b>",parse_mode:"HTML"});862 } catch(e) { __uiSend("⚠️ Could not remove balance: "+e.message); }863 return;864 }865 if (checkbalStep === "waiting_input" && msgText) {866 var checkUid = msgText.trim();867 if (!/^\d+$/.test(checkUid)) { __uiSend("❌ Send a valid user ID."); return; }868 User.setProperty("checkbal_step", null, "string");869 var checkRes = Number(Libs.ResourcesLib.anotherUserRes("balance",checkUid).value()) || 0;870 __uiSend("💳 <b>User Balance</b>\n\n🆔 <code>"+checkUid+"</code>\n💰 <b>$"+checkRes.toFixed(2)+"</b>",{parse_mode:"HTML"});871 return;872 }873 }874 if (userId === adminId) {875 var addAdminStep = User.getProperty("add_admin_step");876 var removeAdminStep = User.getProperty("remove_admin_step");877 var manageAdminBackKb = JSON.stringify({inline_keyboard:[[{text:"🔙 Manage Admins",callback_data:"/manage_coadmin"}]]});878 if (addAdminStep === "waiting_input" && msgText) {879 var newAdminId = msgText.trim();880 if (!/^\d+$/.test(newAdminId)) { __uiSend("❌ Send a valid numeric user ID.",{parse_mode:"HTML"}); return; }881 User.setProperty("add_admin_step", null, "string");882 if (newAdminId === adminId) { __uiSend("❌ The owner cannot be made a co-admin!",{parse_mode:"HTML",reply_markup:manageAdminBackKb}); return; }883 var addAdminList = Bot.getProperty("co_admin_list") || []; if(Array.isArray(addAdminList))addAdminList=addAdminList.slice(); if (!Array.isArray(addAdminList)) addAdminList = [];884 Bot.setProperty("co_admin_" + newAdminId, true, "boolean");885 if (addAdminList.indexOf(newAdminId) === -1) { addAdminList.push(newAdminId); Bot.setProperty("co_admin_list", addAdminList, "json"); }886 __uiSend("✅ <b>Co-admin added!</b>\n\n👤 User <code>"+newAdminId+"</code> now has full admin panel access.",{parse_mode:"HTML",reply_markup:manageAdminBackKb});887 try { Api.sendMessage({chat_id:newAdminId,text:"<blockquote>👑 <b>YOU ARE NOW A CO-ADMIN!</b></blockquote>\n\n<i>You have been granted full access to this store's admin panel. Use the /admin command to open it.</i>",parse_mode:"HTML"}); } catch (addAdminNotifyErr) {}888 return;889 }890 if (removeAdminStep === "waiting_input" && msgText) {891 var oldAdminId = msgText.trim();892 if (!/^\d+$/.test(oldAdminId)) { __uiSend("❌ Send a valid numeric user ID.",{parse_mode:"HTML"}); return; }893 User.setProperty("remove_admin_step", null, "string");894 var remAdminList = Bot.getProperty("co_admin_list") || []; if(Array.isArray(remAdminList))remAdminList=remAdminList.slice(); if (!Array.isArray(remAdminList)) remAdminList = [];895 Bot.setProperty("co_admin_" + oldAdminId, null, "boolean");896 var remAdminIdx = remAdminList.indexOf(oldAdminId);897 if (remAdminIdx > -1) { remAdminList.splice(remAdminIdx, 1); Bot.setProperty("co_admin_list", remAdminList, "json"); }898 __uiSend("✅ <b>Co-admin removed!</b>\n\n👤 User <code>"+oldAdminId+"</code> no longer has admin access.",{parse_mode:"HTML",reply_markup:manageAdminBackKb});899 try { Api.sendMessage({chat_id:oldAdminId,text:"⚠️ <b>Your co-admin access has been revoked.</b>",parse_mode:"HTML"}); } catch (remAdminNotifyErr) {}900 return;901 }902 }903 if (__isAdminOrCo) {904 var setHowLinkStep = User.getProperty("set_how_link_step");905 var howLinkBackKb = JSON.stringify({inline_keyboard:[[{text:"🔙 Admin Panel",callback_data:"/admin"}]]});906 if (setHowLinkStep === "waiting_input" && msgText) {907 var newHowLink = msgText.trim();908 if (!/^https?:\/\//i.test(newHowLink)) { __uiSend("❌ The link must start with http:// or https://",{parse_mode:"HTML",reply_markup:howLinkBackKb}); return; }909 Bot.setProperty("how_to_video_link", newHowLink, "string");910 User.setProperty("set_how_link_step", null, "string");911 __uiSend("✅ <b>How-To video link updated!</b>\n\n"+newHowLink,{parse_mode:"HTML",reply_markup:howLinkBackKb});912 return;913 }914 }915 if ((__isAdminOrCo) && couponGenStep) {916 if (couponGenStep === "code") {917 if (!msgText) { __uiSend("⚠️ Please send a valid coupon code."); return; }918 var couponCodeUpper = msgText.trim().toUpperCase();919 if (Bot.getProperty("coupon_" + couponCodeUpper)) {920 __uiSend("❌ This coupon code already exists! Please choose a different name.");921 return;922 }923 User.setProperty("coupon_gen_code", couponCodeUpper, "string");924 User.setProperty("coupon_gen_step", "maxclaims", "string");925 __uiSend("👥 <b>How many users can claim this coupon?</b>\n<i>Send a number only, for example: 50</i>", { parse_mode: "HTML" });926 return;927 }928 if (couponGenStep === "maxclaims") {929 var maxClaimsVal = parseInt(msgText.trim());930 if (isNaN(maxClaimsVal) || maxClaimsVal <= 0) { __uiSend("❌ Please send a valid number (example: 50)."); return; }931 User.setProperty("coupon_gen_maxclaims", maxClaimsVal, "number");932 User.setProperty("coupon_gen_step", "discount", "string");933 __uiSend("💸 <b>What discount percentage should it give?</b>\n<i>Send a number only (1-100), for example: 10</i>", { parse_mode: "HTML" });934 return;935 }936 if (couponGenStep === "discount") {937 var discountVal = parseFloat(msgText.trim());938 if (isNaN(discountVal) || discountVal <= 0 || discountVal > 100) { __uiSend("❌ The discount must be between 1 and 100."); return; }939 User.setProperty("coupon_gen_discount", discountVal, "number");940 User.setProperty("coupon_gen_step", "validity", "string");941 __uiSend(942 "📅 <b>How many days should this coupon stay valid?</b>\n" +943 "<i>Send a number only, for example: 7</i>\n\n" +944 "♾️ Send <code>0</code> for no expiry.",945 { parse_mode: "HTML" }946 );947 return;948 }949 if (couponGenStep === "validity") {950 var validDays = parseInt(String(msgText).trim(), 10);951 if (isNaN(validDays) || validDays < 0 || validDays > 3650) { __uiSend("❌ Send a number between 0 and 3650. Example: <code>7</code>",{parse_mode:"HTML"}); return; }952 User.setProperty("coupon_gen_validdays", validDays, "number");953 User.setProperty("coupon_gen_step", "scope", "string");954 __uiSend(955 "🎯 <b>Choose the scope:</b>\n\n" +956 "• For all products and plans: send <code>global</code>\n" +957 "• For a single product + plan only: <code>Product Name | Duration</code>\n" +958 " <i>Example:</i> <code>Atomic Habits (Book) | 1d</code>",959 { parse_mode: "HTML" }960 );961 return;962 }963 if (couponGenStep === "scope") {964 var scopeInput = msgText.trim();965 var couponData = {966 code: User.getProperty("coupon_gen_code"),967 maxClaims: User.getProperty("coupon_gen_maxclaims"),968 discountPercent: User.getProperty("coupon_gen_discount"),969 claimedBy: [],970 isPaused: false,971 createdAt: new Date().toISOString(),972 validDays: Number(User.getProperty("coupon_gen_validdays") || 0),973 expiresAt: (Number(User.getProperty("coupon_gen_validdays") || 0) > 0974 ? Date.now() + Number(User.getProperty("coupon_gen_validdays")) * 86400000975 : 0)976 };977 if (scopeInput.toLowerCase() === "global") {978 couponData.scope = "global";979 } else if (scopeInput.indexOf("|") > -1) {980 var scopeParts = scopeInput.split("|");981 couponData.scope = "specific";982 couponData.productName = scopeParts[0].trim();983 couponData.duration = scopeParts[1].trim();984 } else {985 __uiSend("❌ Wrong format! Type 'global' or use the 'Product Name | Duration' format.");986 return;987 }988 Bot.setProperty("coupon_" + couponData.code, couponData, "json");989 var couponList = Bot.getProperty("coupon_list") || []; if (Array.isArray(couponList)) couponList = couponList.slice();990 if (couponList.indexOf(couponData.code) === -1) {991 couponList.push(couponData.code);992 Bot.setProperty("coupon_list", couponList, "json");993 }994 User.setProperty("coupon_gen_step", null, "string");995 User.setProperty("coupon_gen_code", null, "string");996 User.setProperty("coupon_gen_maxclaims", null, "number");997 User.setProperty("coupon_gen_discount", null, "number");998 User.setProperty("coupon_gen_validdays", null, "number");999 __uiSend(1000 "<blockquote>🎟 <b>COUPON CREATED SUCCESSFULLY!</b></blockquote>\n\n" +1001 "🏷 <b>Code:</b> <code>" + couponData.code + "</code>\n" +1002 "👥 <b>Max Claims:</b> " + couponData.maxClaims + "\n" +1003 "💸 <b>Discount:</b> " + couponData.discountPercent + "%\n" +1004 "📅 <b>Valid for:</b> " + (couponData.expiresAt ? couponData.validDays + " day(s)" : "♾️ No expiry") + "\n" +1005 "🎯 <b>Scope:</b> " + (couponData.scope === "global" ? "🌍 Global (All Plans)" : "📦 " + couponData.productName + " (" + couponData.duration + ")"),1006 { parse_mode: "HTML" }1007 );1008 return;1009 }1010 }1011 if (awaitingCouponFor) {1012 var enteredCode = msgText.trim().toUpperCase();1013 var couponRec = Bot.getProperty("coupon_" + enteredCode);1014 User.setProperty("awaiting_coupon_for", null, "string");1015 if (!couponRec) {1016 __uiSend("❌ <b>Invalid coupon code!</b>", { parse_mode: "HTML" });1017 return;1018 }1019 if (couponRec.isPaused) {1020 __uiSend("⏸ This coupon is currently paused. Please try again later.", { parse_mode: "HTML" });1021 return;1022 }1023 if (Number(couponRec.expiresAt||0) > 0 && Date.now() > Number(couponRec.expiresAt)) {1024 __uiSend("⌛ <b>This coupon has expired.</b>", { parse_mode: "HTML" });1025 return;1026 }1027 if (!Array.isArray(couponRec.claimedBy)) { couponRec.claimedBy = []; }1028 if (couponRec.claimedBy.indexOf(userId) > -1) {1029 __uiSend("⚠️ You have already used this coupon!", { parse_mode: "HTML" });1030 return;1031 }1032 if (couponRec.claimedBy.length >= couponRec.maxClaims) {1033 __uiSend("❌ This coupon has reached its usage limit!", { parse_mode: "HTML" });1034 return;1035 }1036 var couponTargetParts = awaitingCouponFor.split(" ");1037 var cTargetProdIdx = couponTargetParts[0];1038 var cTargetPlanIdx = couponTargetParts[1];1039 if (couponRec.scope === "specific") {1040 var cProductList = Bot.getProperty("stored_products") || [];1041 var cProduct = cProductList[Number(cTargetProdIdx)];1042 var cPlan = cProduct ? cProduct.plans[Number(cTargetPlanIdx)] : null;1043 var cDurationDisplay = cPlan ? (cPlan.durationDisplay || (cPlan.days + " Days")) : "";1044 var matchesProduct = cProduct && cProduct.name.trim().toLowerCase() === couponRec.productName.trim().toLowerCase();1045 var matchesDuration = cDurationDisplay.toLowerCase().indexOf(String(couponRec.duration).toLowerCase().replace(/[^a-z0-9]/g, "")) > -1 ||1046 String(couponRec.duration).replace(/[^0-9]/g, "") === String(cPlan ? cPlan.days : "");1047 if (!matchesProduct) {1048 __uiSend("❌ This coupon is not valid for this product!", { parse_mode: "HTML" });1049 return;1050 }1051 if (couponRec.duration && !matchesDuration) {1052 __uiSend("❌ This coupon is not valid for the duration you selected!", { parse_mode: "HTML" });1053 return;1054 }1055 }1056 User.setProperty("applied_coupon_" + cTargetProdIdx + "_" + cTargetPlanIdx, enteredCode, "string");1057 __uiSend("🎉 <b>Coupon applied!</b> -" + couponRec.discountPercent + "% discount applied.", { parse_mode: "HTML" });1058 Bot.runCommand("/buyitem " + cTargetProdIdx + " " + cTargetPlanIdx);1059 return;1060 }1061 if ((__isAdminOrCo) && isAwaitingBroadcast) {1062 User.setProperty("awaiting_broadcast_data", false, "boolean");1063 var userList = Bot.getProperty("all_users_list") || [];1064 if (userList.length === 0) {1065 __uiSend("❌ No user has registered in the bot yet.");1066 return;1067 }1068 var targetMessageId = null;1069 if (request) {1070 if (request.message_id) { targetMessageId = request.message_id; }1071 else if (request.message && request.message.message_id) { targetMessageId = request.message.message_id; }1072 }1073 if (!targetMessageId) {1074 __uiSend("❌ Unable to fetch message ID for broadcast.");1075 return;1076 }1077 __uiSend("⏳ Sending premium broadcast to " + userList.length + " users... Please wait.");1078 var sentCount = 0;1079 var failedCount = 0;1080 for (var i = 0; i < userList.length; i++) {1081 try {1082 Api.copyMessage({1083 chat_id: String(userList[i]),1084 from_chat_id: adminId,1085 message_id: Number(targetMessageId)1086 });1087 sentCount++;1088 } catch (perUserErr) {1089 failedCount++;1090 }1091 }1092 __uiSend(1093 "✅ <b>Duyuru Complete!</b>\n" +1094 "📤 <b>Sent:</b> " + sentCount + " users\n" +1095 (failedCount > 0 ? "⚠️ <b>Failed/Blocked:</b> " + failedCount + " users" : "🎉 <b>No failures!</b>"),1096 { parse_mode: "HTML" }1097 );1098 }1099} catch (err) {1100 __uiSend("Error in handling: " + err.message);1101}