Spaces:
Starting
Starting
File size: 3,760 Bytes
8d8b0ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
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);
}
});
|