ayushyadav7970824760/goldensellingstore_botPublic · Bot Template
AIThis Telegram store bot lets customers browse digital products and plans, apply coupons, add funds via UPI, and receive purchased keys. It includes a full admin panel for managing products, reordering items, setting reseller prices, viewing and removing key stock, configuring UPI payment details and update links, and checking user balances. Co-admins and resellers are supported, and support tickets are forwarded to the admin.
Commercedigital_storeadmin_panelupi_paymentsresellercouponskey_stock
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
commands/_mykey.js
javascript · 114 lines
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 // ✅ BUG FIX: Admin ke "Give Key" (manual, no-PID product) se deliver ki29 // gayi keys pehle "My Keys" me kabhi nahi dikhti thi — kyunki wo history30 // admin ke context me Bot-level property me save hoti hai (buyer ke31 // User-property me nahi, kyunki admin ki taraf se buyer ka User object32 // access nahi hota). Ab yahan dono sources merge karke dikhaye jaate hain.33 let manualKeys = Bot.getProperty("manual_key_history_" + String(chatId)) || [];34 if (!Array.isArray(userKeys)) { userKeys = []; }35 if (!Array.isArray(manualKeys)) { manualKeys = []; }36 userKeys = userKeys.concat(manualKeys);37 38 let text = "";39 let keyboard = { inline_keyboard: [] };40 41 if (!userKeys || userKeys.length === 0) {42 text = "<blockquote>" +43 "❌ <b>NO ACTIVE KEYS FOUND</b>" +44 "</blockquote>\n\n" +45 "<i>You have not purchased any keys yet.</i>";46 47 keyboard.inline_keyboard = [48 [49 { text: "𝑷𝒓𝒐𝒅𝒖𝒄𝒕 𝑺𝒕𝒐𝒓𝒆", callback_data: "/buy_hack", style: "success" }50 ],51 [52 { text: "𝑩𝒂𝒄𝒌", callback_data: "/back", style: "danger" }53 ]54 ];55 } else {56 text = "<b>📋 Your Active Keys:</b>\n\n";57 58 for (let i = 0; i < userKeys.length; i++) {59 let keyData = userKeys[i];60 let pName = keyData.productName || keyData.product || "N/A";61 let pPrice = keyData.cost || keyData.price || "0";62 let pKey = keyData.key || "No Key Found";63 let pDays = keyData.days || "N/A";64 let pDate = keyData.date || "N/A";65 66 text += "<blockquote>" +67 "<tg-emoji emoji-id='6192822213486321961'>🗣</tg-emoji> <b>Product Name:</b> " + pName + "\n" +68 "<tg-emoji emoji-id='6266967801580231067'>⏳</tg-emoji> <b>Days:</b> " + pDays + "\n" +69 "<tg-emoji emoji-id='6176966310920983412'>➡️</tg-emoji> <b>Key:</b> <code>" + pKey + "</code>\n" +70 "<tg-emoji emoji-id='6267068789146260253'>🛒</tg-emoji> <b>Price:</b> ₹" + pPrice + "\n" +71 "<tg-emoji emoji-id='5866053971960929280'>📅</tg-emoji> <b>Date:</b> " + pDate +72 "</blockquote>\n";73 }74 75 // Telegram caption/message length limits ke against safety trim (very large history)76 if (text.length > 3800) {77 text = text.substring(0, 3800) + "\n\n<i>... (list truncated — download full receipt from History)</i>";78 }79 80 keyboard.inline_keyboard = [81 [82 { text: "🧾 Download Receipt", callback_data: "/history_receipt", style: "primary" }83 ],84 [85 { text: "Back To Menu", callback_data: "/back", style: "danger" }86 ]87 ];88 }89 90 // ✅ FIX: photo-message ho to delete + fresh send, warna edit; Api.* wrapper use hota hai91 if (request && request.message && request.message.message_id) {92 if (request.message.photo) {93 try { Api.deleteMessage({ chat_id: chatId, message_id: request.message.message_id }); } catch (delErr) {}94 Api.sendMessage({ chat_id: chatId, text: text, parse_mode: "HTML", reply_markup: JSON.stringify(keyboard) });95 } else {96 Api.editMessageText({97 chat_id: chatId,98 message_id: request.message.message_id,99 text: text,100 parse_mode: "HTML",101 reply_markup: JSON.stringify(keyboard)102 });103 }104 } else {105 Api.sendMessage({ chat_id: chatId, text: text, parse_mode: "HTML", reply_markup: JSON.stringify(keyboard) });106 }107 108 var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;109 if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }110 111} catch (err) {112 // ✅ FIX: ab error silently hide nahi hoti — user ko dikhti hai113 try { Bot.sendMessage("⚠️ My Keys Error: " + err.message, { parse_mode: "HTML" }); } catch (e) {}114}