tarunpoonia905/OfcDevShopBotPublic · Bot Template

ProfileTelegram

AIDEV SHOP appears to be a Telegram automation bot. Commands include /confirm_delete_stock, /addstock_id, /extkey_menu, /partner_api, /apidelete, /buy_hack_cat, /admin_manage_products, /check_buy. Observed in code: messaging, keyboards, payments, libs, web, http, games.

Utilityutility
228 commands0 envUpdated 12d agoCreated Oct 18, 2026
Back to folder

commands/_manualpay.js

javascript · 366 lines

Raw
1/**#command2name: /manualpay3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/*#SIZE_V1*/try{(function(){var z=Bot.getProperty("ui_btn_size");var mx=z==="large"?1:(z==="medium"?2:0);if(!mx||Api.__sz)return;var NAV=/^[◀▶⬅➡«»‹›⏪⏩]|\d+\s*\/\s*\d+|prev|next|page/i;var T=function(m){try{var o=typeof m==="string"?JSON.parse(m):m;if(!o||!o.inline_keyboard)return m;var out=[],cnt=0;o.inline_keyboard.forEach(function(row){var nav=row.some(function(b){return NAV.test(String(b.text||"").trim());});if(row.length<=mx||nav){out.push(row);cnt+=row.length;return;}for(var i=0;i<row.length;i+=mx){var c=row.slice(i,i+mx);out.push(c);cnt+=c.length;}});if(cnt>100||out.length>100)return m;o.inline_keyboard=out;return typeof m==="string"?JSON.stringify(o):o;}catch(e){return m;}};["sendMessage","editMessageText","editMessageCaption","editMessageReplyMarkup","sendPhoto","sendVideo","sendAnimation","sendDocument"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(p&&p.reply_markup)p.reply_markup=T(p.reply_markup);}catch(e){}return f.apply(Api,arguments);};});Api.__sz=true;})();}catch(__szE){}13/*#ANIM_V1*/try{(function(){var M={party:"5046509860389126442",fire:"5104841245755180586",heart:"5159385139981059251",like:"5107584321108051014"};var a=Bot.getProperty("ui_anim");if(!a||!M[a]||Api.__an)return;var E=M[a];var OK=/PURCHASE SUCCESSFUL|PAYMENT SUCCESSFUL|Payment verified|CONGRATULATIONS/i;var priv=function(p){return p&&p.chat_id&&String(p.chat_id).charAt(0)!=="-";};["sendMessage","sendPhoto","sendVideo","sendAnimation"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(priv(p)&&!p.message_effect_id&&OK.test(String(p.text||p.caption||"")))p.message_effect_id=E;}catch(e){}return f.apply(Api,arguments);};});var fe=Api.editMessageText;if(typeof fe==="function"){Api.editMessageText=function(p){var r=fe.apply(Api,arguments);try{if(priv(p)&&OK.test(String(p.text||"")))Api.sendMessage({chat_id:p.chat_id,text:"🎉",message_effect_id:E});}catch(e){}return r;};}Api.__an=true;})();}catch(__anE){}14/*#PREMIUM_UI_V1*/try{(function(){if(Bot.getProperty("ui_premium")!==true||Api.__pm)return;var R=function(t,c){var s=(String(t||"")+" "+String(c||"")).toLowerCase();if(/back|cancel|close|delete|remove|clear|reject|stop|ban|exit/.test(s))return"danger";if(/pay|buy|confirm|verify|paid|add|deposit|shop|claim|yes|receive|wallet|download|update/.test(s))return"success";return"primary";};var T=function(m){try{var o=typeof m==="string"?JSON.parse(m):m;if(!o||!o.inline_keyboard)return m;o.inline_keyboard.forEach(function(row){row.forEach(function(b){if(b.copy_text||b.url||b.callback_data||b.web_app){b.style=R(b.text,b.callback_data||b.url);if(!b.icon_custom_emoji_id&&b.text&&!/^[\u2600-\u27BF\uD83C-\uD83E]/.test(String(b.text).trim())&&!/^[✦✨💎]/.test(b.text))b.text="✦ "+b.text;}});});return typeof m==="string"?JSON.stringify(o):o;}catch(e){return m;}};["sendMessage","editMessageText","editMessageCaption","editMessageReplyMarkup","sendPhoto","sendVideo","sendAnimation","sendDocument"].forEach(function(n){var f=Api[n];if(typeof f!=="function")return;Api[n]=function(p){try{if(p&&p.reply_markup)p.reply_markup=T(p.reply_markup);}catch(e){}return f.apply(Api,arguments);};});Api.__pm=true;})();}catch(__pmE){}15 16// =========================================================17// ✋ MANUAL PAYMENT (owner's own QR + UPI ID, screenshot -> approve/cancel)18//19// ADMIN SETUP  : /admin -> Payment Gateways -> "Set Manual QR & UPI"20//                 1) admin apna QR image bhejta hai21//                 2) bot UPI ID maangta hai -> save hote hi Manual gateway ON22//                 (ON/OFF kabhi bhi Payment Gateways screen se)23// USER FLOW    : Add Balance (amount confirm) ya Panel buy (wallet kam) ->24//                 admin ka QR + UPI ID + exact amount -> "I Have Paid" ->25//                 screenshot -> owner/co-admin ko Approve / Cancel26//                 Approve = user ke wallet me paisa; Cancel = reject.27// Actions (params): setup | save_qr | save_upi | show <amount> [prodIdx planIdx]28//                   paid <id> | shot | cancel <id> | approve <id> | reject <id>29// =========================================================30try {31  var ownerId = String(Bot.getProperty("owner_id") || "7127818616");32  var inOpts = (typeof options !== "undefined" && options) ? options : {};33  var rawParams = (inOpts.params !== undefined && inOpts.params !== null)34    ? String(inOpts.params) : String((typeof params !== "undefined" && params) ? params : "");35  var parts = rawParams.trim().split(/\s+/);36  var action = String(parts[0] || "").toLowerCase();37 38  var myId = String(user.telegramid);39  var chatId = String(chat.chatid);40  var queryId = null;41  if (typeof request !== "undefined" && request) {42    queryId = request.id || (request.callback_query && request.callback_query.id) || null;43  }44 45  function esc(s) { return String(s === undefined || s === null ? "" : s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); }46  function ack(text, alert) {47    if (!queryId) return;48    try { Api.answerCallbackQuery({ callback_query_id: String(queryId), text: text || "", show_alert: !!alert }); } catch (e) {}49  }50  function approverIds() {51    var ids = [ownerId];52    var l = Bot.getProperty("co_admin_list") || [];53    if (Array.isArray(l)) {54      l.forEach(function (x) {55        var v = (x && typeof x === "object") ? (x.id || x.telegramid || x.user_id) : x;56        if (v) { v = String(v); if (ids.indexOf(v) === -1) ids.push(v); }57      });58    }59    return ids;60  }61  function isApprover(uid) {62    uid = String(uid);63    return uid === ownerId || approverIds().indexOf(uid) !== -1 || !!Bot.getProperty("co_admin_" + uid);64  }65  function getPhotoId() {66    try {67      var arr = null;68      if (inOpts.file_id) return String(inOpts.file_id);69      if (request) {70        if (request.message && request.message.photo && request.message.photo.length) arr = request.message.photo;71        else if (request.photo && request.photo.length) arr = request.photo;72        else if (request.update && request.update.message && request.update.message.photo && request.update.message.photo.length) arr = request.update.message.photo;73      }74      if (arr) return String(arr[arr.length - 1].file_id);75    } catch (e) {}76    return null;77  }78  function balRes(uid) {79    try { if (String(user.telegramid) === String(uid)) return Libs.ResourcesLib.userRes("balance"); } catch (e) {}80    return Libs.ResourcesLib.anotherUserRes("balance", uid);81  }82  function getOrder(id) { return id ? Bot.getProperty("mp_order_" + id) : null; }83  function saveOrder(id, o) { Bot.setProperty("mp_order_" + id, o, "json"); }84  function deleteSrcMessage() {85    try {86      if (request && request.message && request.message.message_id) {87        Api.deleteMessage({ chat_id: chatId, message_id: Number(request.message.message_id) });88      }89    } catch (e) {}90  }91  var menuKb = JSON.stringify({ inline_keyboard: [[{ text: "Open Shop", callback_data: "/menu", style: "success" }]] });92 93  // ---------------------------------------------------------94  // ADMIN: start setup (step 1 -> QR image)95  // ---------------------------------------------------------96  if (action === "setup") {97    if (!isApprover(myId)) { ack("Not allowed", true); return; }98    User.setProperty("mp_step", "waiting_qr", "string");99    ack("");100    var curUpi = Bot.getProperty("manual_upi_id");101    Api.sendMessage({102      chat_id: chatId, parse_mode: "HTML",103      text: "<blockquote>✋ <b>MANUAL PAYMENT SETUP</b></blockquote>\n\n" +104        "<b>Step 1/2:</b> Apna <b>QR code image</b> photo ke roop me bhejo.\n\n" +105        (curUpi ? "<i>Current UPI:</i> <code>" + esc(curUpi) + "</code> (nayi QR + UPI se replace ho jayega)\n\n" : "") +106        "<i>Cancel karne ke liye</i> <code>cancel</code> <i>likho.</i>"107    });108    return;109  }110 111  // ADMIN: step 1 done -> QR photo received (from wildcard)112  if (action === "save_qr") {113    if (!isApprover(myId)) return;114    var qrId = getPhotoId();115    if (!qrId) {116      Bot.sendMessage("⚠️ Photo nahi mili. QR ko <b>photo</b> ke roop me bhejo (file/document nahi), ya <code>cancel</code> likho.", { parse_mode: "HTML" });117      return;118    }119    Bot.setProperty("manual_qr_file_id", qrId, "string");120    User.setProperty("mp_step", "waiting_upi", "string");121    Bot.sendMessage("✅ <b>QR saved.</b>\n\n<b>Step 2/2:</b> Ab apni <b>UPI ID</b> bhejo.\nExample: <code>name@paytm</code>", { parse_mode: "HTML" });122    return;123  }124 125  // ADMIN: step 2 done -> UPI ID received (from wildcard)126  if (action === "save_upi") {127    if (!isApprover(myId)) return;128    var upiTxt = String(inOpts.text || "").trim();129    if (!upiTxt || upiTxt.indexOf("@") < 1 || /\s/.test(upiTxt) || upiTxt.length > 100) {130      Bot.sendMessage("❌ Sahi UPI ID bhejo (example: <code>name@paytm</code>), ya <code>cancel</code> likho.", { parse_mode: "HTML" });131      return;132    }133    Bot.setProperty("manual_upi_id", upiTxt, "string");134    Bot.setProperty("gateway_manual_enabled", true, "boolean");135    User.setProperty("mp_step", null, "string");136    Api.sendMessage({137      chat_id: chatId, parse_mode: "HTML",138      text: "✅ <b>Manual Payment ON ho gaya!</b>\n\n🆔 UPI: <code>" + esc(upiTxt) + "</code>\n🖼 QR: saved\n\n" +139        "<i>Ab Add Balance / Panel Buy par aapka QR + UPI ID dikhega. ON/OFF Payment Gateways screen se kar sakte ho.</i>",140      reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "💳 Payment Gateways", callback_data: "/admin_gateways", style: "primary" }]] })141    });142    return;143  }144 145  // ---------------------------------------------------------146  // USER: show manual QR for an amount147  // params: show <amount> [prodIdx planIdx]148  // ---------------------------------------------------------149  if (action === "show") {150    var amount = Number(parts[1]);151    if (!(amount > 0)) { ack("Invalid amount", true); return; }152    amount = Number(amount.toFixed(2));153    var qrFile = Bot.getProperty("manual_qr_file_id");154    var upiId = Bot.getProperty("manual_upi_id");155    if (Bot.getProperty("gateway_manual_enabled") !== true || !qrFile || !upiId) {156      ack("Manual payment abhi available nahi hai.", true);157      return;158    }159    var hasPlan = parts.length >= 4 && isFinite(Number(parts[2])) && isFinite(Number(parts[3]));160    var oid = "mp" + Date.now().toString(36);161    var fullName = ((user.first_name || "") + (user.last_name ? " " + user.last_name : "")).trim();162    var order = {163      id: oid, uid: myId, amount: amount, status: "awaiting",164      name: fullName, username: user.username ? String(user.username) : "",165      prod: hasPlan ? Number(parts[2]) : null, plan: hasPlan ? Number(parts[3]) : null,166      prod_name: hasPlan ? String(User.getProperty("buy_prod_name") || "") : "",167      ts: Date.now()168    };169    saveOrder(oid, order);170 171    var caption =172      "<blockquote>✋ <b>MANUAL PAYMENT</b></blockquote>\n\n" +173      "💰 <b>Amount:</b> ₹<code>" + amount.toFixed(2) + "</code>\n" +174      "🆔 <b>UPI ID:</b> <code>" + esc(upiId) + "</code>\n\n" +175      "1️⃣ QR scan karo ya upar wali UPI ID par <b>exact ₹" + amount.toFixed(2) + "</b> bhejo\n" +176      "2️⃣ Payment ke baad <b>I Have Paid</b> dabao aur screenshot bhejo\n\n" +177      "<i>Admin approve karega to balance add ho jayega.</i>";178    var kb = { inline_keyboard: [179      [{ text: "I Have Paid — Send Screenshot", callback_data: "/manualpay paid " + oid, style: "success" }],180      [{ text: "Cancel", callback_data: "/manualpay cancel " + oid, style: "danger" }]181    ] };182 183    deleteSrcMessage();184    ack("");185    var sent = Api.sendPhoto({ chat_id: chatId, photo: qrFile, caption: caption, parse_mode: "HTML", reply_markup: JSON.stringify(kb) });186    try {187      var smid = (sent && sent.result && sent.result.message_id) ? sent.result.message_id : (sent && sent.message_id ? sent.message_id : null);188      if (smid) { order.qr_mid = smid; saveOrder(oid, order); }189    } catch (e) {}190    return;191  }192 193  // ---------------------------------------------------------194  // USER: pressed "I Have Paid" -> ask for screenshot195  // ---------------------------------------------------------196  if (action === "paid") {197    var po = getOrder(parts[1]);198    if (!po || String(po.uid) !== myId) { ack("Order nahi mila.", true); return; }199    if (po.status !== "awaiting" && po.status !== "pending_review") { ack("Ye order pehle hi close ho chuka hai.", true); return; }200    if (po.status === "pending_review") { ack("Screenshot already admin ke paas hai. Approval ka wait karo.", true); return; }201    User.setProperty("mp_shot_step", po.id, "string");202    ack("");203    Api.sendMessage({204      chat_id: chatId, parse_mode: "HTML",205      text: "📸 <b>Ab payment ka screenshot bhejo</b> (photo ke roop me).\n\n💰 Amount: ₹<code>" + Number(po.amount).toFixed(2) + "</code>",206      reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Cancel", callback_data: "/manualpay cancel " + po.id, style: "danger" }]] })207    });208    return;209  }210 211  // ---------------------------------------------------------212  // USER: screenshot received (from wildcard) -> send to approvers213  // ---------------------------------------------------------214  if (action === "shot") {215    var sid = User.getProperty("mp_shot_step");216    var so = getOrder(sid);217    if (!so || String(so.uid) !== myId || so.status !== "awaiting") {218      User.setProperty("mp_shot_step", null, "string");219      Bot.sendMessage("⚠️ Koi active manual order nahi hai. Dobara Add Balance / Buy se shuru karo.");220      return;221    }222    var shotId = getPhotoId();223    if (!shotId) {224      Bot.sendMessage("⚠️ Screenshot <b>photo</b> ke roop me bhejo.", { parse_mode: "HTML" });225      return;226    }227    so.status = "pending_review";228    so.shot = shotId;229    saveOrder(so.id, so);230    User.setProperty("mp_shot_step", null, "string");231 232    var aCap =233      "<blockquote>✋ <b>MANUAL PAYMENT — APPROVAL</b></blockquote>\n\n" +234      "👤 <b>User:</b> " + esc(so.name || "User") + (so.username ? " (@" + esc(so.username) + ")" : "") + "\n" +235      "🆔 <b>ID:</b> <code>" + esc(so.uid) + "</code>\n" +236      "💰 <b>Amount:</b> ₹<code>" + Number(so.amount).toFixed(2) + "</code>\n" +237      "🧾 <b>For:</b> " + (so.prod !== null && so.prod !== undefined ? "Panel purchase" + (so.prod_name ? " — " + esc(so.prod_name) : "") : "Add Balance") + "\n" +238      "🔖 <b>Order:</b> <code>" + so.id + "</code>";239    var aKb = { inline_keyboard: [[240      { text: "✅ Approve", callback_data: "/manualpay approve " + so.id, style: "success" },241      { text: "❌ Cancel", callback_data: "/manualpay reject " + so.id, style: "danger" }242    ]] };243    approverIds().forEach(function (aid) {244      try { Api.sendPhoto({ chat_id: String(aid), photo: shotId, caption: aCap, parse_mode: "HTML", reply_markup: JSON.stringify(aKb) }); } catch (e) {}245    });246    Api.sendMessage({247      chat_id: chatId, parse_mode: "HTML",248      text: "⏳ <b>Screenshot admin ko bhej diya gaya.</b>\n\nApprove hote hi ₹" + Number(so.amount).toFixed(2) + " aapke wallet me add ho jayega aur aapko message aayega."249    });250    return;251  }252 253  // ---------------------------------------------------------254  // USER: cancel own order (only before admin has decided)255  // ---------------------------------------------------------256  if (action === "cancel") {257    var co = getOrder(parts[1]);258    if (co && String(co.uid) === myId && (co.status === "awaiting" || co.status === "pending_review")) {259      if (co.status === "pending_review") { ack("Screenshot admin ke paas hai, ab cancel nahi ho sakta.", true); return; }260      co.status = "cancelled";261      saveOrder(co.id, co);262    }263    User.setProperty("mp_shot_step", null, "string");264    ack("Cancelled");265    deleteSrcMessage();266    Api.sendMessage({ chat_id: chatId, text: "❌ Manual payment cancel ho gaya.", reply_markup: menuKb });267    return;268  }269 270  // ---------------------------------------------------------271  // ADMIN: approve / reject272  // ---------------------------------------------------------273  if (action === "approve" || action === "reject") {274    if (!isApprover(myId)) { ack("Not allowed", true); return; }275    var ao = getOrder(parts[1]);276    if (!ao) { ack("Order nahi mila.", true); return; }277    if (ao.status !== "pending_review") {278      ack("Ye order pehle hi " + (ao.status === "approved" ? "approve" : "close") + " ho chuka hai.", true);279      return;280    }281 282    var decidedBy = "by " + (user.first_name || myId);283    var doneCap;284 285    if (action === "reject") {286      ao.status = "rejected";287      ao.decided_by = myId;288      saveOrder(ao.id, ao);289      doneCap = "❌ <b>CANCELLED</b> " + esc(decidedBy) + "\n👤 <code>" + esc(ao.uid) + "</code> — ₹" + Number(ao.amount).toFixed(2) + "\n🔖 <code>" + ao.id + "</code>";290      try {291        Api.sendMessage({292          chat_id: String(ao.uid), parse_mode: "HTML",293          text: "❌ <b>Payment cancel kar diya gaya.</b>\n\nAapka manual payment (₹" + Number(ao.amount).toFixed(2) + ") admin ne approve nahi kiya. Agar aapne payment kiya hai to support se contact karo.",294          reply_markup: menuKb295        });296      } catch (e) {}297    } else {298      // claim first (blocks a double credit even if two approvers tap together)299      if (Bot.getProperty("claimed_topup_" + ao.id)) { ack("Already approved.", true); return; }300      Bot.setProperty("claimed_topup_" + ao.id, true, "boolean");301      var credited = true;302      try {303        balRes(ao.uid).add(Number(ao.amount));304      } catch (cErr) {305        credited = false;306        Bot.setProperty("claimed_topup_" + ao.id, false, "boolean");307        Api.sendMessage({ chat_id: chatId, text: "❗ Balance credit FAILED: " + String(cErr.message) });308      }309      if (!credited) { ack("Credit failed", true); return; }310 311      ao.status = "approved";312      ao.decided_by = myId;313      saveOrder(ao.id, ao);314 315      // deposit history (wallet top-ups only, same rule as /onCheck)316      if (ao.prod === null || ao.prod === undefined) {317        try {318          var hist = Bot.getProperty("deposit_history_records");319          if (!Array.isArray(hist)) hist = [];320          hist.push({321            ts: Date.now(), user_id: String(ao.uid), name: String(ao.name || "User"), username: String(ao.username || ""),322            email: "Not provided", amount: Number(ao.amount), utr: "MANUAL", order_id: String(ao.id), gateway: "Manual"323          });324          if (hist.length > 5000) hist = hist.slice(hist.length - 5000);325          Bot.setProperty("deposit_history_records", hist, "json");326        } catch (hErr) {}327      }328 329      var newBal = 0;330      try { newBal = Number(balRes(ao.uid).value()) || 0; } catch (e) {}331      newBal += Number(Bot.getProperty("balance" + ao.uid) || 0);332 333      doneCap = "✅ <b>APPROVED</b> " + esc(decidedBy) + "\n👤 <code>" + esc(ao.uid) + "</code> — ₹" + Number(ao.amount).toFixed(2) + " added\n🔖 <code>" + ao.id + "</code>";334 335      var uKb = (ao.prod !== null && ao.prod !== undefined)336        ? JSON.stringify({ inline_keyboard: [[{ text: "Buy Now", callback_data: "/buyitem " + ao.prod + " " + ao.plan, style: "success" }], [{ text: "Open Shop", callback_data: "/menu", style: "primary" }]] })337        : menuKb;338      try {339        Api.sendMessage({340          chat_id: String(ao.uid), parse_mode: "HTML",341          text: "<blockquote>🎉 <b>PAYMENT SUCCESSFUL</b></blockquote>\n\n💰 <b>₹" + Number(ao.amount).toFixed(2) + "</b> aapke wallet me add ho gaye.\n" +342            "💼 <b>Balance:</b> ₹" + newBal.toFixed(2) +343            ((ao.prod !== null && ao.prod !== undefined) ? "\n\n<i>Ab \"Buy Now\" dabake panel kharido.</i>" : ""),344          reply_markup: uKb345        });346      } catch (e) {}347    }348 349    ack(action === "approve" ? "✅ Approved" : "❌ Cancelled");350    // update the admin card: remove buttons, show the decision351    try {352      if (request && request.message && request.message.message_id) {353        Api.editMessageCaption({354          chat_id: chatId, message_id: Number(request.message.message_id),355          caption: doneCap, parse_mode: "HTML",356          reply_markup: JSON.stringify({ inline_keyboard: [] })357        });358      }359    } catch (e) {}360    return;361  }362 363  ack("");364} catch (err) {365  try { Bot.sendMessage("⚠️ Manual Payment Error: " + err.message); } catch (e2) {}366}
commands/_manualpay.js · tarunpoonia905/OfcDevShopBot · TeleDevs