Fix downloading voice msg and remove unnecessary sort operation

This commit is contained in:
Paul Nameless 2020-05-07 10:14:34 +08:00
parent b20fc378de
commit 5dbd7a843b
2 changed files with 2 additions and 5 deletions

View file

@ -229,11 +229,9 @@ class MsgModel:
log.info(f"adding {msg_id=} {message}")
self.msgs[chat_id].append(message)
msg_set.add(msg_id)
self.msgs[chat_id] = sorted(
self.msgs[chat_id], key=lambda d: d["id"], reverse=True
)
return True
def add_messages(self, chat_id: int, messages: Any) -> bool:
@ -282,9 +280,7 @@ class MsgModel:
messages = self._fetch_msgs_until_limit(chat_id, offset, limit)
self.add_messages(chat_id, messages)
return sorted(self.msgs[chat_id], key=lambda d: d["id"], reverse=True)[
offset:limit
]
return self.msgs[chat_id][offset:limit]
def send_message(self, chat_id: int, text: str) -> None:
log.info("Sending msg")

View file

@ -85,6 +85,7 @@ class MsgProxy:
"video",
"recording",
"sticker",
"voice",
):
return None
doc = self.get_doc(self.msg)