(sock, message, args, context)
| 68 | usage: '.pmblocker <on|off|status|setmsg>', |
| 69 | ownerOnly: true, |
| 70 | async handler(sock, message, args, context) { |
| 71 | const chatId = context.chatId || message.key.remoteJid; |
| 72 | const state = await readState(); |
| 73 | const sub = args[0]?.toLowerCase(); |
| 74 | const rest = args.slice(1); |
| 75 | if (!sub || !['on', 'off', 'status', 'setmsg'].includes(sub)) { |
| 76 | await sock.sendMessage(chatId, { |
| 77 | text: `📵 *PM BLOCKER*\n\n` + |
| 78 | `*Storage:* ${HAS_DB ? 'Database' : 'File System'}\n\n` + |
| 79 | `*Commands:*\n` + |
| 80 | `• \`.pmblocker on\` - Enable DM blocking\n` + |
| 81 | `• \`.pmblocker off\` - Disable DM blocking\n` + |
| 82 | `• \`.pmblocker status\` - Current status\n` + |
| 83 | `• \`.pmblocker setmsg <text>\` - Set warning message\n\n` + |
| 84 | `*Current Status:* ${state.enabled ? '✅ ENABLED' : '❌ DISABLED'}` |
| 85 | }, { quoted: message }); |
| 86 | return; |
| 87 | } |
| 88 | if (sub === 'status') { |
| 89 | await sock.sendMessage(chatId, { |
| 90 | text: `📵 *PM BLOCKER STATUS*\n\n` + |
| 91 | `*Status:* ${state.enabled ? '✅ ENABLED' : '❌ DISABLED'}\n` + |
| 92 | `*Storage:* ${HAS_DB ? 'Database' : 'File System'}\n\n` + |
| 93 | `*Warning Message:*\n${state.message}` |
| 94 | }, { quoted: message }); |
| 95 | return; |
| 96 | } |
| 97 | if (sub === 'setmsg') { |
| 98 | const newMsg = rest.join(' ').trim(); |
| 99 | if (!newMsg) { |
| 100 | await sock.sendMessage(chatId, { |
| 101 | text: '*Please provide a message*\n\nUsage: `.pmblocker setmsg <your message>`' |
| 102 | }, { quoted: message }); |
| 103 | return; |
| 104 | } |
| 105 | await writeState(state.enabled, newMsg); |
| 106 | await sock.sendMessage(chatId, { |
| 107 | text: `✅ *PM blocker message updated!*\n\n*New message:*\n${newMsg}` |
| 108 | }, { quoted: message }); |
| 109 | return; |
| 110 | } |
| 111 | const enable = sub === 'on'; |
| 112 | await writeState(enable, undefined); |
| 113 | await sock.sendMessage(chatId, { |
| 114 | text: `📵 *PM Blocker ${enable ? 'ENABLED' : 'DISABLED'}*\n\n` + |
| 115 | `${enable ? '✅ Users who DM the bot will be warned and blocked.' : '❌ Private messages are now allowed.'}` |
| 116 | }, { quoted: message }); |
| 117 | }, |
| 118 | readState, |
| 119 | writeState |
| 120 | }; |
nothing calls this directly
no test coverage detected