Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

Get removed reactions

Open IanosJunior opened this issue 1 year ago • 13 comments

The messages.reaction event fires only when you set or change a reaction. Is there any way to tell if the reaction has been removed?

IanosJunior avatar May 18 '23 20:05 IanosJunior

It is documented, look at the link that I give you https://whiskeysockets.github.io/Baileys/index.html

image

andresayac avatar May 20 '23 18:05 andresayac

It is documented, look at the link that I give you https://whiskeysockets.github.io/Baileys/index.html

image

I would like an event to identify that the reaction has been removed. The "messages.reaction" event does not fire when removing.

IanosJunior avatar May 20 '23 19:05 IanosJunior

Well you have to manually record all the reactions and their sender id that a message has received

When receiving an empty reaction (ie. removing the reaction), then you can check what this sender's reaction emoji was.

aidulcandra avatar May 22 '23 15:05 aidulcandra

But the problem is that the "messages.reaction" event is not fired when the reaction is empty

Well you have to manually record all the reactions and their sender id that a message has received

When receiving an empty reaction (ie. removing the reaction), then you can check what this sender's reaction emoji was.

IanosJunior avatar May 29 '23 14:05 IanosJunior

@IanosJunior The reason why the messages.reaction event is not fired when the reactionMessage.text is empty is probably in here, but I'm still trying to understand the code. https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/event-buffer.ts#LL433C27-L433C27

matheusb-comp avatar Jun 17 '23 00:06 matheusb-comp

@IanosJunior Found it! The event-buffer calls the util function updateMessageWithReaction that in turn checks if the reaction text has a value before pushing the reaction to the message object: https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/messages.ts#L719

Since the reactionMessage.text is empty, it will not be pushed, and (I imagine that) when the event-buffer gets flushed, the messages.reaction is not fired because this specific reaction is not in the message's "reaction list".

matheusb-comp avatar Jun 17 '23 00:06 matheusb-comp

@IanosJunior Found it! The event-buffer calls the util function updateMessageWithReaction that in turn checks if the reaction text has a value before pushing the reaction to the message object:

https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/messages.ts#L719

Since the reactionMessage.text is empty, it will not be pushed, and (I imagine that) when the event-buffer gets flushed, the messages.reaction is not fired because this specific reaction is not in the message's "reaction list".

In this case, it would be better to remove this conditional to know when the reaction was removed. What do you think @matheusb-comp ?

IanosJunior avatar Jun 18 '23 22:06 IanosJunior

@IanosJunior Just removing this conditional would make these "reactions with empty text" to be added to the msg.reactions array. Since the updateMessageWithReaction function is called in multiple points in the code (including the event-buffer), I don't know what problems this could cause.

What I'm doing to handle this (in my custom "data-store") is to ignore the messages.reaction event and emit custom events inside the sock.ev.on("messages.upsert", ...) based on the message.reactionMessage.text.

matheusb-comp avatar Jun 19 '23 11:06 matheusb-comp

So, let discuss about this, what we can do? Change the messages.reaction to include empty reaction (remove) or create a new event (maybe messages.reaction.delete)

👍 for update messages.reaction with empty reaction 😄 for messages.reaction.delete (or other name)

edgardmessias avatar Jun 19 '23 12:06 edgardmessias

So, let discuss about this, what we can do? Change the messages.reaction to include empty reaction (remove) or create a new event (maybe messages.reaction.delete)

👍 for update messages.reaction with empty reaction 😄 for messages.reaction.delete (or other name)

In the tests I did, just removing the conditional already solves the problem. I don't know if it might impact storage.

IanosJunior avatar Jun 19 '23 13:06 IanosJunior

So, let discuss about this, what we can do? Change the messages.reaction to include empty reaction (remove) or create a new event (maybe messages.reaction.delete)

👍 for update messages.reaction with empty reaction 😄 for messages.reaction.delete (or other name)

So, will we have an update on this? I got myself stuck because of removed reactions aren't emitted.

SalazarF92 avatar Jan 03 '24 22:01 SalazarF92

Is this still an issue? Assigning myself to test this later!

purpshell avatar May 07 '24 19:05 purpshell

Forgot to follow up, still an issue, will fix

purpshell avatar Jul 03 '24 07:07 purpshell