orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.1k stars 1.2k forks source link

Function onAnyMessage #2814

Open valentinolopezbruno opened 3 weeks ago

valentinolopezbruno commented 3 weeks ago

Hi everyone, I recently tested the latest version (5.2.0) and when I use the onAnyMessage function, it happens that if the sender or receiver of messages has more than one Whatsapp session (two, three or four), the outgoing/incoming messages will be multiplied by the number of active sessions on the respective phone number.

I want to know if this affected everyone or just me, I would appreciate your opinions.

Maybe I can try to edit the onAnyMessage function to fix this. I think the problem may be occurring in src/lib/wapi/listeners/. But I am not 100% sure about this.

ghayman commented 3 weeks ago

Thanks @valentinolopezbruno - yes I have been seeing this! I could not figure out why it was happening and I've been filtering duplicate messages in my application code.

If you want to have a go at a fix that would be great 😀

valentinolopezbruno commented 3 weeks ago

In onAnyMessage function, I was looking at the "logs" of incoming messages and there are no fields that validate a user's session so it forces us to filter duplicate messages by ID. I think the easiest solution is to create an array to store the incoming message IDs and filter to correct duplicates. Then after X amount of time reset the array to free up memory. What do you think about this @ghayman?