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

javascript · 114 lines

Raw
1/**#command2name: /addbal_all3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ✅ FIXED (v3): dynamic owner_id + co-admin check (same fix as /addbal).13let admin_id = Bot.getProperty("owner_id") || "7839151435";14let requesterId = String(user.telegramid);15let isCoAdmin = Bot.getProperty("co_admin_" + requesterId);16 17if (requesterId === admin_id || isCoAdmin) {18 19    // ✅ FIXED: instantly ack the button press so it doesn't feel stuck/slow.20    if (request && request.id) {21        try {22            HTTP.post({23                url: "https://api.telegram.org/bot" + bot.token + "/answerCallbackQuery",24                body: { callback_query_id: request.id }25            });26        } catch (ackErr) {}27    }28 29    let params = (typeof message !== "undefined" && message) ? message.split(" ") : [];30    let data = params[1];31 32    // Agar amount na mila ho, toh prompt bhejo aur agla text message33    // auto-capture ho jaayega (see _start.js "MODULE 5").34    if (!data || isNaN(parseFloat(data.trim()))) {35        User.setProperty("addbalall_step", "waiting_input", "string");36        Bot.sendMessage(37            "<tg-emoji emoji-id='5409048419211682843'>💵</tg-emoji> <b>Add Balance To ALL Users</b>\n\n" +38            "<i>Kitna amount har user ko add karna hai, sirf number bhejein:</i>\n<code>amount</code>\n\n" +39            "<i>Example:</i> <code>50</code>",40            {parse_mode: "HTML"}41        );42        return;43    }44 45    let amountToAdd = parseFloat(data.trim());46 47    if (isNaN(amountToAdd) || amountToAdd <= 0) {48        Bot.sendMessage("❌ *Invalid Amount!*", {parse_mode: "Markdown"});49        return;50    }51 52    try {53        let userList = Bot.getProperty("all_users_list") || [];54        if (!Array.isArray(userList)) { userList = []; }55 56        if (userList.length === 0) {57            Bot.sendMessage("⚠️ <b>Database Empty:</b> Abhi tak koi bhi user register nahi hua hai.", {parse_mode: "HTML"});58            return;59        }60 61        Bot.sendMessage(62            "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Adding ₹" + amountToAdd + " to " + userList.length + " users, please wait...</b>",63            {parse_mode: "HTML"}64        );65 66        let notificationText =67            "<blockquote>" +68            "<tg-emoji emoji-id='6192822213486321961'>🗣</tg-emoji> Admin Added: " + amountToAdd + "\n" +69            "<tg-emoji emoji-id='6266967801580231067'>💎</tg-emoji> Balance Credited!\n" +70            "<tg-emoji emoji-id='6267068789146260253'>💰</tg-emoji> Wallet Updated\n" +71            "<tg-emoji emoji-id='5866053971960929280'>🛒</tg-emoji> /start TO SHOP NOW" +72            "</blockquote>";73 74        let successCount = 0;75        let failCount = 0;76 77        for (let i = 0; i < userList.length; i++) {78            let targetUserId = userList[i];79            try {80                // Balance add karna81                let targetUserBalance = Libs.ResourcesLib.anotherUserRes("balance", targetUserId);82                targetUserBalance.add(amountToAdd);83                successCount++;84 85                // ✅ FIXED: raw HTTP.post ki jagah Api.sendMessage — zyada reliable delivery.86                try {87                    Api.sendMessage({88                        chat_id: targetUserId,89                        text: notificationText,90                        parse_mode: "HTML"91                    });92                } catch (notifyErr) {93                    // Notification fail hone se balance-add process nahi rukna chahiye94                }95            } catch (userErr) {96                failCount++;97            }98        }99 100        Bot.sendMessage(101            "✅ <b>Bulk Add Balance Complete!</b>\n\n" +102            "💰 <b>Amount per user:</b> ₹" + amountToAdd + "\n" +103            "👥 <b>Success:</b> " + successCount + "\n" +104            "⚠️ <b>Failed:</b> " + failCount,105            {parse_mode: "HTML"}106        );107 108    } catch (err) {109        Bot.sendMessage("⚠️ *Error:* " + err.message, {parse_mode: "Markdown"});110    }111 112} else {113    Bot.sendMessage("❌ You are not authorized to use this command.");114}