ookamiiixd / baileys-api

Simple WhatsApp REST API with multiple device support
MIT License
431 stars 327 forks source link

automatically read incoming messages #143

Closed davidgalih closed 1 year ago

davidgalih commented 1 year ago

How can I automatically read incoming messages and reply to them in your code updates using this typescript?

If in your old code, I added this

wa.ev.on('messages.upsert', async (m) => {
        const msg = m.messages[0]
        const text = msg.message?.conversation ?? null

        if (!msg.key.fromMe && m.type === 'notify') {

            if (text === "ping") {
                await wa.sendMessage(msg.key.remoteJid, { text: "pong" })
            }
            if (text === "david") {
                var pesan = msg.key.remoteJid;
                await wa.sendMessage(msg.key.remoteJid, { text: "Hai Im david "+pesan })
            }
        }
    })

However, when I try to add your updated code to the typescript it still doesn't work.

ookamiiixd commented 1 year ago

Oh right, i forgot about this. Maybe i'll add this as an option when creating the session instead of hardcoding and applying it for all sessions

davidgalih commented 1 year ago

What an amazing decision. I will look forward to this spectacular update.