amanjha18v/AMAN_SHOPS_BOTPublic · Bot Template
AIAMAN SHOP STORE appears to be a Telegram automation bot. Commands include /*, /addbal, /addbal_all, /addbal_binance, /addbal_binance_approve, /addbal_binance_paid, /addbal_upi, /addcat_id. Observed in code: messaging, http, libs, keyboards, payments.
Utilityutility
132 commands0 envUpdated 7h agoCreated Sep 4, 2026
commands/_checkbal.js
javascript · 98 lines
1/**#command2name: /checkbal3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13 // ✅ FIXED (v3): dynamic owner_id + co-admin check (same fix as /addbal).14 var adminId = Bot.getProperty("owner_id") || "5191323229";15 var isCoAdmin = Bot.getProperty("co_admin_" + String(chat.chatid));16 if (String(chat.chatid) !== adminId && !isCoAdmin) return;17 18 // ✅ FIXED: instantly ack the button press so it doesn't feel stuck/slow.19 if (request && request.id) {20 try {21 HTTP.post({22 url: "https://api.telegram.org/bot" + bot.token + "/answerCallbackQuery",23 body: { callback_query_id: request.id }24 });25 } catch (ackErr) {}26 }27 28 // Expected Usage: /checkbal USER_ID29 // Bot.run() forwards the entered text through `message`, not `params`.30 // Accept both forms so the ID sent after the prompt is actually processed.31 var rawInput = (typeof message !== "undefined" && message) ? String(message).trim() : "";32 var targetId = "";33 if (rawInput) {34 var inputParts = rawInput.split(/\s+/);35 targetId = inputParts.length > 1 ? inputParts[1].trim() : inputParts[0].trim();36 }37 if (!targetId && typeof params !== "undefined" && params) {38 targetId = String(params).trim();39 }40 41 // ✅ FIXED: same button-click bug as /addbal — ab prompt aata hai.42 if (!targetId || isNaN(targetId)) {43 User.setProperty("checkbal_step", "waiting_input", "string");44 Bot.sendMessage(45 "<tg-emoji emoji-id='6039605143601680423'>📊</tg-emoji> <b>Check Balance</b>\n\n" +46 "<i>Jis user ka balance check karna hai uski User ID reply karein:</i>\n<code>5191323229</code>",47 { parse_mode: "HTML" }48 );49 return;50 }51 52 // 👤 USER DETAILS53 // User properties are scoped to the current user in Bot Builder, so when an54 // admin checks another ID we use globally stored values where available.55 var name = Bot.getProperty("name_" + targetId) || Bot.getProperty("user_name_" + targetId) || "N/A";56 var username = Bot.getProperty("username_" + targetId) || Bot.getProperty("user_username_" + targetId) || "N/A";57 if (String(targetId) === String(user.telegramid)) {58 name = user.first_name || name;59 username = user.username ? "@" + user.username : username;60 }61 62 // 💰 READ THE SAME WALLET SOURCES USED BY THE STORE63 var userResBalance = 0;64 try { userResBalance = Number(Libs.ResourcesLib.anotherUserRes("balance", targetId).value() || 0); } catch (e1) {}65 var adminCustomBal = Number(Bot.getProperty("balance" + targetId) || 0);66 var totalUserBal = (userResBalance + adminCustomBal).toFixed(2);67 68 // 📉 TOTAL INVEST69 var totalSpent = Number(Bot.getProperty("total_spent_by_" + targetId) || 0);70 var formattedSpent = totalSpent.toFixed(2);71 72 // 🔑 TOTAL KEYS — use any existing per-user counter if present.73 // The original project stores `my_purchased_keys` as a User property, which74 // cannot be read for another user from an admin command. Do not invent a count.75 var totalKeys = Bot.getProperty("total_keys_purchased_" + targetId);76 if (totalKeys === undefined || totalKeys === null || totalKeys === "") {77 totalKeys = Bot.getProperty("purchase_count_" + targetId);78 }79 if (totalKeys === undefined || totalKeys === null || totalKeys === "") {80 totalKeys = 0;81 }82 totalKeys = Number(totalKeys);83 if (!isFinite(totalKeys) || totalKeys < 0) totalKeys = 0;84 85 // 📄 FINAL RESPONSE BOX86 var messageText = "<blockquote><b><tg-emoji emoji-id='6039605143601680423'>📊</tg-emoji> USER ACCOUNT DETAILS</b>\n\n" +87 "• <b>Name:</b> " + name + "\n" +88 "• <b>Username:</b> " + username + "\n" +89 "• <b>User ID:</b> <code>" + targetId + "</code>\n" +90 "• <b>Balance:</b> <code>₹" + totalUserBal + "</code>\n" +91 "• <b>Total Keys:</b> <code>" + totalKeys + "</code>\n" +92 "• <b>Total Invest:</b> <code>₹" + formattedSpent + "</code></blockquote>";93 94 Bot.sendMessage(messageText, { parse_mode: "HTML" });95 96} catch (err) {97 Bot.sendMessage("⚠️ Error: " + err.message);98}