From c5ed1cff2467bbe010c15bdf8cb69486deccf2ae Mon Sep 17 00:00:00 2001 From: Salad Dais Date: Thu, 14 Dec 2023 01:23:57 +0000 Subject: [PATCH] Handle non-templated EQ events in client --- hippolyzer/lib/client/hippo_client.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hippolyzer/lib/client/hippo_client.py b/hippolyzer/lib/client/hippo_client.py index 4dccd25..0830baf 100644 --- a/hippolyzer/lib/client/hippo_client.py +++ b/hippolyzer/lib/client/hippo_client.py @@ -513,10 +513,20 @@ class HippoClient(BaseClientSessionManager): continue polled = await resp.read_llsd() for event in polled["events"]: - if not self._llsd_serializer.can_handle(event["message"]): - # TODO: handle non-message EQ events - continue - msg = self._llsd_serializer.deserialize(event) + if self._llsd_serializer.can_handle(event["message"]): + msg = self._llsd_serializer.deserialize(event) + else: + # If this isn't a templated message (like some EQ-only events are), + # then we wrap it in a synthetic `Message` so that the API for handling + # both EQ-only and templated message events can be the same. Ick. + msg = Message(event["message"]) + if isinstance(event["body"], dict): + msg.add_block(Block("EventData", **event["body"])) + else: + # Shouldn't be any events that have anything other than a dict + # as a body, but just to be sure... + msg.add_block(Block("EventData", Data=event["body"])) + msg.synthetic = True self.session.message_handler.handle(msg) self.session.main_region.message_handler.handle(msg) ack = polled["id"]