|
| 1 | +const { zokou } = require("../framework/zokou"); |
| 2 | +const fs = require('fs'); |
| 3 | + |
| 4 | + |
| 5 | +let antiDeleteActive = false; // Variable pour stocker l'tat de la commande anti-delete |
| 6 | + |
| 7 | +zokou({ |
| 8 | + nomCom: "anti/delete2", |
| 9 | + categorie: "General", |
| 10 | + reaction: "?" |
| 11 | +}, async (origineMessage, zk, commandeOptions) => { |
| 12 | + const { ms, arg } = commandeOptions; |
| 13 | + |
| 14 | + // Vrifier si un argument est fourni pour activer ou dsactiver la commande |
| 15 | + if (arg[0]) { |
| 16 | + const action = arg[0].toLowerCase(); |
| 17 | + if (action === "on") { |
| 18 | + antiDeleteActive = true; |
| 19 | + await zk.sendMessage(origineMessage, "La commande anti-delete est active."); |
| 20 | + return; |
| 21 | + } else if (action === "off") { |
| 22 | + antiDeleteActive = false; |
| 23 | + await zk.sendMessage(origineMessage, "La commande anti-delete est dsactive."); |
| 24 | + return; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + // Vrifier si la commande anti-delete est active |
| 29 | + if (!antiDeleteActive) { |
| 30 | + await zk.sendMessage(origineMessage, "La commande anti-delete est actuellement dsactive."); |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + if (ms.message.protocolMessage && ms.message.protocolMessage.type === 0 && (conf.ADM).toLowerCase() === 'yes') { |
| 35 | + if (ms.key.fromMe || ms.message.protocolMessage.key.fromMe) { |
| 36 | + console.log('Message supprim me concernant'); |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + console.log('Message supprim'); |
| 41 | + const key = ms.message.protocolMessage.key; |
| 42 | + |
| 43 | + try { |
| 44 | + const st = './store.json'; |
| 45 | + const data = fs.readFileSync(st, 'utf8'); |
| 46 | + const jsonData = JSON.parse(data); |
| 47 | + const message = jsonData.messages[key.remoteJid]; |
| 48 | + |
| 49 | + let msg; |
| 50 | + |
| 51 | + for (let i = 0; i < message.length; i++) { |
| 52 | + if (message[i].key.id === key.id) { |
| 53 | + msg = message[i]; |
| 54 | + break; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + if (!msg) { |
| 59 | + console.log('Message introuvable'); |
| 60 | + return; |
| 61 | + } |
| 62 | + |
| 63 | + const senderId = msg.key.participant.split('@')[0]; |
| 64 | + const caption = ` Anti-delete-message by RAHMANI-XMD\nMessage de @${senderId}`; |
| 65 | + const imageCaption = { image: { url: './media/deleted-message.jpg' }, caption, mentions: [msg.key.participant] }; |
| 66 | + |
| 67 | + await zk.sendMessage(idBot, imageCaption); |
| 68 | + await zk.sendMessage(idBot, { forward: msg }, { quoted: msg }); |
| 69 | + } catch (error) { |
| 70 | + console.error(error); |
| 71 | + } |
| 72 | + } |
| 73 | +}); |
0 commit comments