Skip to content

Commit

Permalink
WPPCONNECT: React on message deleted. Fixes #110
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanogueira committed Apr 14, 2023
1 parent 9916afd commit 3ee7710
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion rocket_connect/plugins/wppconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,23 @@ def incoming(self):
) and not self.message.get("id", {}).get("fromMe", False):
self.logger_info(f"PROCESSED UNREAD MESSAGE. PAYLOAD {self.message}")

# message removed
if self.message.get("event") == "onrevokedmessage":
# get ref id
ref_id = self.message.get("refId")
if ref_id:
self.get_rocket_client()
msg = self.rocket.chat_get_message(msg_id=ref_id)
if msg:
new_message = ":warning: DELETED: ~{}~".format(
msg.json()["message"]["msg"]
)
room = self.get_room()
a = self.rocket.chat_update(
room_id=room.room_id, msg_id=ref_id, text=new_message
)
print(a.json())

# webhook active chat integration
if self.config.get("active_chat_webhook_integration_token"):
if self.message.get("token") == self.config.get(
Expand Down Expand Up @@ -929,7 +946,7 @@ def get_incoming_visitor_id(self):
if self.message.get("id", {}).get("fromMe"):
return self.message.get("id").get("remote")
else:
if self.message.get("event") == "unreadmessages":
if self.message.get("event") in ["unreadmessages", "onrevokedmessage"]:
return self.message.get("from")
else:
return self.message.get("chatId")
Expand Down

0 comments on commit 3ee7710

Please sign in to comment.