// code from goatstore // api: https://store.agi.bd "use strict"; const fs = require("fs-extra"); const path = require("path"); const cacheDir = path.join(__dirname, "cache"); const pathFile = path.join(cacheDir, "autoseen.txt"); // Ensure cache directory and file exist fs.ensureDirSync(cacheDir); if (!fs.existsSync(pathFile)) { fs.writeFileSync(pathFile, "false", "utf8"); } module.exports = { config: { name: "autoseen", version: "1.0.1", hasPermssion: 2, author: "Jas", shortDescription: { en: "Turn on/off automatically seen when new messages are available" }, longDescription: { en: "Turn on/off automatically seen when new messages are available" }, category: "Admin", guide: { en: "{pn} on/off" }, cooldowns: 5 }, onChat: async ({ api, event, args }) => { try { if (!fs.existsSync(pathFile)) { fs.ensureDirSync(cacheDir); fs.writeFileSync(pathFile, "false", "utf8"); } const isEnable = fs.readFileSync(pathFile, "utf8").trim(); if (isEnable === "true") { api.markAsReadAll(() => {}); } } catch (error) { console.error("[AUTOSEEN] onChat error:", error); } }, onStart: async ({ api, event, args }) => { try { const action = args[0]?.toLowerCase(); if (action === "on") { fs.writeFileSync(pathFile, "true", "utf8"); return api.sendMessage( "The autoseen function is now enabled for new messages.", event.threadID, event.messageID ); } if (action === "off") { fs.writeFileSync(pathFile, "false", "utf8"); return api.sendMessage( "The autoseen function has been disabled for new messages.", event.threadID, event.messageID ); } return api.sendMessage( "Incorrect syntax. Use: autoseen on/off", event.threadID, event.messageID ); } catch (error) { console.error("[AUTOSEEN] onStart error:", error); return api.sendMessage( "Failed to update autoseen settings.", event.threadID, event.messageID ); } } };