diff --git a/tg/models.py b/tg/models.py index 52b5fd7..7756d82 100644 --- a/tg/models.py +++ b/tg/models.py @@ -351,7 +351,9 @@ class MsgModel: } def update_msg_content_opened(self, chat_id: int, msg_id: int) -> None: - index = self.msg_idx[chat_id][msg_id] + index = self.msg_idx[chat_id].get(msg_id) + if not index: + return msg = MsgProxy(self.msgs[chat_id][index]) if msg.content_type == "voice": msg.is_listened = True @@ -364,7 +366,9 @@ class MsgModel: def update_msg( self, chat_id: int, msg_id: int, **fields: Dict[str, Any] ) -> None: - index = self.msg_idx[chat_id][msg_id] + index = self.msg_idx[chat_id].get(msg_id) + if not index: + return msg = self.msgs[chat_id][index] msg.update(fields)