From 609d2f076d825c39b0161e44ea01e52bd030f905 Mon Sep 17 00:00:00 2001 From: cangui Date: Wed, 7 May 2025 07:19:18 +0200 Subject: [PATCH] lkkkklkl --- index.js | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index d0fa998..8bc1ffe 100644 --- a/index.js +++ b/index.js @@ -73,29 +73,35 @@ const initBaileys = async () => { // (Facultatif) Gestion des messages reçus sock.ev.on('messages.upsert', async ({ messages }) => { const msg = messages[0]; + if (!msg.key.fromMe && msg.message?.conversation) { console.log('💬 Message reçu de', msg.key.remoteJid, ':', msg.message.conversation); } - if (buttonId === 'doc_1') { - await sock.sendMessage(jid, { - document: { - url: 'hhttps://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf', - }, - mimetype: 'application/pdf', - fileName: 'Document_1.pdf', - caption: 'Voici votre *Document 1* 📄', - footer: '© Fizzxy Dev', - }); - } else if (buttonId === 'doc_2') { - await sock.sendMessage(jid, { - document: { - url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf', - }, - mimetype: 'application/pdf', - fileName: 'Document_2.pdf', - caption: 'Voici votre *Document 2* 📄', - footer: '© Fizzxy Dev', - }); + if (!msg.message || !msg.key.fromMe) { + const jid = msg.key.remoteJid; + const buttonId = msg.message.buttonsResponseMessage?.selectedButtonId; + + if (buttonId === 'doc_1') { + await sock.sendMessage(jid, { + document: { + url: 'https://wa.canguidev.fr/static/document1.pdf', + }, + mimetype: 'application/pdf', + fileName: 'Document_1.pdf', + caption: 'Voici votre *Document 1* 📄', + footer: '© Fizzxy Dev', + }); + } else if (buttonId === 'doc_2') { + await sock.sendMessage(jid, { + document: { + url: 'https://wa.canguidev.fr/static/document2.pdf', + }, + mimetype: 'application/pdf', + fileName: 'Document_2.pdf', + caption: 'Voici votre *Document 2* 📄', + footer: '© Fizzxy Dev', + }); + } } }); };