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/_fam_webhook.js
javascript · 69 lines
1/**#command2name: /fam_webhook3answer: 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// 🔔 /fam_webhook — FamGateway payment webhook (TeleBotHost signed USER webhook).19// URL har order ke saath create-order me `webhook_url` ke roop me jaata hai (see /pay_fampay, /addbal_fampay).20//21// Security (3 layer):22// 1) URL TeleBotHost ne sign kiya hai (sig + user + expires) — bina signature ke command chalta hi nahi.23// 2) Order ownership: order_id -> user mapping (fg_order_owner_<id>) match honi chahiye.24// 3) Webhook sirf TRIGGER hai. Paisa tabhi credit hota hai jab hum khud verify-order API se25// (server-to-server, API key ke saath) confirm kar lein + locked amount match ho (/auto_verify_result -> /onCheck).26// =========================================================27function _reply(code, obj) {28 try { if (typeof res !== "undefined" && res) { res.status(code).json(obj); } } catch (e) {}29}30try {31 var ownerId = String(Bot.getProperty("owner_id") || "7127818616");32 var body = (typeof request !== "undefined" && request && request.body) ? request.body : {};33 if (typeof body === "string") { try { body = JSON.parse(body); } catch (e) { body = {}; } }34 var d = (body && body.data && typeof body.data === "object") ? body.data : (body || {});35 36 var uid = String((typeof user !== "undefined" && user && user.telegramid) ? user.telegramid : ((typeof options !== "undefined" && options && options.uid) || ""));37 var oid = String(d.order_id || body.order_id || d.orderId || "").trim();38 var evt = String(body.event || body.type || "").toLowerCase();39 var st = String(d.status || d.payment_status || body.status || "").toLowerCase();40 41 function dbg(tag) {42 if (Bot.getProperty("fam_debug") !== true) return;43 try {44 Api.sendMessage({ chat_id: ownerId, parse_mode: "HTML",45 text: "🔔 <b>fam_webhook</b> (" + tag + ")\nUser: <code>" + uid + "</code>\nOrder: <code>" + oid + "</code>\nEvent: <code>" + evt + "</code> status: <code>" + st + "</code>" });46 } catch (e) {}47 }48 49 // /famwebhooktest self-test50 if (oid === "fg_SELFTEST") { _reply(200, { ok: true, selftest: true }); return; }51 52 if (!uid || !oid) { dbg("missing user/order"); _reply(200, { ok: true, ignored: "missing_order" }); return; }53 54 var paid = /success|paid|captured|complete/.test(evt) || /success|paid|captured|complete/.test(st);55 if (!paid) { dbg("not a success event"); _reply(200, { ok: true, ignored: "not_success_event" }); return; }56 57 var owner = Bot.getProperty("fg_order_owner_" + oid);58 if (!owner || String(owner) !== uid) { dbg("unknown order / owner mismatch"); _reply(200, { ok: true, ignored: "unknown_order" }); return; }59 60 if (Bot.getProperty("claimed_topup_" + oid)) { dbg("duplicate (already credited)"); _reply(200, { ok: true, duplicate: true }); return; }61 62 dbg("accepted -> verifying");63 // Authoritative server-side verify -> /auto_verify_result -> /onCheck (credit)64 Bot.run({ command: "/auto_verify_poll", options: { userId: uid, orderId: oid, attempt: 1, wh: true } });65 _reply(200, { ok: true });66} catch (e) {67 try { Api.sendMessage({ chat_id: String(Bot.getProperty("owner_id") || "7127818616"), text: "⚠️ fam_webhook error: " + e.message }); } catch (e2) {}68 _reply(200, { ok: false });69}