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/_viewprod.js
javascript · 279 lines
1/**#command2name: /viewprod3answer: 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// 📦 Shows a product's plans (Step 2 of the buy flow)19// ✅ CRITICAL BUG FIX: pehle "<tg-emoji emoji-id='X'></tg-emoji>" ek EMPTY20// tag tha (koi fallback character nahi) — Telegram ka HTML parser aise21// malformed tg-emoji tag par POORA MESSAGE hi reject kar deta hai. Isi22// wajah se product par click karne par plan-list screen kabhi aati hi nahi23// thi — poora buy flow yahi pe tootta tha!24// ✅ Photo-message-edit bug bhi fix, aur missing else-branch (fresh send)25// bhi add kiya.26// =========================================================27 28try {29 // 🧹 NAV-CLEAN: koi bhi navigation button (Back/Menu/Shop/Admin) dabane par purane30 // "agla message save karo" wale pending states hata do, taaki aalatu-faalatu31 // purana wizard/upload agle message ko na nigal le. Sirf button-press par chalta hai.32 try {33 if (typeof request !== "undefined" && request && (request.id || request.callback_query)) {34 ["shopmedia_step","wz_state","aiadd_state","set_payment_zapupi_step","set_zapupi_mobile_step",35 "extkey_url_step","extkey_apikey_step","extkey_master_step"].forEach(function (k) {36 try { if (User.getProperty(k)) User.setProperty(k, null, "json"); } catch (e0) {}37 });38 try { if (User.getProperty("ai_chat_active")) User.setProperty("ai_chat_active", false, "boolean"); } catch (e1) {}39 }40 } catch (navE) {}41 42 // 🛠 PANEL MAINTENANCE GUARD43 // Re-check at every purchase/payment stage so an admin can switch a panel44 // OFF even if a user already opened the checkout screen.45 function isPanelUnderMaintenance(product) {46 if (!product) return false;47 var mKey = "panel_maintenance_" +48 String(product.id || product.name || "").toUpperCase().replace(/[^A-Z0-9_-]/g, "_");49 return Bot.getProperty(mKey) === true;50 }51 52 var productList = Bot.getProperty("stored_products") || [];53 var callbackId = request ? request.id : null;54 var chatId = chat.chatid;55 var messageId = request && request.message ? request.message.message_id : (request ? request.message_id : null);56 // photo / video / GIF / document message par text-edit nahi hota -> delete + fresh send57 var isPhotoMsg = !!(request && request.message && (request.message.photo || request.message.video || request.message.animation || request.message.document));58 59 var userId = user.telegramid;60 var isReseller = Bot.getProperty("is_reseller_" + userId) === true;61 62 var productIndex = params ? params.trim() : "";63 if (productIndex === "") {64 var cbData = request && request.callback_query ? request.callback_query.data : "";65 productIndex = cbData.replace("/viewprod ", "").replace("viewprod ", "");66 }67 68 var selectedProduct = productList[Number(productIndex)];69 70 if (selectedProduct) {71 var viewMaintKey = "panel_maintenance_" +72 String(selectedProduct.id || selectedProduct.name || productIndex).toUpperCase().replace(/[^A-Z0-9_-]/g, "_");73 if (Bot.getProperty(viewMaintKey) === true) {74 var maintenanceLink = String(selectedProduct.maintenance_link || "").trim();75 var viewMaintText =76 "<tg-emoji emoji-id='6194949330399407789'>🛠️</tg-emoji> <b>Ye product abhi maintenance mein hai.</b>\n\n" +77 "<tg-emoji emoji-id='6215414866744712399'>📥</tg-emoji> <b>Update Files neeche open karo.</b>";78 var viewMaintMarkup = { inline_keyboard: [79 maintenanceLink80 ? [{ text: "Update Files", url: maintenanceLink, style: "success", icon_custom_emoji_id: "6143177515440544964" }]81 : [{ text: "⚠️ Update Link Not Set", callback_data: "/viewprod " + String(productIndex), style: "danger" }],82 [{ text: "⬅️ Back to Shop", style: "danger", callback_data: "/buy_hack", icon_custom_emoji_id: "5893163582194978381" }]83 ] };84 if (messageId && !isPhotoMsg) {85 try {86 Api.editMessageText({87 chat_id: chatId,88 message_id: Number(messageId),89 text: viewMaintText,90 parse_mode: "HTML",91 reply_markup: JSON.stringify(viewMaintMarkup)92 });93 } catch (e) {94 Api.sendMessage({ chat_id: chatId, text: viewMaintText, parse_mode: "HTML", reply_markup: JSON.stringify(viewMaintMarkup) });95 }96 } else {97 if (messageId && isPhotoMsg) { try { Api.deleteMessage({ chat_id: chatId, message_id: Number(messageId) }); } catch (e) {} }98 Api.sendMessage({ chat_id: chatId, text: viewMaintText, parse_mode: "HTML", reply_markup: JSON.stringify(viewMaintMarkup) });99 }100 return;101 }102 }103 104 if (!selectedProduct) {105 if (callbackId) {106 try { Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "⚠️ Product not found!", show_alert: true }); } catch (e) {}107 }108 return;109 }110 111 var planButtons = [];112 var planLines = [];113 var plans = selectedProduct.plans || [];114 115 if (plans.length === 0) {116 // Same naam ka dusra entry (duplicate product) jisme plans hain -> usi par le chalo, taaki index sahi rahe.117 var __nm = String(selectedProduct.name || "").trim().toLowerCase();118 for (var __k = 0; __k < productList.length; __k++) {119 var __c = productList[__k];120 if (__c && __k !== Number(productIndex) && String(__c.name || "").trim().toLowerCase() === __nm && Array.isArray(__c.plans) && __c.plans.length) {121 productIndex = String(__k); selectedProduct = __c; plans = __c.plans; break;122 }123 }124 }125 if (plans.length === 0) {126 // Pehle yaha fake demo plans (1 Day/7 Days) dikhte the jo asli list me the hi nahi -> kharidte time "configuration missing" aata tha.127 if (callbackId) {128 try { Api.answerCallbackQuery({ callback_query_id: String(callbackId), text: "Is panel ke plans abhi available nahi hain.", show_alert: true }); } catch (e) {}129 }130 return;131 }132 133 // User-specific price is resolved here for the exact Telegram member.134 // Global normal/reseller prices remain untouched.135 for (var j = 0; j < plans.length; j++) {136 var plan = plans[j];137 var planUnit = plan.unit || "day";138 139 var cleanProdName = selectedProduct.name.trim().toUpperCase();140 var cleanPlanDays = String(plan.days).replace(/[^0-9.]/g, "").trim();141 142 var priceKeySuffix = (planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_" + planUnit);143 var normalKey = "price_normal_" + cleanProdName + "_" + priceKeySuffix;144 var resellerKey = "price_reseller_" + cleanProdName + "_" + priceKeySuffix;145 146 var adminNormalPrice = Bot.getProperty(normalKey);147 var adminResellerPrice = Bot.getProperty(resellerKey);148 149 var currentNormal = (adminNormalPrice !== undefined && adminNormalPrice !== null) ? adminNormalPrice : plan.normal_price;150 var currentReseller = (adminResellerPrice !== undefined && adminResellerPrice !== null) ? adminResellerPrice : plan.reseller_price;151 152 var baseDisplayPrice = isReseller ? Number(currentReseller) : Number(currentNormal);153 var memberPriceKey = "member_custom_price_" + userId + "_" + cleanProdName.replace(/[^A-Z0-9_-]/g, "_") + "_" + ((planUnit === "day") ? cleanPlanDays : (cleanPlanDays + "_hour"));154 var memberCustomPrice = Bot.getProperty(memberPriceKey);155 var hasMemberCustomPrice = memberCustomPrice !== undefined && memberCustomPrice !== null && isFinite(Number(memberCustomPrice));156 var displayPrice = hasMemberCustomPrice ? Number(memberCustomPrice) : baseDisplayPrice;157 158 var unitLabelWord = (planUnit === "hour") ? (Number(cleanPlanDays) === 1 ? "HOUR" : "HOURS") :159 (planUnit === "minute") ? (Number(cleanPlanDays) === 1 ? "MINUTE" : "MINUTES") :160 (Number(cleanPlanDays) === 1 ? "DAY" : "DAYS");161 var dayLabel = plan.durationDisplay || (cleanPlanDays + " " + unitLabelWord);162 163 // Live manual stock count is isolated by Product + Duration + Unit.164 var stockProductSlug = cleanProdName.replace(/[^A-Z0-9_-]/g, "_");165 var stockStorageKey = "manual_keys_" + stockProductSlug + "_" + cleanPlanDays + "_" + planUnit;166 var liveStock = Bot.getProperty(stockStorageKey) || [];167 if (!Array.isArray(liveStock)) liveStock = [];168 169 // Backward compatibility for old Day-only manual stock.170 if (liveStock.length === 0 && planUnit === "day") {171 var legacyStock = Bot.getProperty("manual_keys_" + cleanProdName + "_" + cleanPlanDays) || [];172 if (Array.isArray(legacyStock)) liveStock = legacyStock;173 }174 175 // Stock is tracked internally for delivery, but deliberately hidden from the customer UI.176 // Price → duration, using the requested custom emoji ID.177 var priceEmoji = "<tg-emoji emoji-id='6199422882435571592'>💲</tg-emoji>";178 var durationEmoji = "<tg-emoji emoji-id='5787432469598835099'>⏱️</tg-emoji>";179 planLines.push(180 priceEmoji + " <b>₹" + Number(displayPrice).toFixed(2) + "</b> — " +181 durationEmoji + " <b>" + dayLabel.toUpperCase() + "</b>" +182 (hasMemberCustomPrice ? " 👤" : "")183 );184 185 // Buttons stay tied to the exact panel/plan/member-specific price.186 // Do not expose stock count on the customer-facing button.187 planButtons.push([188 {189 text: dayLabel.toUpperCase() + " — ₹" + Number(displayPrice).toFixed(2),190 callback_data: "/buyitem " + productIndex + " " + j,191 style: "success",192 icon_custom_emoji_id: "5787432469598835099"193 }194 ]);195 }196 197 // 🔗 Share Link button — SIRF owner/co-admin ko dikhta hai, normal users ko nahi.198 var svOwner = String(Bot.getProperty("owner_id") || "7127818616");199 if (String(userId) === svOwner || Bot.getProperty("co_admin_" + String(userId))) {200 planButtons.push([201 { text: "Share Link", callback_data: "/share_product " + productIndex, style: "primary", icon_custom_emoji_id: "6091571559233755994" }202 ]);203 }204 205 // ✅ NEW: Back button ab is product ki category wali list par le jaata hai206 // (Android Root / Android Non Root), generic /buy_hack (category-select) par nahi.207 var backCategory = selectedProduct.category ? String(selectedProduct.category).toLowerCase() : "both";208 var backCallback = (backCategory === "root") ? "/buy_hack_cat root" : (backCategory === "iphone") ? "/buy_hack_cat iphone" : "/buy_hack_cat nonroot";209 210 planButtons.push([211 {212 text: "Back to Shop",213 callback_data: backCallback,214 style: "danger",215 icon_custom_emoji_id: "5893163582194978381"216 }217 ]);218 219 // ✅ FIX: empty tg-emoji tag hata diya — ab sirf plain product emoji text hai220 var planText =221 "<blockquote>🛒 <b>" + selectedProduct.name.toUpperCase() + "</b> 🛒</blockquote>\n\n" +222 "<blockquote><tg-emoji emoji-id='6102685285328362759'>👑</tg-emoji> <b>Your Account Tier: " + (isReseller ? "RESELLER" : "USER") + "</b></blockquote>\n\n" +223 "<tg-emoji emoji-id='6188354631454694966'>🛒</tg-emoji> <b>Choose your access plan:</b>\n\n" +224 planLines.join("\n") + "\n\n" +225 "<blockquote><tg-emoji emoji-id='6311831672744580735'>👇</tg-emoji> <i>Tap any plan below to continue</i></blockquote>";226 227 228 var replyMarkupStr = JSON.stringify({ inline_keyboard: planButtons });229 230 // 🎮 Product Gameplay Video / GIF — admin: /admin → "🎮 Product Gameplay Video"231 // Key product ki id/name se bandhi hai (list ka index badalne par bhi sahi product se juda rehta hai).232 var gpKey = "product_media_" + String(selectedProduct.id || selectedProduct.name || productIndex).toUpperCase().replace(/[^A-Z0-9_-]/g, "_");233 var gpMedia = Bot.getProperty(gpKey);234 if (typeof gpMedia === "string") { try { gpMedia = JSON.parse(gpMedia); } catch (eGp) { gpMedia = null; } }235 var hasGp = !!(gpMedia && gpMedia.file_id && (gpMedia.type === "animation" || gpMedia.type === "video"));236 237 // Caption limit 1024. Zyada plans hon to compact text, phir bhi lamba ho to text-only.238 var gpCaption = planText;239 if (hasGp && gpCaption.replace(/<[^>]*>/g, "").length > 1000) {240 gpCaption = "<blockquote>🛒 <b>" + selectedProduct.name.toUpperCase() + "</b> 🛒</blockquote>\n\n" + planLines.join("\n");241 if (gpCaption.replace(/<[^>]*>/g, "").length > 1000) { hasGp = false; }242 }243 244 if (hasGp) {245 var gpPayload = { chat_id: chatId, caption: gpCaption, parse_mode: "HTML", reply_markup: replyMarkupStr };246 if (gpMedia.type === "animation") {247 gpPayload.animation = String(gpMedia.file_id);248 Api.sendAnimation(gpPayload);249 } else {250 gpPayload.video = String(gpMedia.file_id);251 gpPayload.supports_streaming = true;252 Api.sendVideo(gpPayload);253 }254 if (messageId) { try { Api.deleteMessage({ chat_id: chatId, message_id: Number(messageId) }); } catch (e) {} }255 } else if (messageId) {256 if (isPhotoMsg) {257 try { Api.deleteMessage({ chat_id: chatId, message_id: messageId }); } catch (e) {}258 Api.sendMessage({ chat_id: chatId, text: planText, parse_mode: "HTML", reply_markup: replyMarkupStr });259 } else {260 Api.editMessageText({261 chat_id: chatId,262 message_id: Number(messageId),263 text: planText,264 parse_mode: "HTML",265 reply_markup: replyMarkupStr266 });267 }268 } else {269 // ✅ FIX: pehle is case me kuch bhejta hi nahi tha270 Api.sendMessage({ chat_id: chatId, text: planText, parse_mode: "HTML", reply_markup: replyMarkupStr });271 }272 273 if (callbackId) {274 try { Api.answerCallbackQuery({ callback_query_id: String(callbackId) }); } catch (e) {}275 }276 277} catch (err) {278 Bot.sendMessage("⚠️ View Product Error: " + err.message, { parse_mode: "HTML" });279}