kkapil9112/Hguuuuuv45botPublic · Bot Template
AITelegram commerce bot for an admin-managed digital store: admins create categories, products, time-based plans, stock entries and license keys, and can grant reseller roles or adjust user balances. End users can view their balance, start a deposit flow with an inline amount keypad, apply coupon codes, and navigate back to the store menu. It uses Bot properties for product/stock/coupon data and Libs.ResourcesLib for per-user balances.
Commercecommerceshopreselleradmin-panelbalanceproduct-management
102 commands0 envUpdated 29d agoCreated Aug 7, 2026
commands/_deletekey_now.js
javascript · 96 lines
1/**#command2name: /deletekey_now3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13 var adminId = "8812621370";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}