const fs = require('fs'); const path = require('path'); const config = require('../config') const {cmd , commands} = require('../command') //auto recording cmd({ on: "body" }, async (conn, mek, m, { from, body, isOwner }) => { if (config.AUTO_RECORDING === 'true') { await conn.sendPresenceUpdate('recording', from); } } ); //auto_voice cmd({ on: "body" }, async (conn, mek, m, { from, body, isOwner }) => { const filePath = path.join(__dirname, '../data/autovoice.json'); const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); for (const text in data) { if (body.toLowerCase() === text.toLowerCase()) { if (config.AUTO_VOICE === 'true') { //if (isOwner) return; await conn.sendPresenceUpdate('recording', from); await conn.sendMessage(from, { audio: { url: data[text] }, mimetype: 'audio/mpeg', ptt: true }, { quoted: mek }); } } } }); //auto sticker cmd({ on: "body" }, async (conn, mek, m, { from, body, isOwner }) => { const filePath = path.join(__dirname, '../data/autosticker.json'); const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); for (const text in data) { if (body.toLowerCase() === text.toLowerCase()) { if (config.AUTO_STICKER === 'true') { //if (isOwner) return; await conn.sendMessage(from,{sticker: { url : data[text]},package: 'SUBZERO-MD'},{ quoted: mek }) } } } }); //auto reply cmd({ on: "body" }, async (conn, mek, m, { from, body, isOwner }) => { const filePath = path.join(__dirname, '../data/autoreply.json'); const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); for (const text in data) { if (body.toLowerCase() === text.toLowerCase()) { if (config.AUTO_REPLY === 'true') { //if (isOwner) return; await m.reply(data[text]) } } } }); // Composing (Auto Typing) cmd({ on: "body" }, async (conn, mek, m, { from, body, isOwner }) => { if (config.AUTO_TYPING === 'true') { await conn.sendPresenceUpdate('composing', from); // send typing } }); // Always Online cmd({ on: "body" }, async (conn, mek, m, { from, isOwner }) => { try { if (config.ALWAYS_ONLINE === "true") { // Always Online Mode: Bot always appears online (double tick) await conn.sendPresenceUpdate("available", from); } else { // Dynamic Mode: Adjust presence based on owner's status if (isOwner) { // If the owner is online, show as available (double tick) await conn.sendPresenceUpdate("available", from); } else { // If the owner is offline, show as unavailable (single tick) await conn.sendPresenceUpdate("unavailable", from); } } } catch (e) { console.log(e); } }); // Public Mod cmd({ on: "body" }, async (conn, mek, m, { from, isOwner }) => { try { if (config.ALWAYS_ONLINE === "true") { // Public Mode + Always Online: Always show as online await conn.sendPresenceUpdate("available", from); } else if (config.PUBLIC_MODE === "true") { // Public Mode + Dynamic: Respect owner's presence if (isOwner) { // If owner is online, show available await conn.sendPresenceUpdate("available", from); } else { // If owner is offline, show unavailable await conn.sendPresenceUpdate("unavailable", from); } } } catch (e) { console.log(e); } });