ayushyadav7970824760/goldensellingstore_botPublic · Bot Template
AIThis Telegram store bot lets customers browse digital products and plans, apply coupons, add funds via UPI, and receive purchased keys. It includes a full admin panel for managing products, reordering items, setting reseller prices, viewing and removing key stock, configuring UPI payment details and update links, and checking user balances. Co-admins and resellers are supported, and support tickets are forwarded to the admin.
Commercedigital_storeadmin_panelupi_paymentsresellercouponskey_stock
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
commands/_toggle_stock.js
javascript · 84 lines
1/**#command2name: /toggle_stock3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🔧 ADMIN PANEL — "Toggle Product Stock"14// Sabhi products ki list dikhata hai, current status ke saath (✅ In Stock /15// 🔧 Under Maintenance). Tap karne par woh product turant toggle ho jaata16// hai — koi extra confirmation step nahi, taaki jaldi se on/off kiya ja sake.17// =========================================================18 19try {20 var adminId = Bot.getProperty("owner_id") || "8477746023";21 var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));22 if (String(chat.chatid) !== adminId && !isCoAdmin0) {23 Bot.sendMessage("❌ You are not authorized to use this.");24 return;25 }26 27 var callbackId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;28 29 var productList = Bot.getProperty("stored_products") || [];30 if (!Array.isArray(productList)) { productList = []; }31 32 // Agar ek product index diya gaya hai (button click se), toggle kar do33 var toggleIdx = params ? String(params).trim() : "";34 if (toggleIdx !== "" && productList[Number(toggleIdx)]) {35 var idx = Number(toggleIdx);36 productList[idx].out_of_stock = !(productList[idx].out_of_stock === true);37 Bot.setProperty("stored_products", productList, "json");38 if (callbackId) {39 try {40 Api.answerCallbackQuery({41 callback_query_id: String(callbackId),42 text: productList[idx].out_of_stock ? "🔧 Marked Under Maintenance" : "✅ Marked In Stock"43 });44 } catch (e) {}45 }46 }47 48 if (productList.length === 0) {49 Bot.sendMessage("⚠️ Koi products add nahi kiye gaye hain abhi tak.", { parse_mode: "HTML" });50 return;51 }52 53 var text = "<blockquote>🔧 <b>TOGGLE PRODUCT STOCK</b></blockquote>\n\n" +54 "<i>Kisi bhi product par tap karein — status turant toggle hoga. 🔴 Maintenance par product ka button sirf red ho jayega.</i>\n\n";55 56 var rows = [];57 for (var i = 0; i < productList.length; i++) {58 var p = productList[i];59 if (!p) { continue; }60 var isOOS = p.out_of_stock === true;61 var label = (isOOS ? "🔧 " : "✅ ") + p.name;62 rows.push([{ text: label, callback_data: "/toggle_stock " + i, style: isOOS ? "danger" : "success" }]);63 }64 rows.push([{ text: "Back to Admin Panel", callback_data: "/admin", style: "primary" }]);65 66 if (request && request.message && request.message.message_id) {67 try {68 Api.editMessageText({69 chat_id: String(chat.chatid),70 message_id: Number(request.message.message_id),71 text: text,72 parse_mode: "HTML",73 reply_markup: JSON.stringify({ inline_keyboard: rows })74 });75 } catch (e) {76 Api.sendMessage({ chat_id: chat.chatid, text: text, parse_mode: "HTML", reply_markup: JSON.stringify({ inline_keyboard: rows }) });77 }78 } else {79 Bot.sendMessage(text, { parse_mode: "HTML", reply_markup: JSON.stringify({ inline_keyboard: rows }) });80 }81 82} catch (err) {83 Bot.sendMessage("⚠️ Error: " + err.message);84}