From 4fdf5316310a27193cda2b7f2b99a029b89f45dd Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 23 Mar 2020 13:43:30 -0400 Subject: [PATCH] Fix mention-related KeyError in message callback --- TODO.md | 2 +- src/backend/nio_callbacks.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 53bf8ff8..869a184b 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ # TODO +- mention color in local echo - cpu usage -- room.mentions += 1 key error before registration ## Main goals for next version diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 38fd083d..0b262cd9 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -101,16 +101,17 @@ class NioCallbacks: room_id = room.room_id, ) - if HTML_PROCESSOR.user_id_link_in_html(co, self.client.user_id): - rooms = self.client.models[self.client.user_id, "rooms"] - rooms[room.room_id].mentions += 1 - mention_list = HTML_PROCESSOR.mentions_in_html(co) await self.client.register_nio_event( room, ev, content=co, mentions=mention_list, ) + if HTML_PROCESSOR.user_id_link_in_html(co, self.client.user_id): + rooms = self.client.models[self.client.user_id, "rooms"] + rooms[room.room_id].mentions += 1 + + async def onRoomMessageNotice(self, room, ev) -> None: await self.onRoomMessageText(room, ev)