// code from goatstore // api: https://store.agi.bd const moment = require("moment-timezone"); module.exports = { config: { name: "active", aliases: ["act", "activity", "today"], version: "3.0", author: "Sakib", countDown: 3, role: 0, description: { en: "Today active list" }, category: "group", guide: { en: "{pn}" } }, onStart: async function ({ api, event, usersData, threadsData }) { const { threadID, messageID } = event; const today = moment.tz("Asia/Dhaka").format("YYYY-MM-DD"); const threadData = await threadsData.get(threadID); let activeData = threadData.data?.activeToday; // যদি ডেটা না থাকে বা তারিখ পুরানো হয় if (!activeData || activeData.date!== today) { return api.sendMessage( `📊 𝗧𝗢𝗗𝗔𝗬 𝗔𝗖𝗧𝗜𝗩𝗘\n\n📅 তারিখ: ${today}\n\n❥ আজকে এখনো কেউ মেসেজ করেনি!\nএকটা মেসেজ দিয়ে আবার active লিখো।`, threadID, messageID ); } const users = activeData.users; if (Object.keys(users).length === 0) { return api.sendMessage(`📊 আজকে এখনো কেউ active না\n📅 ${today}`, threadID, messageID); } const sorted = Object.entries(users).sort((a, b) => b[1] - a[1]); let msg = `╭─❍ 📊 𝗧𝗢𝗗𝗔𝗬 𝗔𝗖𝗧𝗜𝗩𝗘 ❍─╮\n`; msg += `│ 📅 ${today}\n`; msg += `│ 👥 Total Active: ${sorted.length} জন\n`; msg += `│ 💬 Total Msg: ${Object.values(users).reduce((a,b)=>a+b,0)} টা\n`; msg += `│\n`; for (let i = 0; i < sorted.length; i++) { if (i >= 25) break; // Top 25 const [uid, count] = sorted[i]; let name; try { name = await usersData.getName(uid); } catch { name = uid; } const medal = i==0? "🥇" : i==1? "🥈" : i==2? "🥉" : ` ${i+1}.`; msg += `│ ${medal} ${name} » ${count} টা\n`; } msg += `╰─❍─❍─❍─❍─❍─❍─❍─╯`; return api.sendMessage(msg, threadID, messageID); }, onChat: async function ({ event, threadsData, api }) { const { threadID, senderID } = event; if (!threadID ||!senderID) return; if (senderID === api.getCurrentUserID()) return; // Bot ignore const today = moment.tz("Asia/Dhaka").format("YYYY-MM-DD"); try { const threadData = await threadsData.get(threadID); let activeData = threadData.data?.activeToday; // নতুন দিন হলে রিসেট if (!activeData || activeData.date!== today) { activeData = { date: today, users: {} }; } if (!activeData.users) activeData.users = {}; // Count +1 activeData.users[senderID] = (activeData.users[senderID] || 0) + 1; await threadsData.set(threadID, { data: { ...(threadData.data || {}), activeToday: activeData } }); } catch (e) { console.log("Active Error: " + e.message); } } };