diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-09-01 22:46:14 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 30eea6bb1f4278b79583e8130aef5e404411a31b (patch) | |
tree | 57eadb1ccf0c9b5a3bccd7ddf84403293237cce6 /slack/slack_conversation.py | |
parent | c14ed0a9eb18e7e073b37948a4e1286109af1e36 (diff) | |
download | wee-slack-30eea6bb1f4278b79583e8130aef5e404411a31b.tar.gz |
Create a readonly messages property instead of get_message
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r-- | slack/slack_conversation.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 20b1085..fd73385 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -4,7 +4,7 @@ import hashlib import time from collections import OrderedDict from contextlib import contextmanager -from typing import TYPE_CHECKING, Dict, List, NoReturn, Optional, Union +from typing import TYPE_CHECKING, Dict, List, Mapping, NoReturn, Optional, Union import weechat @@ -196,11 +196,10 @@ class SlackConversationMessageHashes(Dict[SlackTs, str]): self._setitem(ts_with_same_hash, other_short_hash) self._inverse_map[other_short_hash] = ts_with_same_hash - other_message = self._conversation.get_message(ts_with_same_hash) - if other_message: - run_async(self._conversation.rerender_message(other_message)) - for reply in other_message.replies: - run_async(self._conversation.rerender_message(reply)) + other_message = self._conversation.messages[ts_with_same_hash] + run_async(self._conversation.rerender_message(other_message)) + for reply in other_message.replies: + run_async(self._conversation.rerender_message(reply)) self._setitem(key, short_hash) self._inverse_map[short_hash] = key @@ -249,6 +248,10 @@ class SlackConversation: return self._info["id"] @property + def messages(self) -> Mapping[SlackTs, SlackMessage]: + return self._messages + + @property def type(self) -> Literal["channel", "private", "mpim", "im"]: if self._info["is_im"] is True: return "im" @@ -313,9 +316,6 @@ class SlackConversation: finally: self.completion_context = "ACTIVE_COMPLETION" - def get_message(self, ts: SlackTs) -> Optional[SlackMessage]: - return self._messages.get(ts) - async def open_if_open(self): if "is_open" in self._info: if self._info["is_open"]: |