indrajitghosh20006/Testseller_01botPublic · Bot Template

ProfileTelegram

AIThis bot provides an admin‑controlled system for managing user balances, products, and reseller roles. It includes commands to add balances (via manual input, Binance Pay, or UPI), approve and credit payments, and set up product listings with categories and pricing. Admins can also add resellers, view reseller info, and manage stock entries. The bot uses built‑in TeleBotHost APIs such as Bot, Api, HTTP, and Libs for database operations and message handling.

Commerceadminbalanceproductresellerpaymentsbinance
138 commands0 envUpdated 17h agoCreated Sep 27, 2026
Back to folder

commands/_deletekey_now.js

javascript · 96 lines

Raw
1/**#command2name: /deletekey_now3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  var adminId = "7839151435";14  if (String(chat.chatid) !== adminId) return;15 16  var callbackId = request ? request.id : null;17  18  // Data nikalna callback params se19  var dataStr = params ? params.trim() : "";20  if (!dataStr) return;21 22  var parts = dataStr.split("|");23  var keyIndex = Number(parts[0]);24  var prodName = parts[1];25  var cleanPlanDays = parts[2];26 27  var stockKeyText = "stock_" + prodName + "_" + cleanPlanDays;28  var keyStock = Bot.getProperty(stockKeyText) || [];29 30  if (keyStock.length === 0 || keyIndex >= keyStock.length) {31    if (callbackId) {32      Api.answerCallbackQuery({ callback_query_id: callbackId, text: "❌ Key already deleted or missing!", show_alert: true });33    }34    return;35  }36 37  // Key ko array se delete karna38  var removedKeyText = keyStock[keyIndex];39  keyStock.splice(keyIndex, 1);40  41  // Updated text stock ko save karna42  Bot.setProperty(stockKeyText, keyStock, "json");43 44  // 🔄 INDEX BACKUP PIPELINE SYNC (For /buyitem sync)45  var productList = Bot.getProperty("stored_products") || [];46  var prodIdx = -1;47  var planIdx = -1;48  var pDaysNumOnly = cleanPlanDays.replace("_Day", "").trim();49 50  for (var i = 0; i < productList.length; i++) {51    if (productList[i].name.trim().toLowerCase() === prodName.toLowerCase()) {52      prodIdx = i;53      break;54    }55  }56  if (prodIdx !== -1) {57    var plans = productList[prodIdx].plans || [];58    for (var j = 0; j < plans.length; j++) {59      if (String(plans[j].days).trim() === pDaysNumOnly) {60        planIdx = j;61        break;62      }63    }64  }65  if (prodIdx !== -1 && planIdx !== -1) {66    var stockKeyIndex = "stock_" + prodIdx + "_" + planIdx;67    Bot.setProperty(stockKeyIndex, keyStock, "json");68  }69 70  // Final Response & UI update71  var successText = "<blockquote><b>🗑️ KEY SUCCESSFULLY REMOVED</b>\n\n" +72                    "• <b>Product:</b> <code>" + prodName + "</code>\n" +73                    "• <b>Plan:</b> <code>" + cleanPlanDays + "</code>\n" +74                    "• <b>Removed Key:</b> <code>" + removedKeyText + "</code>\n" +75                    "• <b>Remaining Stock:</b> <code>" + keyStock.length + " Keys</code></blockquote>";76 77  // Message text edit karke confirm karna78  if (request && request.message) {79    HTTP.post({80      url: "https://api.telegram.org/bot" + bot.token + "/editMessageText",81      body: {82        chat_id: String(chat.chatid),83        message_id: Number(request.message.message_id),84        text: successText,85        parse_mode: "HTML"86      }87    });88  }89 90  if (callbackId) {91    Api.answerCallbackQuery({ callback_query_id: callbackId, text: "✅ Key Removed!" });92  }93 94} catch (err) {95  Bot.sendMessage("Error: " + err.message);96}