From 07ea679ecd01b3a080c60ded0efa84c125db331d Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 27 Feb 2021 10:08:59 -0800 Subject: [PATCH] fix channel type check and parsing payload --- pnut-matrix.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pnut-matrix.py b/pnut-matrix.py index 378ebe4..e12f15e 100644 --- a/pnut-matrix.py +++ b/pnut-matrix.py @@ -252,22 +252,23 @@ def on_message(ws, message): if 'data' in msg: - if msg['meta']['type'] == "message": + if 'channel_type' in msg['meta']: # TODO: bypassed other channel types for now if msg['meta']['channel_type'] != 'io.pnut.core.chat': return - pmsg = pnutpy.models.Message.from_response_data(msg['data']) + for d_item in msg['data']: + pmsg = pnutpy.models.Message.from_response_data(d_item) - if 'is_deleted' in msg['meta']: - if msg['meta']['is_deleted']: - logger.debug("message: delete") - delete_message(pmsg) + if 'is_deleted' in msg['meta']: + if msg['meta']['is_deleted']: + logger.debug("message: delete") + delete_message(pmsg) + else: + logger.debug("uh whut?") else: - logger.debug("uh whut?") - else: - new_message(pmsg) + new_message(pmsg) def on_error(ws, error): logger.error("on_error: !!! ERROR !!!")