// code from goatstore // api: https://store.agi.bd const fs = require("fs"); const path = require("path"); const DB_DIR = path.join(__dirname, "../database"); const DB_FILE = path.join(DB_DIR, "anti.json"); function loadDB() { if (!fs.existsSync(DB_DIR)) { fs.mkdirSync(DB_DIR, { recursive: true }); } if (!fs.existsSync(DB_FILE)) { fs.writeFileSync(DB_FILE, "{}"); } try { return JSON.parse(fs.readFileSync(DB_FILE, "utf8")); } catch (e) { return {}; } } function saveDB(data) { if (!fs.existsSync(DB_DIR)) { fs.mkdirSync(DB_DIR, { recursive: true }); } fs.writeFileSync(DB_FILE, JSON.stringify(data, null, 2)); } function newGroup() { return { namebox: false, boximage: false, nickname: false, out: false, emoji: false, theme: false, qtv: false, join: false, savedName: "", savedImage: "" }; } function getGroup(data, threadID) { if (!data[threadID]) { data[threadID] = newGroup(); } return data[threadID]; } function status(value) { return value ? "đŸŸĸ ON" : "🔴 OFF"; } module.exports = { config: { name: "anti", version: "2.0.0", author: "Zihad", countDown: 3, role: 1, shortDescription: "Goat Anti-Change Group", longDescription: "Protect group name, picture and other settings.", category: "group", guide: { en: "{pn}\n{pn} 1\n{pn} 2\n{pn} 9\n{pn} data add" } }, onStart: async function ({ api, event, args, message }) { const data = loadDB(); const threadID = event.threadID; const group = getGroup(data, threadID); /* * Save current group data */ if ( args[0] && args[0].toLowerCase() === "data" && args[1] && args[1].toLowerCase() === "add" ) { try { const info = await api.getThreadInfo(threadID); group.savedName = info.threadName || ""; group.savedImage = info.imageSrc || ""; saveDB(data); return message.reply( "╭────── 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜 ──────╮\n\n" + "✅ Current group data saved!\n\n" + "📛 Name: " + (group.savedName || "No name") + "\n" + "đŸ–ŧī¸ Picture: " + (group.savedImage ? "Saved ✅" : "Not available") + "\n\n" + "Now enable:\n" + "anti 1 → Name Lock\n" + "anti 2 → Picture Lock\n\n" + "╰────────────────────────╯" ); } catch (e) { return message.reply( "❌ Could not save group data.\n\n" + e.message ); } } /* * Menu */ if (!args[0]) { return message.reply( "╭────── 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜 ──────╮\n\n" + "1. anti namebox : " + status(group.namebox) + "\n" + "2. anti boximage : " + status(group.boximage) + "\n" + "3. anti nickname : " + status(group.nickname) + "\n" + "4. anti out : " + status(group.out) + "\n" + "5. anti emoji : " + status(group.emoji) + "\n" + "6. anti theme : " + status(group.theme) + "\n" + "7. anti qtv : " + status(group.qtv) + "\n" + "8. anti join : " + status(group.join) + "\n" + "9. Check status\n\n" + "Reply with a number to toggle.\n\n" + 'anti data add → Save current name & picture\n\n' + "╰────────────────────────╯" ); } const number = parseInt(args[0]); const modes = [ "namebox", "boximage", "nickname", "out", "emoji", "theme", "qtv", "join" ]; /* * Toggle 1-8 */ if (number >= 1 && number <= 8) { const mode = modes[number - 1]; group[mode] = !group[mode]; saveDB(data); return message.reply( "đŸ›Ąī¸ 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜\n\n" + "Mode: anti " + mode + "\n" + "Status: " + status(group[mode]) ); } /* * Status */ if (number === 9) { return message.reply( "╭──── 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜 ────╮\n\n" + "1. Name Box : " + status(group.namebox) + "\n" + "2. Box Image : " + status(group.boximage) + "\n" + "3. Nickname : " + status(group.nickname) + "\n" + "4. Anti Out : " + status(group.out) + "\n" + "5. Emoji : " + status(group.emoji) + "\n" + "6. Theme : " + status(group.theme) + "\n" + "7. QTV : " + status(group.qtv) + "\n" + "8. Join : " + status(group.join) + "\n\n" + "Saved Name: " + (group.savedName ? "✅" : "❌") + "\n" + "Saved Picture: " + (group.savedImage ? "✅" : "❌") + "\n\n" + "╰────────────────────╯" ); } return message.reply("❌ Invalid option.\nUse: anti"); }, /* * IMPORTANT: * GoatBot-Pro receives Facebook group events here. */ onEvent: async function ({ api, event, message }) { const threadID = event.threadID; if (!threadID) return; const data = loadDB(); if (!data[threadID]) return; const group = data[threadID]; /* * GROUP NAME CHANGED */ if (event.logMessageType === "log:thread-name") { if (!group.namebox) return; if (!group.savedName) return; try { await api.setTitle(group.savedName, threadID); return message.reply( "đŸ›Ąī¸ 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜\n\n" + "âš ī¸ Group name change detected!\n" + "🔒 Name Lock is ON.\n\n" + "â†Šī¸ Previous group name restored." ); } catch (e) { return; } } /* * GROUP PICTURE CHANGED * * The event is detected here. * The actual picture restore depends on the * image-changing method supported by the installed FCA. */ if (event.logMessageType === "log:thread-image") { if (!group.boximage) return; return message.reply( "đŸ›Ąī¸ 𝗚đ—ĸ𝗔𝗧 𝗔𝗡𝗧𝗜\n\n" + "âš ī¸ Group picture change detected!\n" + "🔒 Box Image Lock is ON." ); } } };