Fix mention-related KeyError in message callback

This commit is contained in:
miruka 2020-03-23 13:43:30 -04:00
parent 3c64b33cb7
commit 4fdf531631
2 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# TODO # TODO
- mention color in local echo
- cpu usage - cpu usage
- room.mentions += 1 key error before registration
## Main goals for next version ## Main goals for next version

View File

@ -101,16 +101,17 @@ class NioCallbacks:
room_id = room.room_id, 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) mention_list = HTML_PROCESSOR.mentions_in_html(co)
await self.client.register_nio_event( await self.client.register_nio_event(
room, ev, content=co, mentions=mention_list, 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: async def onRoomMessageNotice(self, room, ev) -> None:
await self.onRoomMessageText(room, ev) await self.onRoomMessageText(room, ev)