(sock, message, args, context)
| 134 | groupOnly: true, |
| 135 | adminOnly: true, |
| 136 | async handler(sock, message, args, context) { |
| 137 | const chatId = context.chatId || message.key.remoteJid; |
| 138 | const action = args[0]?.toLowerCase(); |
| 139 | if (!action) { |
| 140 | const config = await getAntilink(chatId, 'on'); |
| 141 | await sock.sendMessage(chatId, { |
| 142 | text: `*🔗 ANTILINK SETUP*\n\n` + |
| 143 | `*Current Status:* ${config?.enabled ? '✅ Enabled' : '❌ Disabled'}\n` + |
| 144 | `*Current Action:* ${config?.action || 'Not set'}\n\n` + |
| 145 | `*Commands:*\n` + |
| 146 | `• \`.antilink on\` - Enable antilink\n` + |
| 147 | `• \`.antilink off\` - Disable antilink\n` + |
| 148 | `• \`.antilink set delete\` - Delete link messages\n` + |
| 149 | `• \`.antilink set kick\` - Kick users who send links\n` + |
| 150 | `• \`.antilink set warn\` - Warn users only\n\n` + |
| 151 | `*Protected Links:*\n` + |
| 152 | `• WhatsApp Groups\n` + |
| 153 | `• WhatsApp Channels\n` + |
| 154 | `• Telegram\n` + |
| 155 | `• All other links\n\n` + |
| 156 | `*Note:* Admins, Owner, and Sudo users are exempt.` |
| 157 | }, { quoted: message }); |
| 158 | return; |
| 159 | } |
| 160 | switch (action) { |
| 161 | case 'on': |
| 162 | const existingConfig = await getAntilink(chatId, 'on'); |
| 163 | if (existingConfig?.enabled) { |
| 164 | await sock.sendMessage(chatId, { |
| 165 | text: '⚠️ *Antilink is already enabled*' |
| 166 | }, { quoted: message }); |
| 167 | return; |
| 168 | } |
| 169 | const result = await setAntilink(chatId, 'on', 'delete'); |
| 170 | await sock.sendMessage(chatId, { |
| 171 | text: result ? '✅ *Antilink enabled successfully!*\n\nDefault action: Delete messages\n\n*Exempt:* Admins, Owner, Sudo users' : '❌ *Failed to enable antilink*' |
| 172 | }, { quoted: message }); |
| 173 | break; |
| 174 | case 'off': |
| 175 | await removeAntilink(chatId, 'on'); |
| 176 | await sock.sendMessage(chatId, { |
| 177 | text: '❌ *Antilink disabled*\n\nUsers can now send links freely.' |
| 178 | }, { quoted: message }); |
| 179 | break; |
| 180 | case 'set': |
| 181 | if (args.length < 2) { |
| 182 | await sock.sendMessage(chatId, { |
| 183 | text: '❌ *Please specify an action*\n\nUsage: `.antilink set delete | kick | warn`' |
| 184 | }, { quoted: message }); |
| 185 | return; |
| 186 | } |
| 187 | const setAction = args[1].toLowerCase(); |
| 188 | if (!['delete', 'kick', 'warn'].includes(setAction)) { |
| 189 | await sock.sendMessage(chatId, { |
| 190 | text: '❌ *Invalid action*\n\nChoose: delete, kick, or warn' |
| 191 | }, { quoted: message }); |
| 192 | return; |
| 193 | } |
nothing calls this directly
no test coverage detected