// code from goatstore // api: https://store.agi.bd module.exports = { config: { name: "tag", version: "2.1", author: "—͞𝐏ʀɪᴍᴇ́", role: 0, category: "group", guide: "{pn} | {pn} all | {pn} all | reply {pn} | reply {pn} " }, onStart: async function ({ api, event, args }) { const { threadID, messageID, type, messageReply } = event; const info = await api.getThreadInfo(threadID); const participants = info.participantIDs; const userInfo = info.userInfo || []; const nicknames = info.nicknames || {}; // ✅ Real FB name priority, nickname শুধু fallback const getName = (id) => userInfo.find(u => u.id == id)?.name || nicknames[id] || "user"; // ✅ Search real name + nickname দুইটাতেই const matches = (id, query) => { const real = (userInfo.find(u => u.id == id)?.name || "").toLowerCase(); const nick = (nicknames[id] || "").toLowerCase(); return real.includes(query) || nick.includes(query); }; if (type === "message_reply") { const id = messageReply.senderID; const name = getName(id); const text = args.join(" "); return api.sendMessage({ body: text ? `@${name}\n${text}` : `@${name}`, mentions: [{ tag: `@${name}`, id }] }, threadID, messageID); } if (!args[0]) { return api.sendMessage("⚠️ Use: tag / tag all / tag all ", threadID, messageID); } const query = args[0].toLowerCase(); const restText = args.slice(1).join(" "); if (query === "all") { const mentions = []; let body = ""; for (let id of participants) { const name = getName(id); mentions.push({ tag: `@${name}`, id }); body += `@${name} `; } if (restText) body += `\n${restText}`; return api.sendMessage({ body: body.trim(), mentions }, threadID, messageID); } const matched = participants.filter(id => matches(id, query)); if (matched.length > 0) { const mentions = []; let body = ""; for (let id of matched) { const name = getName(id); mentions.push({ tag: `@${name}`, id }); body += `@${name} `; } if (restText) body += `\n${restText}`; return api.sendMessage({ body: body.trim(), mentions }, threadID, messageID); } else { return api.sendMessage(`❌ "${args[0]}" nam e kawke pelam na`, threadID, messageID); } } };