(sock, message, args, context)
| 117 | usage: '.autoread <on|off>', |
| 118 | ownerOnly: true, |
| 119 | async handler(sock, message, args, context) { |
| 120 | const chatId = context.chatId || message.key.remoteJid; |
| 121 | const channelInfo = context.channelInfo || {}; |
| 122 | try { |
| 123 | const config = await initConfig(); |
| 124 | const action = args[0]?.toLowerCase(); |
| 125 | if (!action) { |
| 126 | const ghostMode = await store.getSetting('global', 'stealthMode'); |
| 127 | const ghostActive = ghostMode && ghostMode.enabled; |
| 128 | await sock.sendMessage(chatId, { |
| 129 | text: `*📖 AUTOREAD STATUS*\n\n` + |
| 130 | `*Current Status:* ${config.enabled ? '✅ Enabled' : '❌ Disabled'}\n` + |
| 131 | `*Stealth Mode:* ${ghostActive ? '👻 Active (overrides autoread)' : '❌ Inactive'}\n` + |
| 132 | `*Storage:* ${HAS_DB ? 'Database' : 'File System'}\n\n` + |
| 133 | `*Commands:*\n` + |
| 134 | `• \`.autoread on\` - Enable auto-read\n` + |
| 135 | `• \`.autoread off\` - Disable auto-read\n\n` + |
| 136 | `*What it does:*\n` + |
| 137 | `When enabled, the bot automatically marks all messages as read (blue ticks).\n\n` + |
| 138 | `*Note:* Ghost mode takes priority over autoread. If ghost mode is active, no read receipts will be sent.`, |
| 139 | ...channelInfo |
| 140 | }, { quoted: message }); |
| 141 | return; |
| 142 | } |
| 143 | if (action === 'on' || action === 'enable') { |
| 144 | if (config.enabled) { |
| 145 | await sock.sendMessage(chatId, { |
| 146 | text: '⚠️ *Autoread is already enabled*', |
| 147 | ...channelInfo |
| 148 | }, { quoted: message }); |
| 149 | return; |
| 150 | } |
| 151 | config.enabled = true; |
| 152 | await saveConfig(config); |
| 153 | const ghostMode = await store.getSetting('global', 'stealthMode'); |
| 154 | const ghostActive = ghostMode && ghostMode.enabled; |
| 155 | await sock.sendMessage(chatId, { |
| 156 | text: `✅ *Auto-read enabled!*\n\nAll messages will now be automatically marked as read.${ghostActive ? '\n\n⚠️ *Note:* Ghost mode is currently active and will override autoread.' : ''}`, |
| 157 | ...channelInfo |
| 158 | }, { quoted: message }); |
| 159 | } |
| 160 | else if (action === 'off' || action === 'disable') { |
| 161 | if (!config.enabled) { |
| 162 | await sock.sendMessage(chatId, { |
| 163 | text: '⚠️ *Autoread is already disabled*', |
| 164 | ...channelInfo |
| 165 | }, { quoted: message }); |
| 166 | return; |
| 167 | } |
| 168 | config.enabled = false; |
| 169 | await saveConfig(config); |
| 170 | await sock.sendMessage(chatId, { |
| 171 | text: '❌ *Auto-read disabled!*\n\nMessages will no longer be automatically marked as read.', |
| 172 | ...channelInfo |
| 173 | }, { quoted: message }); |
| 174 | } |
| 175 | else { |
| 176 | await sock.sendMessage(chatId, { |
nothing calls this directly
no test coverage detected