// code from goatstore // api: https://store.agi.bd const { getTime, drive } = global.utils; module.exports = { config: { name: "leave", version: "1.5", author: "π† απ’πˆπ˜π€πŒ-𝐇𝐀𝐒𝐀𝐍", category: "events" }, langs: { vi: { session1: "sΓ‘ng", session2: "trΖ°a", session3: "chiều", session4: "tα»‘i", leaveType1: "tα»± rời", defaultLeaveMessage: "{userName} Δ‘Γ£ {type} khỏi nhΓ³m" }, en: { session1: "morning", session2: "noon", session3: "afternoon", session4: "evening", leaveType1: "left", defaultLeaveMessage: "{userName} {type} the group" } }, onStart: async ({ threadsData, message, event, api, usersData, getLang }) => { if (event.logMessageType == "log:unsubscribe") return async function () { const { threadID } = event; const threadData = await threadsData.get(threadID); if (!threadData.settings.sendLeaveMessage) return; const { leftParticipantFbId } = event.logMessageData; // π‘π€π˜π‡π€π-π’π€πππˆπ‘ if (leftParticipantFbId == api.getCurrentUserID()) return; // π‘π€π˜π‡π€π-π’π€πππˆπ‘ if (leftParticipantFbId != event.author) return; const hours = getTime("HH"); const threadName = threadData.threadName; const userName = await usersData.getName(leftParticipantFbId); let { leaveMessage = getLang("defaultLeaveMessage") } = threadData.data; const form = { mentions: leaveMessage.match(/\{userNameTag\}/g) ? [{ tag: userName, id: leftParticipantFbId }] : null }; leaveMessage = leaveMessage .replace(/\{userName\}|\{userNameTag\}/g, userName) .replace(/\{type\}/g, getLang("leaveType1")) .replace(/\{threadName\}|\{boxName\}/g, threadName) .replace(/\{time\}/g, hours) .replace(/\{session\}/g, hours <= 10 ? getLang("session1") : hours <= 12 ? getLang("session2") : hours <= 18 ? getLang("session3") : getLang("session4") ); form.body = leaveMessage; if (leaveMessage.includes("{userNameTag}")) { form.mentions = [{ id: leftParticipantFbId, tag: userName }]; } if (threadData.data.leaveAttachment) { const files = threadData.data.leaveAttachment; const attachments = files.reduce((acc, file) => { acc.push(drive.getFile(file, "stream")); return acc; }, []); form.attachment = (await Promise.allSettled(attachments)) .filter(({ status }) => status == "fulfilled") .map(({ value }) => value); } // ππˆπ‰π‡π”πŒ-𝐂𝐇𝐀𝐓-ππŽπ“ return; }; } };