const antiscamDbPath = './db/antiscam.json'; if (!fs.existsSync(antiscamDbPath)) { fs.writeFileSync(antiscamDbPath, JSON.stringify({ enabled: false, scammers: [] }, null, 2)); } let antiscamData = JSON.parse(fs.readFileSync(antiscamDbPath)); // ==================================================== const saveAntiscamData = () => { fs.writeFileSync(antiscamDbPath, JSON.stringify(antiscamData, null, 2)); } const normalizeNumber = (number) => { return number.replace(/[^0-9]/g, '') + '@s.whatsapp.net'; } const checkScammers = async () => { if (!antiscamData.enabled || !isGroup || !isBotAdmins) return; for (const participant of participants) { if (antiscamData.scammers.includes(participant.id)) { await xstbot.groupParticipantsUpdate(from, [participant.id], 'remove'); await xstbot.sendMessage(from, { text: `⚠️ Scammer detected! @${participant.id.split('@')[0]} has been removed from ${groupName}.`, mentions: [participant.id] }); } } } if (isGroup && m.messageStubType === 27) { // Member added await checkScammers(); } if (isGroup && antiscamData.enabled && isBotAdmins) { await checkScammers(); } // ==================================================== case 'scammer': if (!isOwner && !isAdmins) { await xstbot.sendMessage(from, { text: 'Only admins can use this command!' }); return; } if (!args[0]) { await xstbot.sendMessage(from, { text: 'Usage: .scammer on/off' }); return; } if (args[0].toLowerCase() === 'on') { antiscamData.enabled = true; saveAntiscamData(); await xstbot.sendMessage(from, { text: 'Anti-scam feature enabled!' }); } else if (args[0].toLowerCase() === 'off') { antiscamData.enabled = false; saveAntiscamData(); await xstbot.sendMessage(from, { text: 'Anti-scam feature disabled!' }); } else { await xstbot.sendMessage(from, { text: 'Invalid option! Use: .scammer on/off' }); } break; case 'addscam': if (!isOwner && !isAdmins) { await xstbot.sendMessage(from, { text: 'Only admins can use this command!' }); return; } if (!text) { await xstbot.sendMessage(from, { text: 'Usage: .addscam ' }); return; } const scamNumber = normalizeNumber(text); if (!antiscamData.scammers.includes(scamNumber)) { antiscamData.scammers.push(scamNumber); saveAntiscamData(); await xstbot.sendMessage(from, { text: `Number ${text} added to scammer list!` }); if (isGroup && isBotAdmins && participants.some(p => p.id === scamNumber)) { await xstbot.groupParticipantsUpdate(from, [scamNumber], 'remove'); await xstbot.sendMessage(from, { text: `⚠️ Scammer @${scamNumber.split('@')[0]} has been removed from ${groupName}!`, mentions: [scamNumber] }); } } else { await xstbot.sendMessage(from, { text: `Number ${text} is already in the scammer list!` }); } break; case 'delscam': if (!isOwner && !isAdmins) { await xstbot.sendMessage(from, { text: 'Only admins can use this command!' }); return; } if (!text) { await xstbot.sendMessage(from, { text: 'Usage: .delscam ' }); return; } const delNumber = normalizeNumber(text); if (antiscamData.scammers.includes(delNumber)) { antiscamData.scammers = antiscamData.scammers.filter(num => num !== delNumber); saveAntiscamData(); await xstbot.sendMessage(from, { text: `Number ${text} removed from scammer list!` }); } else { await xstbot.sendMessage(from, { text: `Number ${text} is not in the scammer list!` }); } break;