_antilink.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import ws from 'ws';
  2. export async function before(m, { conn, isAdmin, isBotAdmin, isOwner, isROwner, participants }) {
  3. if (!m.isGroup) return;
  4. if (isAdmin || isOwner || m.fromMe || isROwner) return;
  5. let chat = global.db.data.chats[m.chat];
  6. let delet = m.key.participant;
  7. let bang = m.key.id;
  8. const user = `@${m.sender.split`@`[0]}`;
  9. const groupAdmins = participants.filter(p => p.admin);
  10. const listAdmin = groupAdmins.map((v, i) => `*ยป ${i + 1}. @${v.id.split('@')[0]}*`).join('\n');
  11. let bot = global.db.data.settings[this.user.jid] || {};
  12. let linkRegex1 = /chat.whatsapp.com\/([0-9A-Za-z]{20,24})|5chat-whatzapp\.vercel\.app/i;
  13. let linkRegex2 = /whatsapp.com\/channel\/([0-9A-Za-z]{20,24})/i;
  14. const isGroupLink = linkRegex1.exec(m.text) || linkRegex2.exec(m.text);
  15. const grupo = `https://chat.whatsapp.com`;
  16. const allBots = [conn, ...global.conns.filter((conn) => conn.user && conn.ws.socket && conn.ws.socket.readyState !== ws.CLOSED)];
  17. const isThisBotAdmin = isBotAdmin;
  18. const botAdmins = allBots.filter(bot => {
  19. const botParticipants = participants.find(p => p.id === bot.user.jid);
  20. return botParticipants && botParticipants.admin;
  21. });
  22. let shouldAct = false;
  23. if (botAdmins.length > 0) {
  24. shouldAct = isThisBotAdmin && botAdmins.some(bot => bot.user.jid === conn.user.jid);
  25. } else if (allBots.length > 1) {
  26. const firstBot = allBots[0];
  27. shouldAct = conn.user.jid === firstBot.user.jid;
  28. } else {
  29. return;
  30. }
  31. if (!shouldAct) return;
  32. if (isAdmin && chat.antiLink && m.text.includes(grupo)) return m.reply('*El AntiLink Esta activo pero que salvarte eres admin ๐Ÿ˜Ž!*');
  33. if (chat.antiLink && isGroupLink && !isAdmin) {
  34. if (isBotAdmin) {
  35. const linkThisGroup = `https://chat.whatsapp.com/${await this.groupInviteCode(m.chat)}`;
  36. if (m.text.includes(linkThisGroup)) return;
  37. }
  38. await conn.sendMessage(m.chat, { text: `*ใ€Œ ANTILINK DETECTADO ใ€*\n\n${user} ๐Ÿคจ Rompiste las reglas del Grupo sera eliminado....`, mentions: [m.sender] }, { quoted: m, ephemeralExpiration: 24*60*100, disappearingMessagesInChat: 24*60*100 });
  39. if (!isBotAdmin) return conn.sendMessage(m.chat, { text: `*Te salvarte gil, no soy admin no te puedo eliminar*`, mentions: [...groupAdmins.map(v => v.id)] }, { quoted: m });
  40. if (isBotAdmin) {
  41. await conn.sendMessage(m.chat, { delete: { remoteJid: m.chat, fromMe: false, id: bang, participant: delet } });
  42. let responseb = await conn.groupParticipantsUpdate(m.chat, [m.sender], 'remove');
  43. if (responseb[0].status === "404") return;
  44. }} else if (!bot.restrict) {
  45. return m.reply('*๐™€๐™ก ๐™ฅ๐™ง๐™ค๐™ฅ๐™ž๐™š๐™ฉ๐™–๐™ง๐™ž๐™ค ๐™™๐™š๐™ก ๐™—๐™ค๐™ฉ ๐™ฃ๐™ค ๐™ฉ๐™ž๐™š๐™ฃ๐™š ๐™–๐™˜๐™ฉ๐™ž๐™ซ๐™–๐™™๐™ค ๐™š๐™ก ๐™ง๐™š๐™จ๐™ฉ๐™ง๐™ž๐™˜๐™ž๐™ค๐™ฃ (๐™š๐™ฃ๐™–๐™—๐™ก๐™š ๐™ง๐™š๐™จ๐™ฉ๐™ง๐™ž๐™˜๐™ฉ) ๐™˜๐™ค๐™ฃ๐™ฉ๐™–๐™˜๐™ฉ๐™š ๐™˜๐™ค๐™ฃ ๐™š๐™ก ๐™ฅ๐™–๐™ง๐™– ๐™ฆ๐™ช๐™š ๐™ก๐™ค๐™จ ๐™๐™–๐™—๐™ž๐™ก๐™ž๐™ฉ๐™š*');
  46. }
  47. return !0;
  48. }