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.42k stars 3.68k forks source link

Broadcast message msg.broadcast = false #978

Closed tofers closed 2 years ago

tofers commented 2 years ago

I understood broadcast this is a story in whatsapp.

Default message format in broadcast message

Message { mediaKey: 'kh42NR8yKm6HE099nKRp4UJz79rt7ybFx5orVPdgxkM=', id: { fromMe: false, remote: 'status@broadcast', id: '7FA3344E66B5A8A7F91FA6FD19C5A6D5', participant: '79872940636@c.us', _serialized: 'false_status@broadcast_7FA3344E66B5A8A7F91FA6FD19C5A6D5_79872940636@c.us' }, ack: 0, hasMedia: true, body: '', type: 'video', timestamp: 1637337341, from: 'status@broadcast', to: '79195188515@c.us', author: '79872940636@c.us', deviceType: 'android', isForwarded: false, forwardingScore: 0, isStatus: true, isStarred: false, broadcast: false, fromMe: false, hasQuotedMsg: false, location: undefined, vCards: [], inviteV4: undefined, mentionedIds: [], orderId: undefined, token: undefined, links: [] }

Regular incoming message

id: { fromMe: false, remote: '79697771185@c.us', id: '3EB0EB28D1FD4C59C503', _serialized: 'false_79697771185@c.us_3EB0EB28D1FD4C59C503' },

Broadcast id: { fromMe: false, remote: 'status@broadcast', id: '7FA3344E66B5A8A7F91FA6FD19C5A6D5', participant: '79872940636@c.us', _serialized: 'false_status @ broadcast_7FA3344E66B5A8A7F91FA6FD19C5A6D5_79872940636@c.us' }, In the broadcast form, the client is in a participant.

It's just a mistake that the broadcast parameter is in the message as a broadcast: false

WhatsApp Web v 2.2144.11 WWebJS v 1.15.1 Browser v HeadlessChrome/88.0.4324.150

PurpShell commented 2 years ago

Hey! I suggest you do this:

const isBroadcast = msg.broadcast || msg.isStatus;