Deprecated message-new & message-update + fix presence update for groups

The chat-update event is fired now when a message is received/updated
This commit is contained in:
Adhiraj Singh
2020-11-13 16:07:08 +05:30
parent eaf56f6d71
commit eace0c1795
6 changed files with 59 additions and 39 deletions

View File

@@ -47,8 +47,11 @@ async function example() {
const participant = json.participant ? ' (' + json.participant + ')' : '' // participant exists when the message is from a group
console.log(`${json.to}${participant} acknlowledged message(s) ${json.ids} as ${json.type}`)
})
// set to false to NOT relay your own sent messages
conn.on('message-new', async (m) => {
conn.on('chat-update', async chat => {
// only do something when a new message is received; i.e. the unread count is updated
if (!chat.count) return
const m = chat.messages.all()[0] // pull the new message from the update
const messageStubType = WA_MESSAGE_STUB_TYPES[m.messageStubType] || 'MESSAGE'
console.log('got notification of type: ' + messageStubType)