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
ProfileTelegram
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
Back to folder

commands/_export_users.js

javascript · 69 lines

Raw
1/**#command2name: /export_users3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 📥 ADMIN PANEL — "Export Users List"14// Bot ke sabhi users (jinhone kabhi /start kiya hai) ki CSV file bhejta15// hai — User ID, Phone Number (agar verify ke waqt mila), Joined Date,16// aur current Wallet Balance ke saath.17// =========================================================18 19try {20  var adminId = Bot.getProperty("owner_id") || "8477746023";21  var isCoAdmin0 = Bot.getProperty("co_admin_" + String(chat.chatid));22  if (String(chat.chatid) !== adminId && !isCoAdmin0) {23    Bot.sendMessage("❌ You are not authorized to use this.");24    return;25  }26 27  var userList = Bot.getProperty("all_users_list") || [];28  if (!Array.isArray(userList) || userList.length === 0) {29    Bot.sendMessage("⚠️ Abhi tak koi user track nahi hua hai.", { parse_mode: "HTML" });30    return;31  }32 33  var lines = [];34  lines.push("User ID,Phone Number,Joined Date,Wallet Balance (INR)");35 36  for (var i = 0; i < userList.length; i++) {37    var uid = String(userList[i]);38    var phone = Bot.getProperty("phone_" + uid) || "Not Shared";39    var joined = Bot.getProperty("joined_date_" + uid) || "N/A";40 41    var resBal = 0;42    try { resBal = Number(Libs.ResourcesLib.anotherUserRes("balance", uid).value()) || 0; } catch (e) {}43    var bonusBal = Number(Bot.getProperty("balance" + uid) || 0);44    var totalBal = (resBal + bonusBal).toFixed(2);45 46    lines.push(uid + "," + phone + "," + joined + "," + totalBal);47  }48 49  var csvContent = lines.join("\n");50  var todayStamp = new Date().toISOString().slice(0, 10);51 52  Api.sendDocument({53    chat_id: chat.chatid,54    document: {55      content: csvContent,56      filename: "Users_Export_" + todayStamp + ".csv"57    },58    caption: "<blockquote>📥 <b>USERS EXPORT COMPLETE</b></blockquote>\n\n" +59             "👥 <b>Total Users:</b> " + userList.length + "\n\n" +60             "<i>File me User ID, Phone Number, Joined Date, aur Wallet Balance hai. Excel/Sheets me open kar sakte hain.</i>",61    parse_mode: "HTML"62  });63 64  var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;65  if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }66 67} catch (err) {68  Bot.sendMessage("⚠️ Error: " + err.message);69}