aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_message.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-31 00:26:56 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commitc14ed0a9eb18e7e073b37948a4e1286109af1e36 (patch)
tree06a0b8b84b94a561583b9b52dd06079848c737c9 /slack/slack_message.py
parentdce234ea366d688a0aa899aa1bc4cf56a2d1a009 (diff)
downloadwee-slack-c14ed0a9eb18e7e073b37948a4e1286109af1e36.tar.gz
Render tombstone messages as deleted messages
Diffstat (limited to 'slack/slack_message.py')
-rw-r--r--slack/slack_message.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py
index e304a9d..0a1870b 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -167,7 +167,7 @@ class SlackMessage:
@property
def deleted(self) -> bool:
- return self._deleted
+ return self._deleted or self._message_json.get("subtype") == "tombstone"
@deleted.setter
def deleted(self, value: bool):
@@ -364,11 +364,12 @@ class SlackMessage:
else:
return full_text
- async def _render_message(self) -> str:
- if self._deleted:
+ async def _render_message(self, rerender: bool = False) -> str:
+ if self.deleted:
return with_color(shared.config.color.deleted_message.value, "(deleted)")
+ elif self._rendered_message is not None and not rerender:
+ return self._rendered_message
else:
- thread_prefix = self._create_thread_prefix()
text = await self._render_message_text()
text_edited = (
f" {with_color(shared.config.color.edited_message_suffix.value, '(edited)')}"
@@ -376,14 +377,14 @@ class SlackMessage:
else ""
)
reactions = await self._create_reactions_string()
- thread = self._create_thread_string()
- return thread_prefix + text + text_edited + reactions + thread
+ self._rendered_message = text + text_edited + reactions
+ return self._rendered_message
async def render_message(self, rerender: bool = False) -> str:
- if self._rendered_message is not None and not rerender:
- return self._rendered_message
- self._rendered_message = await self._render_message()
- return self._rendered_message
+ thread_prefix = self._create_thread_prefix()
+ text = await self._render_message(rerender=rerender)
+ thread = self._create_thread_string()
+ return thread_prefix + text + thread
def _item_prefix(self, item_id: str):
if item_id.startswith("#") or item_id.startswith("@"):