MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/settings.js:10–106  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

8 description: 'Show bot settings and per-group configurations',
9 usage: '.settings',
10 async handler(sock, message, args, context) {
11 const chatId = context.chatId || message.key.remoteJid;
12 const senderId = message.key.participant || message.key.remoteJid;
13 try {
14 const isOwner = await isOwnerOrSudo(senderId, sock, chatId);
15 const isMe = message.key.fromMe;
16 if (!isMe && !isOwner) {
17 return await sock.sendMessage(chatId, {
18 text: '❌ *Access Denied:* Only Owner/Sudo can view settings.'
19 }, { quoted: message });
20 }
21 const isGroup = chatId.endsWith('@g.us');
22 const botMode = await store.getBotMode();
23 const autoStatus = await store.getSetting('global', 'autoStatus') || { enabled: false };
24 const autoread = await store.getSetting('global', 'autoread') || { enabled: false };
25 const autotyping = await store.getSetting('global', 'autotyping') || { enabled: false };
26 const pmblocker = await store.getSetting('global', 'pmblocker') || { enabled: false };
27 const anticall = await store.getSetting('global', 'anticall') || { enabled: false };
28 const autoReactionData = await store.getSetting('global', 'autoReaction');
29 const mentionData = await store.getSetting('global', 'mention');
30 const autoReaction = autoReactionData?.enabled || false;
31 const stealthMode = await store.getSetting('global', 'stealthMode') || { enabled: false };
32 const autoBio = await store.getSetting('global', 'autoBio') || { enabled: false };
33 // cmdreact saves to userGroupData.json as data.autoReaction
34 const fs = (await import('fs')).default;
35 let cmdReactEnabled = true;
36 try {
37 const ugd = JSON.parse(fs.readFileSync('./data/userGroupData.json', 'utf-8'));
38 cmdReactEnabled = ugd.autoReaction ?? true;
39 }
40 catch {
41 cmdReactEnabled = true;
42 }
43 const getSt = (val) => val ? '✅' : '❌';
44 let menuText = `╭━〔 *MEGA CONFIG* 〕━┈\n┃\n`;
45 menuText += `┃ 👤 *User:* @${cleanJid(senderId)}\n`;
46 menuText += `┃ 🤖 *Mode:* ${botMode.toUpperCase()}\n`;
47 menuText += `┃\n┣━〔 *GLOBAL CONFIG* 〕━┈\n`;
48 menuText += `┃ ${getSt(autoStatus?.enabled)} *Auto Status*\n`;
49 menuText += `┃ ${getSt(autoread?.enabled)} *Auto Read*\n`;
50 menuText += `┃ ${getSt(autotyping?.enabled)} *Auto Typing*\n`;
51 menuText += `┃ ${getSt(pmblocker?.enabled)} *PM Blocker*\n`;
52 menuText += `┃ ${getSt(anticall?.enabled)} *Anti Call*\n`;
53 menuText += `┃ ${getSt(autoReaction)} *Auto Reaction*\n`;
54 menuText += `┃ ${getSt(cmdReactEnabled)} *Cmd Reactions*\n`;
55 menuText += `┃ ${getSt(stealthMode?.enabled)} *Stealth Mode*\n`;
56 menuText += `┃ ${getSt(autoBio?.enabled)} *Auto Bio*\n`;
57 menuText += `┃ ${getSt(mentionData?.enabled)} *Mention Alert*\n`;
58 menuText += `┃\n`;
59 if (isGroup) {
60 const groupSettings = await store.getAllSettings(chatId);
61 const groupAntilink = groupSettings.antilink || { enabled: false };
62 const groupBadword = groupSettings.antibadword || { enabled: false };
63 const antitag = await getAntitag(chatId, 'on');
64 const groupAntitag = { enabled: !!antitag };
65 const chatbotData = await getChatbot(chatId);
66 const welcomeData = await getWelcome(chatId);
67 const goodbyeData = await getGoodbye(chatId);

Callers

nothing calls this directly

Calls 7

cleanJidFunction · 0.90
getAntitagFunction · 0.90
getChatbotFunction · 0.90
getWelcomeFunction · 0.90
getGoodbyeFunction · 0.90
isOwnerOrSudoFunction · 0.85
getStFunction · 0.85

Tested by

no test coverage detected