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