pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.53k stars 3.7k forks source link

Self messages are not received #2653

Closed jaytonic closed 11 months ago

jaytonic commented 11 months ago

Is there an existing issue for this?

Describe the bug

In whatsapp, you can send messages to yourself.

Currently if you listen to messages events:

client.on("message", (message) => { console.log(message.body); });

My whatsapp web instance receives them, even if they are sent from another device. But, with whatsapp-web.js, no event are triggered for this. I've double-checked, it doesn't seems to be another existing event that could cover this usecase

Expected behavior

The message event should inform me when I send myself a message(and I've even the possibility to check the fromMe property.

Steps to Reproduce the Bug or Issue

  1. Run the attached code
  2. Send yourself a message from the web or from the phone

--> You should get the message.

Relevant Code

` const client = new Client({ authStrategy: new LocalAuth(), });

client.on("qr", (qr) => { qrcode.generate(qr, { small: true }); });

client.on("ready", () => { console.log("Client is ready!"); });

client.initialize(); client.on("message", (message) => { console.log(message.body); });`

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 11 Phone: Android whatsapp-web.js version: 1.23.0 whatsapp Web version: 2.2350.52 node.js version: 20.10.0

Additional context

The purpose of this is to be able to send some commands to my bot that uses whatsapp web js

alechkos commented 11 months ago

@jaytonic

Use message_create event

jaytonic commented 11 months ago

@jaytonic

Use message_create event

I just tried to use it, I do receive the event with this, but then I also receive all the messages sent through whatsapp-web.js Is there a way to know the message has been sent by the package or not?

Is there a way to know the message has been sent in my own conversation?