indrajitghosh20006/HgfhhuybotPublic · Bot Template
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
commands/_select_id_product.js
javascript · 163 lines
1/**#command2name: /select_id_product3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13 // 🔥 CALLBACK DATA CLEARING & PARAM EXTRACTION PIPELINE14 var rawParams = "";15 if (typeof params !== "undefined" && params) {16 rawParams = String(params).trim();17 }18 19 // Fallback check agar dynamic params system bypass ho gaya ho20 if (!rawParams && typeof request !== "undefined" && request) {21 var callbackQuery = request.callback_query || request;22 if (callbackQuery && callbackQuery.data) {23 var dataStr = String(callbackQuery.data).trim();24 var parts = dataStr.split(" ");25 if (parts.length > 1) {26 rawParams = parts.slice(1).join(" ").trim();27 } else {28 rawParams = dataStr;29 }30 }31 32 // Clear loading spinner instantly33 let queryId = request.id || (request.callback_query && request.callback_query.id);34 if (queryId) {35 try { Api.answerCallbackQuery({ callback_query_id: queryId }); } catch (qErr){}36 }37 }38 39 // Safe Chat ID fallback40 var targetChatId = (chat && chat.chatid) ? chat.chatid : ((chat && chat.id) ? chat.id : (user ? user.telegramid : null));41 42 if (!targetChatId) return; // Silent guard if no context exists43 44 // 🛡️ SECURITY & EMPTY PARAM CHECK FIX45 if (!rawParams || rawParams.indexOf("/") === 0) { 46 Api.sendMessage({47 chat_id: targetChatId,48 text: "<tg-emoji emoji-id='5244837092042750681'>⚠️</tg-emoji> <b>Session Expired or Invalid Selection.</b>\n\nKripya main menu se phir se product select karein.",49 parse_mode: "HTML"50 });51 return;52 }53 54 var categories = Bot.getProperty("ff_categories") || {};55 56 if (!categories[rawParams]) {57 Api.sendMessage({58 chat_id: targetChatId,59 text: "❌ <b>Product nahi mila ya remove ho chuka hai!</b>\nSelected Slug: <code>" + rawParams + "</code>",60 parse_mode: "HTML"61 });62 return;63 }64 65 var item = categories[rawParams];66 var stockList = Bot.getProperty("ff_stock_" + rawParams) || [];67 68 if (!Array.isArray(stockList)) stockList = [];69 70 // Safe user role derivation71 var userId = (user && user.telegramid) ? user.telegramid : targetChatId;72 var isReseller = Bot.getProperty("is_reseller_" + userId);73 var hasResellerAccess = (isReseller === true || String(isReseller).toLowerCase() === "true");74 75 var price = hasResellerAccess76 ? (item.reseller_price !== undefined && item.reseller_price !== null ? item.reseller_price : (item.normal_price || 0))77 : (item.normal_price || 0);78 79 // 💎 MULTIPLE PREMIUM EMOJIS INTEGRATION & BOLD LAYOUT (NEW EMOJIS MIXED)80 var text =81 "┏━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +82 "┃ <tg-emoji emoji-id='6267140231632262769'>❤️🔥</tg-emoji> <b>ALL DETAILS</b> <tg-emoji emoji-id='6267140231632262769'>❤️🔥</tg-emoji> ┃\n" +83 "┗━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n" +84 "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +85 "<tg-emoji emoji-id='5244837092042750681'>✨</tg-emoji> <b>PRODUCT DETAILS:</b>\n\n" +86 "<tg-emoji emoji-id='6267129592998270736'>📣</tg-emoji> <b>Product Name :</b> <code>" + item.name + "</code>\n\n" +87 "<tg-emoji emoji-id='6062310436672377598'>🪐</tg-emoji> <b>Current Stocks :</b> <code>" + stockList.length + " accounts</code>\n\n" +88 "<tg-emoji emoji-id='6266995104687330978'>📈</tg-emoji> <b>Price:</b> <code>₹" + price + "</code>\n\n" +89 "<tg-emoji emoji-id='4967656361073574498'>👑</tg-emoji> <b>Account Type :</b> <b>" + (hasResellerAccess ? "Reseller" : "User") + "</b>\n" +90 "━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" +91 "<tg-emoji emoji-id='6057728771719435723'>⚡</tg-emoji> <i>Kripya confirmation ke liye niche diye gaye button par click karein.</i>";92 93 // Dynamic Button Configuration94 var purchaseButtonText = "Confirm Purchase";95 var purchaseButtonStyle = "success"; 96 var purchaseEmojiId = "6062310436672377598"; 97 98 if (stockList.length === 0) {99 purchaseButtonText = "❌ Out of Stock";100 purchaseButtonStyle = "danger"; 101 purchaseEmojiId = "5197288647275071607"; 102 }103 104 var buttons = {105 inline_keyboard: [106 [107 {108 text: purchaseButtonText,109 callback_data: stockList.length > 0 ? "/execute_id_buy " + rawParams : "/ff_id_menu",110 style: purchaseButtonStyle,111 icon_custom_emoji_id: purchaseEmojiId112 }113 ],114 [115 {116 text: "Back to Menu",117 callback_data: "/ff_id_menu",118 style: "danger",119 icon_custom_emoji_id: "5893163582194978381"120 }121 ]122 ]123 };124 125 var targetMessageId = (typeof request !== "undefined" && request && request.message) ? request.message.message_id : null;126 127 // Render logic handling128 if (targetMessageId) {129 try {130 Api.editMessageText({131 chat_id: targetChatId,132 message_id: targetMessageId,133 text: text,134 parse_mode: "HTML",135 reply_markup: JSON.stringify(buttons)136 });137 } catch (err) {138 Api.sendMessage({139 chat_id: targetChatId,140 text: text,141 parse_mode: "HTML",142 reply_markup: JSON.stringify(buttons)143 });144 }145 } else {146 Api.sendMessage({147 chat_id: targetChatId,148 text: text,149 parse_mode: "HTML",150 reply_markup: JSON.stringify(buttons)151 });152 }153 154} catch (e) {155 var errorChatId = (chat && chat.chatid) ? chat.chatid : ((user && user.telegramid) ? user.telegramid : "7839151435");156 try {157 Api.sendMessage({158 chat_id: errorChatId,159 text: "❌ <b>Checkout Error:</b>\n<code>" + e.message + "</code>",160 parse_mode: "HTML"161 });162 } catch(fatal){}163}