// code from goatstore // api: https://store.agi.bd const fs = require("fs"); const path = require("path"); exports.config = { name: "resend", version: "4.2", author: "â€”ÍžðĘ€ÉŠáīáī‡Ė", countDown: 0, role: 0, shortDescription: "Anti Unsend per group", longDescription: "Shows unsent messages. Ignores bot's own unsent messages. Each group controlled separately. Default OFF.", category: "box", guide: { en: "{pn} on / {pn} off" } }; if (!global.resend) global.resend = new Map(); const cachePath = path.join(__dirname, "cache", "resendStatus.json"); function loadStatus() { try { if (!fs.existsSync(cachePath)) { fs.writeFileSync(cachePath, JSON.stringify({}), "utf-8"); return {}; } return JSON.parse(fs.readFileSync(cachePath, "utf-8")); } catch { return {}; } } function saveStatus(data) { try { const dir = path.dirname(cachePath); if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8"); } catch (e) { console.log(e); } } exports.onStart = async function({ args, event, message }) { const threadID = event.threadID; const action = (args[0] || "").toLowerCase(); const status = loadStatus(); if (status[threadID] === undefined) status[threadID] = false; if (action === "on") { status[threadID] = true; saveStatus(status); return message.reply(`✅ Anti-Unsend is now ON for this group.`); } if (action === "off") { status[threadID] = false; saveStatus(status); return message.reply(`❌ Anti-Unsend is now OFF for this group.`); } const current = status[threadID]? "ON" : "OFF"; return message.reply(`Anti-Unsend is currently ${current} for this group.\nUse: resend on / resend off`); }; exports.onChat = async function({ event, api }) { const { threadID, messageID, senderID, body, attachments, type } = event; const botID = api.getCurrentUserID(); const status = loadStatus(); if (status[threadID] === undefined) { status[threadID] = false; saveStatus(status); } if (!status[threadID]) return; if (type === "message_unsend") { const saved = global.resend.get(messageID); if (!saved) return; if (saved.senderID == botID) return; try { const info = await api.getUserInfo(saved.senderID); const name = info[saved.senderID]?.name || "Someone"; let text = `ðŸļ__āĶļāĶŽāĶūā͇ āĶĶ⧇āĶ–ā§‹ ${name} āĶ•āĶŋ Unsend āĶ•āͰā͛⧇! 😁🙃\n`; text += `━━━━━━━━━━━━━━━━━━━━\n`; text += `${saved.body || "[Attachment Only]"}`; if (saved.attachments && saved.attachments.length > 0) { const files = await Promise.all( saved.attachments.map(url => global.utils.getStreamFromURL(url)) ); return api.sendMessage({ body: text, attachment: files }, threadID); } else { return api.sendMessage(text, threadID); } } catch (e) { console.log(e); } return; } if (senderID == botID) return; if (body || (attachments && attachments.length > 0)) { let urls = []; if (attachments) { for (const att of attachments) { if (att.url) urls.push(att.url); } } global.resend.set(messageID, { body: body, senderID: senderID, attachments: urls }); setTimeout(() => { global.resend.delete(messageID); }, 60 * 60 * 1000); } };