tarunpoonia905/OfcDevShopBotPublic · Bot Template
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
commands/_confirm_reseller_upgrade.js
javascript · 230 lines
1/**#command2name: /confirm_reseller_upgrade3answer: 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// =========================================================18// 👑 Reseller Upgrade — Confirm button handler19// Balance sufficient -> instant upgrade. Insufficient -> shortfall QR20// (payment completion handled automatically in _onCheck.js).21// =========================================================22 23try {24 var userId = String(user.telegramid);25 var chatId = chat.chatid;26 27 if (Bot.getProperty("is_reseller_" + userId)) {28 Bot.sendMessage("💎 Aap already ek Reseller hain!");29 return;30 }31 32 var price = Number(Bot.getProperty("reseller_upgrade_price") || Bot.getProperty("reseller_price") || 0);33 if (!price) {34 Bot.sendMessage("❌ Reseller Upgrade price admin ne abhi set nahi kiya.");35 return;36 }37 38 var unifiedBal = (function () {39 var resBal = 0;40 try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}41 var bonusBal = Number(Bot.getProperty("balance" + userId) || 0);42 return resBal + bonusBal;43 })();44 45 // ---- Safe screen show: text msg -> edit; photo/GIF/video msg -> delete + fresh send (same pattern as /buy_hack).46 function __showScreen(txt, kb, withEdit) {47 var srcMsg = (request && request.message) ? request.message : null;48 var srcMid = (srcMsg && srcMsg.message_id) ? Number(srcMsg.message_id) : null;49 var srcIsMedia = !!(srcMsg && (srcMsg.photo || srcMsg.video || srcMsg.animation || srcMsg.document));50 var payload = { chat_id: String(chatId), text: txt, parse_mode: "HTML" };51 if (kb) payload.reply_markup = JSON.stringify({ inline_keyboard: kb });52 var sent = null;53 if (srcMid && !srcIsMedia) {54 payload.message_id = srcMid;55 try { sent = Api.editMessageText(payload); } catch (e1) { sent = { ok: false, description: String(e1.message || e1) }; }56 if (sent && sent.ok === false && !/not modified/i.test(String(sent.description || ""))) {57 delete payload.message_id;58 try { sent = Api.sendMessage(payload); } catch (e2) { sent = { ok: false, description: String(e2.message || e2) }; }59 }60 } else {61 if (srcMid) { try { Api.deleteMessage({ chat_id: String(chatId), message_id: srcMid }); } catch (e3) {} }62 try { sent = Api.sendMessage(payload); } catch (e4) { sent = { ok: false, description: String(e4.message || e4) }; }63 }64 // Telegram ne reject kiya (jaise bad HTML/emoji) -> plain text fallback + owner ko reason65 if (sent && sent.ok === false && !/not modified/i.test(String(sent.description || ""))) {66 try { Api.sendMessage({ chat_id: String(Bot.getProperty("owner_id") || "7127818616"), text: "Reseller screen error (user " + userId + "): " + String(sent.description || "unknown").slice(0, 300) }); } catch (e5) {}67 try { Api.sendMessage({ chat_id: String(chatId), text: String(txt).replace(/<[^>]*>/g, ""), reply_markup: kb ? JSON.stringify({ inline_keyboard: kb }) : undefined }); } catch (e6) {}68 }69 return sent;70 }71 72 function grantReseller(chatIdTarget) {73 Bot.setProperty("is_reseller_" + userId, true, "boolean");74 var congratsText =75 "<blockquote><tg-emoji emoji-id='6102856637343600044'>🎉</tg-emoji> <b>CONGRATULATIONS!</b></blockquote>\n\n" +76 "<tg-emoji emoji-id='6215386799133433653'>👑</tg-emoji> <b>You are now a Reseller!</b>\n\n" +77 "<i>Aapko ab har product/plan par reseller pricing milegi, priority processing, aur reseller-only stock ka access. Enjoy your upgraded status!</i>";78 Api.sendMessage({79 chat_id: chatIdTarget,80 text: congratsText,81 parse_mode: "HTML",82 reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Explore Shop", callback_data: "/buy_hack", style: "success", icon_custom_emoji_id: "5866053971960929280" }]] })83 });84 85 var ownerId = Bot.getProperty("owner_id") || "7127818616";86 try {87 Api.sendMessage({88 chat_id: ownerId,89 text: "👑 <b>NEW RESELLER!</b>\n👤 <b>User:</b> <code>" + userId + "</code>\n💰 <b>Paid:</b> ₹" + price.toFixed(2),90 parse_mode: "HTML"91 });92 } catch (e) {}93 }94 95 if (unifiedBal >= price) {96 try { var __b=Number(Bot.getProperty("balance"+userId)||0); var __tb=Math.min(Math.max(__b,0),price); if(__tb>0) Bot.setProperty("balance"+userId,__b-__tb,"number"); var __tw=price-__tb; if(__tw>0) Libs.ResourcesLib.userRes("balance").add(-__tw); } catch (e) {}97 grantReseller(chatId);98 } else {99 var needToPay = Number((price - unifiedBal).toFixed(2));100 var queryIdR = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;101 102 // Sirf wahi gateways jo admin ne ON kiye hain103 var enabledGws = [];104 if (Bot.getProperty("gateway_upi_enabled") !== false) enabledGws.push("upi");105 if (Bot.getProperty("gateway_fampay_enabled") === true) enabledGws.push("fampay");106 if (Bot.getProperty("gateway_zapupi_enabled") === true) enabledGws.push("zapupi");107 108 if (!enabledGws.length) {109 Bot.sendMessage("⚠️ Abhi koi payment method available nahi hai. Thodi der baad try karo.");110 if (queryIdR) { try { Api.answerCallbackQuery({ callback_query_id: String(queryIdR) }); } catch (e) {} }111 return;112 }113 114 var gw = String(params || "").trim().split(/\s+/)[0].toLowerCase();115 if (enabledGws.indexOf(gw) === -1) gw = "";116 if (!gw && enabledGws.length === 1) gw = enabledGws[0];117 118 // Ek se zyada gateway ON hain -> pehle method chuno119 if (!gw) {120 var labels = { upi: "UPI", fampay: "FamPay", zapupi: "Zapupi" };121 var rows = enabledGws.map(function (g) {122 return [{ text: labels[g] + " • Pay ₹" + needToPay.toFixed(2), callback_data: "/confirm_reseller_upgrade " + g, style: "success", icon_custom_emoji_id: "5348392971207194994" }];123 });124 rows.push([{ text: "Back", callback_data: "/back", style: "danger", icon_custom_emoji_id: "5893163582194978381" }]);125 var pickText = "<blockquote>👑 <b>RESELLER UPGRADE</b></blockquote>\n━━━━━━━━━━━━━━━━━━━━━\n\n" +126 "💰 <b>Amount to pay:</b> ₹<code>" + needToPay.toFixed(2) + "</code>\n\n<i>Select a payment method below:</i>";127 __showScreen(pickText, rows);128 if (queryIdR) { try { Api.answerCallbackQuery({ callback_query_id: String(queryIdR) }); } catch (e) {} }129 return;130 }131 132 // Key/config check — message edit se PEHLE (taaki "Creating order..." atka na rahe)133 var famApiKeyR = Bot.getProperty("fampay_merchant_key") || Bot.getProperty("fampay_api_key");134 var paytmUpiR = Bot.getProperty("paytm_upi") || Bot.getProperty("payment_upi_id") || "paytm.s1tk6od@pty";135 var paytmMidR = Bot.getProperty("paytm_merchant_id") || "SDfRhW21109811758334";136 var paytmKeyR = Bot.getProperty("paytm_merchant_key") || "SDfRhW21109811758334";137 var zapKeyR = Bot.getProperty("zapupi_key");138 if (gw === "zapupi" && !zapKeyR) {139 Bot.sendMessage("⚠️ Zapupi gateway abhi admin ne configure nahi kiya hai. /set_payment_zapupi ZAP_KEY chalao.");140 return;141 }142 if (gw === "upi" && (!paytmUpiR || !paytmMidR || !paytmKeyR)) {143 Bot.sendMessage("⚠️ Paytm Business gateway abhi configure nahi hai. Admin se Paytm UPI / Merchant ID / Merchant Key set karwao.");144 return;145 }146 if (gw === "fampay" && !famApiKeyR) {147 Bot.sendMessage("⚠️ FamPay gateway abhi configure nahi hai. /set_payment_fampay UPI_ID|API_KEY chalao.");148 return;149 }150 151 User.setProperty("buy_reseller_upgrade", true, "boolean");152 User.setProperty("buy_reseller_price", price, "number");153 // Background verify (webhook/auto-verify) me ambient User unreliable hota hai -> Bot-level marker bhi rakho.154 Bot.setProperty("reseller_upg_" + userId, price, "number");155 // Amount lock (order-bound lock /onQR ya /zap_onOrder me banta hai)156 User.setProperty("buy_expected_amount", needToPay, "number");157 User.setProperty("pending_pay_amount_" + userId, needToPay.toFixed(2), "string");158 159 var genText = "<tg-emoji emoji-id='6100657257605763582'>⏳</tg-emoji> <b>Creating order for ₹" + needToPay.toFixed(2) + ", please wait...</b>";160 var __gs = __showScreen(genText, null);161 try {162 var __gm = (__gs && __gs.result && __gs.result.message_id) ? __gs.result.message_id : (__gs && __gs.message_id ? __gs.message_id : null);163 if (!__gm && request && request.message && request.message.message_id && !(request.message.photo || request.message.animation || request.message.video || request.message.document)) __gm = request.message.message_id;164 if (__gm) {165 Bot.setProperty("gen_msg_id_" + userId, __gm, "string");166 User.setProperty("gen_msg_id_" + userId, __gm, "string");167 }168 } catch (e) {}169 170 if (gw === "zapupi") {171 var zOid = "ZP" + new Date().getTime() + Math.floor(100 + Math.random() * 900);172 Bot.setProperty("zap_oid_" + userId, zOid, "string");173 Bot.setProperty("zap_amt_" + userId, needToPay.toFixed(2), "string");174 // ⚠️ FIX: customer_mobile + success/failed/timeout_url ke bina ZapUPI175 // create-order ko HTTP level par hi reject kar deta hai ("QR generate176 // nahi ho paya"). Same fix jo /pay_zapupi aur /addbal_zapupi me hai.177 var zBotUserR = String(Bot.getProperty("bot_username") || "JASSMODZSHOP_BOT").replace(/^@/, "");178 HTTP.post({179 url: "https://pay.zapupi.com/api/create-order",180 headers: { "Content-Type": "application/json" },181 body: JSON.stringify({182 zap_key: zapKeyR,183 order_id: zOid,184 amount: needToPay.toFixed(2),185 customer_mobile: String(Bot.getProperty("zapupi_customer_mobile") || "9999999999"),186 remark: "TG" + userId,187 success_url: "https://t.me/" + zBotUserR + "?start=success_" + zOid,188 failed_url: "https://t.me/" + zBotUserR + "?start=failed_" + zOid,189 timeout_url: "https://t.me/" + zBotUserR + "?start=timeout_" + zOid190 }),191 success: "/zap_onOrder",192 error: "/onApiError"193 });194 } else if (gw === "upi") {195 var paytmResellerUrl = "https://paytm.anujbots.xyz/qr.php?upi=" + encodeURIComponent(paytmUpiR) +196 "&amount=" + encodeURIComponent(needToPay.toFixed(2)) +197 "&merchantid=" + encodeURIComponent(paytmMidR) +198 "&merchantkey=" + encodeURIComponent(paytmKeyR);199 HTTP.get({200 url: paytmResellerUrl,201 success: "/onQR",202 error: "/onApiError"203 });204 } else {205 HTTP.post({206 url: "https://famgateway.in/api/create-order",207 headers: { "Content-Type": "application/json", "Authorization": "Bearer " + famApiKeyR, "X-Api-Key": famApiKeyR },208 body: JSON.stringify((function () {209 var ob = { amount: needToPay.toFixed(2), customer_name: String(userId) };210 try { var wu = Webhook.getUrl("fam_webhook", { options: { uid: String(userId) }, expiresIn: 3600 }); if (wu) ob.webhook_url = wu; } catch (whErr) {}211 return ob;212 })()),213 success: "/onQR",214 error: "/onApiError"215 });216 }217 try {218 var qrTsR = String(new Date().getTime());219 Bot.setProperty("qr_gen_ts_" + userId, qrTsR, "string");220 // (TeleBotHost Bot.run me run_after hota hi nahi — docs: command/options/user_id/chat_id/ignoreMissingCommand. Isliye delayed watchdog/poll hata diya.)221 } catch (wdErr) {}222 }223 224 var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;225 if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }226 227} catch (err) {228 try { Bot.sendMessage("⚠️ Error: " + err.message); } catch (e0) {}229 try { Api.sendMessage({ chat_id: String(Bot.getProperty("owner_id") || "7127818616"), text: "/confirm_reseller_upgrade error: " + err.message }); } catch (e00) {}230}