pnxh2371/Ankit_mods_store_botPublic ยท Bot Template

ProfileTelegram

AI๐€ษดแด‹ษชแด› ๐Œแดแด…๊œฑ ๐’แด›แดส€แด‡ ๐Ÿ› appears to be a Telegram automation bot. Commands include /*, /addbal, /addbal_all, /addbal_binance, /addbal_binance_approve, /addbal_binance_paid, /addbal_upi, /addcat_id. Observed in code: messaging, http, libs, keyboards, payments.

Utilityutility
133 commands0 envUpdated 8h agoCreated Sep 10, 2026
Back to folder

commands/_onCheck.js

javascript ยท 407 lines

Raw
1/**#command2name: /onCheck3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  var opts = (typeof options !== "undefined" && options) ? options : {};14  let isBackground = opts.is_background || false;15  let orderId = opts.order_id;16  let amount = opts.amount;17  let chatId = chat ? chat.chatid : null;18  let attempt = opts.attempt || 1;19 20  if (typeof params !== "undefined" && params && params.trim() !== "") {21    let splitParams = params.trim().split(" ");22    if (splitParams.length >= 1 && splitParams[0].length > 5) {23      orderId = splitParams[0];24    }25    if (splitParams.length >= 2) amount = splitParams[1];26  }27 28  let targetUserId = (typeof user !== "undefined" && user) ? user.telegramid : null;29 30  // ๐Ÿ› ๏ธ ULTIMATE FALLBACK: Agar button ya params se orderId na mile, toh active pending order ID utha lo!31  if ((!orderId || orderId.trim() === "") && targetUserId) {32    orderId = User.getProperty("pending_order_id") || 33              Bot.getProperty("qr_order_id_" + targetUserId) || 34              User.getProperty("qr_order_id_" + targetUserId) ||35              User.getProperty("buy_pending_order_id");36  }37 38  let queryId = null;39  if (typeof request !== "undefined" && request) {40    if (request.callback_query && request.callback_query.id) {41      queryId = request.callback_query.id;42    } else if (request.id) {43      queryId = request.id;44    }45  }46 47  // ๐ŸŽจ Premium emojis48  let e_chart = "<tg-emoji emoji-id='5992430854909989581'>๐Ÿ“Š</tg-emoji>";49  let e_plus = "<tg-emoji emoji-id='5346004239246183111'>โž•</tg-emoji>";50  let e_arrow = "<tg-emoji emoji-id='5875506366050734240'>โžก๏ธ</tg-emoji>";51  let e_coin = "<tg-emoji emoji-id='5778335621491723621'>๐Ÿช™</tg-emoji>";52  let e_money = "<tg-emoji emoji-id='5348392971207194994'>๐Ÿ’ฐ</tg-emoji>";53  let e_time = "<tg-emoji emoji-id='5776213190387961618'>๐Ÿ•“</tg-emoji>";54  let e_check = "<tg-emoji emoji-id='5330237710655306682'>โœ…</tg-emoji>";55 56  function vanishQrMessage(uid, fallbackChatId) {57    try {58      let qrMsgId = Bot.getProperty("qr_msg_id_" + uid) ||59                    User.getProperty("qr_msg_id_" + uid) ||60                    User.getProperty("last_qr_message_id_" + uid);61      if (qrMsgId) {62        try { Api.deleteMessage({ chat_id: fallbackChatId, message_id: qrMsgId }); } catch (e) {}63      }64    } catch (e) {}65  }66 67  function clearQrState(uid) {68    Bot.setProperty("qr_msg_id_" + uid, null, "string");69    User.setProperty("qr_msg_id_" + uid, null, "string");70    User.setProperty("last_qr_message_id_" + uid, null, "string");71    Bot.setProperty("qr_order_id_" + uid, null, "string");72    User.setProperty("qr_order_id_" + uid, null, "string");73    Bot.setProperty("qr_watch_order_" + uid, null, "string");74    User.setProperty("qr_watch_order_" + uid, null, "string");75    Bot.setProperty("verifying_lock_" + uid, false, "boolean");76    User.setProperty("verifying_lock_" + uid, false, "boolean");77    User.setProperty("topup_verifying_lock_" + uid, false, "boolean");78    User.setProperty("pending_order_id", null);79  }80 81  function getUnifiedBalance(uid) {82    let resBal = 0;83    try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}84    let bonusBal = Number(Bot.getProperty("balance" + uid) || 0);85    return resBal + bonusBal;86  }87 88  // โœ… STEP 1: Strict Order ID validation check89  if (!orderId || orderId.trim() === "") {90    if (queryId) {91      try {92        Api.answerCallbackQuery({93          callback_query_id: queryId,94          text: "โš ๏ธ Active order nahi mila. Kripya pehle naya QR generate karein.",95          show_alert: true96        });97      } catch (e) {}98    }99    return;100  }101 102  // โœ… STEP 2: Duplicate Claim Check103  if (Bot.getProperty("claimed_topup_" + orderId)) {104    vanishQrMessage(targetUserId, chatId);105    if (targetUserId) clearQrState(targetUserId);106 107    if (queryId) {108      try {109        Api.answerCallbackQuery({110          callback_query_id: queryId,111          text: "โœ… ALREADY CLAIMED โœ…\nYe payment pehle hi verify hokar balance me add ho chuki hai.",112          show_alert: true113        });114      } catch (e) {}115    }116    return;117  }118 119  if (targetUserId && !isBackground) {120    let isChecking = User.getProperty("topup_verifying_lock_" + targetUserId);121    if (isChecking) {122      if (queryId) {123        try {124          Api.answerCallbackQuery({125            callback_query_id: queryId,126            text: "โณ VERIFYING... PLEASE WAIT...",127            show_alert: true128          });129        } catch (e) {}130      }131      return;132    }133    User.setProperty("topup_verifying_lock_" + targetUserId, true, "boolean");134  }135 136  let responseData = null;137  try {138    responseData = (typeof content !== "undefined" && content)139      ? (typeof content === "object" ? content : JSON.parse(content))140      : null;141  } catch (parseErr) {142    responseData = null;143  }144 145  // FamPay gateway responses have appeared in a few compatible shapes:146  // {status:"success",data:{...}}, {success:true,data:{...}},147  // {payment_status:"SUCCESS",...}, or a nested result/payment object.148  // Normalize all of them before deciding whether money was actually received.149  function firstObject() {150    for (var ai = 0; ai < arguments.length; ai++) {151      var v = arguments[ai];152      if (v && typeof v === "object" && !Array.isArray(v)) return v;153    }154    return null;155  }156 157  gatewayData = firstObject(158    responseData && responseData.data,159    responseData && responseData.result,160    responseData && responseData.payment,161    responseData && responseData.transaction,162    responseData163  );164 165  function normalizeStatus(v) {166    return String(v === undefined || v === null ? "" : v)167      .trim().toLowerCase().replace(/[\s-]+/g, "_");168  }169 170  var statusCandidates = [];171  if (responseData) {172    statusCandidates.push(responseData.status, responseData.payment_status,173      responseData.paymentStatus, responseData.state, responseData.result_status);174    if (responseData.data && typeof responseData.data === "object") {175      statusCandidates.push(responseData.data.status, responseData.data.payment_status,176        responseData.data.paymentStatus, responseData.data.state);177    }178    if (responseData.result && typeof responseData.result === "object") {179      statusCandidates.push(responseData.result.status, responseData.result.payment_status,180        responseData.result.paymentStatus, responseData.result.state);181    }182    if (responseData.payment && typeof responseData.payment === "object") {183      statusCandidates.push(responseData.payment.status, responseData.payment.payment_status,184        responseData.payment.paymentStatus, responseData.payment.state);185    }186  }187 188  var gatewayStatus = "";189  for (var si = 0; si < statusCandidates.length; si++) {190    var ns = normalizeStatus(statusCandidates[si]);191    if (ns) { gatewayStatus = ns; break; }192  }193 194  var explicitSuccess = (195    gatewayStatus === "success" ||196    gatewayStatus === "successful" ||197    gatewayStatus === "paid" ||198    gatewayStatus === "payment_paid" ||199    gatewayStatus === "completed" ||200    gatewayStatus === "complete" ||201    gatewayStatus === "verified" ||202    gatewayStatus === "payment_success" ||203    gatewayStatus === "payment_successful" ||204    gatewayStatus === "successfully_paid"205  );206 207  // Boolean success may be returned as true, "true", 1, or "1".208  var boolSuccess = false;209  if (responseData) {210    boolSuccess = responseData.success === true ||211      String(responseData.success).toLowerCase() === "true" ||212      responseData.success === 1 || String(responseData.success) === "1";213    if (!boolSuccess && responseData.data && typeof responseData.data === "object") {214      boolSuccess = responseData.data.success === true ||215        String(responseData.data.success).toLowerCase() === "true" ||216        responseData.data.success === 1 || String(responseData.data.success) === "1";217    }218  }219 220  gatewaySuccess = explicitSuccess || boolSuccess;221 222  // Some versions return the transaction object directly and only expose223  // "paid"/"success" as a boolean field.224  if (!gatewaySuccess && gatewayData) {225    gatewaySuccess = gatewayData.paid === true ||226      String(gatewayData.paid).toLowerCase() === "true" ||227      normalizeStatus(gatewayData.payment_state) === "paid";228  }229 230  // A successful response without a nested data object is still valid when it231  // contains a transaction/reference identifier. Older code incorrectly232  // required responseData.data, causing the exact "PAYMENT NOT RECEIVED YET"233  // false-negative reported by users.234  if (gatewaySuccess && !gatewayData) gatewayData = responseData;235 236  if (responseData && gatewaySuccess && gatewayData) {237 238    // โœ… STEP 3: Mark claimed only NOW that payment is confirmed successful239    // (avoids race conditions on concurrent success calls, without falsely240    // locking out an order that hasn't actually been paid yet)241    if (Bot.getProperty("claimed_topup_" + orderId)) {242      // Someone else already processed this exact order in parallel โ€” bail out243      if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");244      return;245    }246    Bot.setProperty("claimed_topup_" + orderId, true, "boolean");247 248    let txData = gatewayData;249    let txAmount = txData.amount || txData.paid_amount || txData.amount_paid ||250                   txData.amountReceived || txData.received_amount || amount ||251                   (targetUserId ? User.getProperty("qr_order_amount_" + targetUserId) : 0);252    let utr = txData.utr || txData.transaction_id || txData.txn_id ||253              txData.reference_id || txData.ref_id || txData.upi_ref || txData.bank_ref ||254              ("ORDER-" + String(orderId));255    let senderName = txData.sender_name || (typeof user !== "undefined" && user ? user.first_name : "Valued User");256    let payTime = txData.payment_time_ist || "N/A";257    let addedAmount = parseFloat(txAmount) || 0;258 259    try {260      Libs.ResourcesLib.userRes("balance").add(addedAmount);261    } catch (e) {}262    let newBalance = getUnifiedBalance(targetUserId);263 264    // ==========================================265    // ๐ŸŽ REFER & EARN โ€” referrer bonus jab referred friend PEHLI baar266    // balance add kare (sirf ek baar, farming rokne ke liye)267    // ==========================================268    try {269      let referredByTopup = User.getProperty("referred_by");270      if (referredByTopup && !User.getProperty("ref_topup_bonus_given")) {271        let refBonusTopup = Number(Bot.getProperty("refer_earn_topup_amount"));272        if (isNaN(refBonusTopup)) refBonusTopup = 2;273        if (refBonusTopup > 0) {274          Libs.ResourcesLib.anotherUserRes("balance", referredByTopup).add(refBonusTopup);275          let pastEarnTopup = Number(Bot.getProperty("refer_earnings_" + referredByTopup) || 0);276          Bot.setProperty("refer_earnings_" + referredByTopup, pastEarnTopup + refBonusTopup, "number");277          try {278            Api.sendMessage({279              chat_id: referredByTopup,280              text: "<blockquote>๐Ÿ’ธ <b>Referral Bonus!</b>\n\nAapke referred friend ne balance add kiya โ€” aapko โ‚น" + refBonusTopup.toFixed(2) + " mile hain!</blockquote>",281              parse_mode: "HTML"282            });283          } catch (e) {}284        }285        User.setProperty("ref_topup_bonus_given", true, "boolean");286      }287    } catch (e) {}288 289    // ๐Ÿ”” Admin notification for wallet balance top-up290    try {291      let walletLogAdminId = Bot.getProperty("owner_id") || "6182067327";292      let walletAdminMsg = "<blockquote>" +293        "๐Ÿ”” <b>WALLET BALANCE ADDED</b> โœ”๏ธ\n\n" +294        "๐Ÿ‘ค <b>User:</b> " + senderName + " (<code>" + targetUserId + "</code>)\n" +295        "๐Ÿ’ฐ <b>Amount Added:</b> โ‚น" + addedAmount.toFixed(2) + "\n" +296        "๐Ÿงพ <b>UTR:</b> <code>" + utr + "</code>\n" +297        "๐Ÿ†” <b>Order ID:</b> <code>" + orderId + "</code>" +298        "</blockquote>";299      Api.sendMessage({ chat_id: walletLogAdminId, text: walletAdminMsg, parse_mode: "HTML" });300    } catch (e) {}301 302    if (queryId) {303      try {304        Api.answerCallbackQuery({305          callback_query_id: queryId,306          text: "โœ… PAYMENT VERIFIED SUCCESSFULLY!",307          show_alert: false308        });309      } catch (e) {}310    }311 312    if (targetUserId) {313      vanishQrMessage(targetUserId, chatId);314      clearQrState(targetUserId);315    }316 317    if (User.getProperty("buy_reseller_upgrade")) {318      let resellerPrice = Number(User.getProperty("buy_reseller_price") || 0);319      User.setProperty("buy_reseller_upgrade", null, "boolean");320      User.setProperty("buy_reseller_price", null, "number");321 322      Bot.setProperty("is_reseller_" + targetUserId, true, "boolean");323 324      Api.sendMessage({325        chat_id: chatId,326        text: "<blockquote><tg-emoji emoji-id='6102856637343600044'>๐ŸŽ‰</tg-emoji> <b>CONGRATULATIONS!</b></blockquote>\n\n" +327              "<tg-emoji emoji-id='6215386799133433653'>๐Ÿ‘‘</tg-emoji> <b>You are now a Reseller!</b>\n\n" +328              "<i>Payment verified aur permanent reseller status activate ho gaya!</i>",329        parse_mode: "HTML",330        reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Explore Shop", callback_data: "/buy_hack", style: "success" }]] })331      });332 333      if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");334      return;335    }336 337    let pendingProdIdx = User.getProperty("buy_prod_idx");338    let pendingPlanIdx = User.getProperty("buy_plan_idx");339 340    if (pendingProdIdx !== null && pendingProdIdx !== undefined && pendingProdIdx !== "" &&341        pendingPlanIdx !== null && pendingPlanIdx !== undefined && pendingPlanIdx !== "") {342 343      Api.sendMessage({ 344        chat_id: chatId, 345        text: e_check + " <b>Payment verified! Generating your key now...</b>", 346        parse_mode: "HTML" 347      });348 349      Bot.run({350        command: "/confirm_buyitem",351        options: { params: pendingProdIdx + " " + pendingPlanIdx }352      });353 354      User.setProperty("buy_prod_idx", null);355      User.setProperty("buy_plan_idx", null);356      User.setProperty("buy_price", null);357      User.setProperty("buy_needpay", null);358 359      if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");360      return;361    }362 363    let successText = "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n" +364                      e_plus + " <b>PAYMENT SUCCESSFUL</b> " + e_plus + "\n" +365                      "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n\n" +366                      e_money + " <b>Added Amount:</b> โ‚น<b>" + addedAmount.toFixed(2) + "</b>\n" +367                      e_chart + " <b>New Balance:</b> โ‚น<b>" + newBalance.toFixed(2) + "</b>\n" +368                      e_arrow + " <b>UTR / Ref ID:</b> <code>" + utr + "</code>\n" +369                      e_time + " <b>Time:</b> " + payTime + "\n\n" +370                      "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n" +371                      e_coin + " <i>Your funds have been successfully credited! ๐ŸŽ‰</i>";372 373    Api.sendMessage({374      chat_id: chatId,375      text: successText,376      parse_mode: "HTML",377      reply_markup: JSON.stringify({378        inline_keyboard: [[379          { text: "๐Ÿ›’ Shop Now", callback_data: "/buy_hack", style: "success" },380          { text: "๐Ÿ”ฐ Profile", callback_data: "/profile", style: "primary" }381        ]]382      })383    });384 385    if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");386    return;387  }388 389  if (queryId && !isBackground) {390    try {391      Api.answerCallbackQuery({392        callback_query_id: queryId,393        text: "โš ๏ธ PAYMENT NOT RECEIVED YET\nPlease complete the payment first.",394        show_alert: true395      });396    } catch (e) {}397  }398 399  if (targetUserId) User.setProperty("topup_verifying_lock_" + targetUserId, false, "boolean");400 401} catch (err) {402  try {403    let uid = (typeof user !== "undefined" && user) ? user.telegramid : null;404    if (uid) User.setProperty("topup_verifying_lock_" + uid, false, "boolean");405  } catch (e) {}406  Bot.sendMessage("โš ๏ธ Error in verification check: " + err.message);407}