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/_mykey.js

javascript · 102 lines

Raw
1/**#command2name: /mykey3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🔑 MY KEYS — shows all purchased keys14// ✅ BUG FIXES:15// 1. Pehle photo message (Profile se aane par) editMessageText try karta tha16//    jo Telegram me fail hota hai — isi wajah se "My Keys" click karne par17//    kuch dikhta hi nahi tha.18// 2. catch(err) block errors ko SILENTLY hide kar raha tha — koi feedback19//    hi nahi milta tha jab kuch fail hota.20// 3. Raw HTTP.post use ho raha tha bina success/error handling ke — ab21//    consistent Api.* wrapper functions use hote hain (poore bot jaisa).22// =========================================================23 24try {25    let userKeys = User.getProperty("my_purchased_keys");26    let chatId = chat.chatid;27 28    let text = "";29    let keyboard = { inline_keyboard: [] };30 31    if (!userKeys || userKeys.length === 0) {32        text = "<blockquote>" +33            "<tg-emoji emoji-id='6192822213486321961'>🗣</tg-emoji> <b>No keys found!</b>\n" +34            "<tg-emoji emoji-id='5866053971960929280'>💎</tg-emoji> You haven't purchased anything yet." +35            "</blockquote>";36 37        keyboard.inline_keyboard = [38            [39                { text: "Shop Now", callback_data: "/buy_hack", style: "success", icon_custom_emoji_id: "5866053971960929280" },40                { text: "Back", callback_data: "/back", style: "danger", icon_custom_emoji_id: "5893163582194978381" }41            ]42        ];43    } else {44        text = "<b>📋 Your Active Keys:</b>\n\n";45 46        for (let i = 0; i < userKeys.length; i++) {47            let keyData = userKeys[i];48            let pName = keyData.productName || keyData.product || "N/A";49            let pPrice = keyData.cost || keyData.price || "0";50            let pKey = keyData.key || "No Key Found";51            let pDays = keyData.days || "N/A";52            let pDate = keyData.date || "N/A";53 54            text += "<blockquote>" +55                "<tg-emoji emoji-id='6192822213486321961'>🗣</tg-emoji> <b>Product Name:</b> " + pName + "\n" +56                "<tg-emoji emoji-id='6266967801580231067'>⏳</tg-emoji> <b>Days:</b> " + pDays + "\n" +57                "<tg-emoji emoji-id='6176966310920983412'>➡️</tg-emoji> <b>Key:</b> <code>" + pKey + "</code>\n" +58                "<tg-emoji emoji-id='6267068789146260253'>🛒</tg-emoji> <b>Price:</b> ₹" + pPrice + "\n" +59                "<tg-emoji emoji-id='5866053971960929280'>📅</tg-emoji> <b>Date:</b> " + pDate +60                "</blockquote>\n";61        }62 63        // Telegram caption/message length limits ke against safety trim (very large history)64        if (text.length > 3800) {65            text = text.substring(0, 3800) + "\n\n<i>... (list truncated — download full receipt from History)</i>";66        }67 68        keyboard.inline_keyboard = [69            [70                { text: "🧾 Download Receipt", callback_data: "/history_receipt", style: "primary", icon_custom_emoji_id: "6100170496077204999" }71            ],72            [73                { text: "Back To Menu", callback_data: "/back", style: "danger", icon_custom_emoji_id: "5893163582194978381" }74            ]75        ];76    }77 78    // ✅ FIX: photo-message ho to delete + fresh send, warna edit; Api.* wrapper use hota hai79    if (request && request.message && request.message.message_id) {80        if (request.message.photo) {81            try { Api.deleteMessage({ chat_id: chatId, message_id: request.message.message_id }); } catch (delErr) {}82            Api.sendMessage({ chat_id: chatId, text: text, parse_mode: "HTML", reply_markup: JSON.stringify(keyboard) });83        } else {84            Api.editMessageText({85                chat_id: chatId,86                message_id: request.message.message_id,87                text: text,88                parse_mode: "HTML",89                reply_markup: JSON.stringify(keyboard)90            });91        }92    } else {93        Api.sendMessage({ chat_id: chatId, text: text, parse_mode: "HTML", reply_markup: JSON.stringify(keyboard) });94    }95 96    var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;97    if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }98 99} catch (err) {100    // ✅ FIX: ab error silently hide nahi hoti — user ko dikhti hai101    try { Bot.sendMessage("⚠️ My Keys Error: " + err.message, { parse_mode: "HTML" }); } catch (e) {}102}