From f336c9eaa5f0c07df16520810b1a733e3d05ff66 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 6 May 2025 12:52:02 +0200 Subject: [PATCH] dddddssss --- index.js | 51 ++++++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/index.js b/index.js index 0d0f4ae..fb844e1 100644 --- a/index.js +++ b/index.js @@ -126,47 +126,32 @@ app.post('/sendButtons', async (req, res) => { if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' }); try { - const content = { - viewOnceMessage: { - message: { - interactiveMessage: proto.Message.InteractiveMessage.create({ - body: { text: "Choisis une option :" }, - footer: { text: "Réponds via un bouton" }, - nativeFlowMessage: { - buttons: [ - { - name: "quick_reply", - buttonParamsJson: JSON.stringify({ - display_text: "Option A", - id: ".optionA" - }) - }, - { - name: "ctl_url", - buttonParamsJson: JSON.stringify({ - display_text: "Ouvrir mon site", - url: "https://example.com", - merchant_url: "https://example.com" - }) - } - ] - } - }) + const msg = { + text: 'Choisis une option :', + footer: 'Clique sur un bouton ci-dessous', + buttons: [ + { + buttonId: 'id_produits', + buttonText: { displayText: '🛍 Voir produits' }, + type: 1 + }, + { + buttonId: 'id_support', + buttonText: { displayText: '☎ Contacter support' }, + type: 1 } - } + ], + headerType: 1 }; - const msg = generateWAMessageFromContent(`${phone}@s.whatsapp.net`, content, {}); - console.log("📤 Message interactif généré :", JSON.stringify(msg.message, null, 2)); - - await sock.relayMessage(`${phone}@s.whatsapp.net`, msg.message, { messageId: msg.key.id }); - + await sock.sendMessage(`${phone}@s.whatsapp.net`, msg); res.json({ success: true }); } catch (e) { - console.error('❌ Erreur sendButtons:', e); + console.error('❌ Erreur bouton simple :', e); res.status(500).json({ error: e.message }); } }); + app.listen(3001, () => console.log('🚀 Serveur Baileys démarré sur http://localhost:3001'));