indrajitghosh20006/HgfhhuybotPublic · Bot Template

ProfileTelegram

AIThis bot provides a command‑based admin interface for managing user balances, products, and resellers. It supports adding balances via UPI or Binance Pay, approving payments, and configuring product details and categories. The bot also handles user role changes, stock uploads, and offers a simple calculator UI for entering amounts. All interactions are handled through short commands and inline keyboards, with no long‑running listeners or external frameworks.

Utilityadminbalanceproductresellerpaymentupi
138 commands0 envUpdated 15h agoCreated Sep 27, 2026
Back to folder

commands/_clearstock.js

javascript · 117 lines

Raw
1/**#command2name: /clearstock3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  var ADMIN_ID = "7839151435";14 15  if (String(user.telegramid) !== ADMIN_ID) {16    return;17  }18 19  // FIX 1: Message aur Params dono check karein (Button callback aur Direct typing dono handle karne ke liye)20  var input = (message || "").trim();21  var catSlug = "";22 23  if (params && params.trim() !== "") {24    catSlug = params.trim().toLowerCase();25  } else if (input.indexOf(" ") !== -1) {26    catSlug = input.split(" ")[1].trim().toLowerCase();27  } else {28    Bot.sendMessage("⚠️ <b>Format:</b> <code>/clearstock [category_slug]</code>\n\n<i>Example: /clearstock lodu</i>", { parse_mode: "HTML" });29    return;30  }31 32  var categories = Bot.getProperty("ff_categories") || {};33 34  if (!categories[catSlug]) {35    Bot.sendMessage(36      "❌ Category <code>" + catSlug + "</code> not found.",37      { parse_mode: "HTML" }38    );39    return;40  }41 42  // Stock check43  var oldStock = categories[catSlug].stock_list || Bot.getProperty("ff_stock_" + catSlug) || [];44  if (!Array.isArray(oldStock)) { oldStock = []; }45 46  var catName = categories[catSlug].name ? categories[catSlug].name.toUpperCase() : catSlug.toUpperCase();47 48  // HTML Content Builder49  var text = "<blockquote><tg-emoji emoji-id='5447644880824181073'>⚠️</tg-emoji> <b>CONFIRM STOCK DELETION</b></blockquote>\n" +50             "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +51             "📁 <b>Category:</b> <code>" + catName + "</code>\n" +52             "📦 <b>Total Items:</b> <code>" + oldStock.length + "</code>\n" +53             "━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" +54             "📋 <b>LIVE STOCK LIST:</b>\n\n";55 56  if (oldStock.length > 0) {57    for (var i = 0; i < oldStock.length; i++) {58      var rawItem = oldStock[i];59      var email = "N/A";60      var pass = "N/A";61      var price = "N/A"; // Added Price Variable62 63      // FIX 2: email|password|price dynamic parsing logic64      if (typeof rawItem === "string") {65        if (rawItem.indexOf("|") !== -1) {66          var parts = rawItem.split("|");67          email = parts[0] ? parts[0].trim() : "N/A";68          pass = parts[1] ? parts[1].trim() : "N/A";69          price = parts[2] ? parts[2].trim() : "N/A"; // Extra Price extraction70        } else {71          email = rawItem.trim();72        }73      } else if (rawItem && typeof rawItem === "object") {74        email = rawItem.email || rawItem.username || "N/A";75        pass = rawItem.password || rawItem.pass || "N/A";76        price = rawItem.price || "N/A";77      }78 79      text += "🆔 <b>Item #" + (i + 1) + "</b>\n" +80              "📧 <b>Email:</b> <code>" + email + "</code>\n" +81              "🔑 <b>Pass:</b> <code>" + pass + "</code>\n" +82              "💰 <b>Price:</b> <code>₹" + price + "</code>\n\n"; // Rendered Price beautifully83    }84  } else {85    text += "❌ <i>Stock is already empty!</i>\n";86  }87 88  text += "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +89          "<i>Are you sure you want to permanently delete all items?</i>";90 91  // Inline Buttons92  var inlineButtons = [];93  if (oldStock.length > 0) {94    inlineButtons.push([95      { 96        text: "🗑️ Delete All Stock", 97        callback_data: "/confirm_delete_stock " + catSlug 98      }99    ]);100  }101  inlineButtons.push([102    { text: "❌ Cancel", callback_data: "/back" }103  ]);104 105  Api.sendMessage({106    chat_id: chat.chatid,107    text: text,108    reply_markup: JSON.stringify({ inline_keyboard: inlineButtons }),109    parse_mode: "HTML"110  });111 112} catch (e) {113  Bot.sendMessage(114    "❌ <b>Error:</b>\n<code>" + e.message + "</code>",115    { parse_mode: "HTML" }116  );117}