aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_message.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-09-17 11:30:53 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit994e2d246fc09ed942a871696ccae1bdc3002217 (patch)
tree2c1ac01192e50c6d1c717f8c78b70fd47585fcf9 /slack/slack_message.py
parent2a9cad66efec738e68230d335540e6c9e7d9c7e8 (diff)
downloadwee-slack-994e2d246fc09ed942a871696ccae1bdc3002217.tar.gz
Support thread buffers
Diffstat (limited to 'slack/slack_message.py')
-rw-r--r--slack/slack_message.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 0466559..6728038 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -35,9 +35,10 @@ if TYPE_CHECKING:
SlackMessageReaction,
SlackMessageSubtypeHuddleThreadRoom,
)
- from typing_extensions import assert_never
+ from typing_extensions import Literal, assert_never
from slack.slack_conversation import SlackConversation
+ from slack.slack_thread import SlackThread
from slack.slack_workspace import SlackWorkspace
@@ -110,6 +111,7 @@ class SlackMessage:
self.ts = SlackTs(message_json["ts"])
self.replies: OrderedDict[SlackTs, SlackMessage] = OrderedDict()
self.reply_history_filled = False
+ self.thread_buffer: Optional[SlackThread] = None
self._deleted = False
@property
@@ -261,9 +263,12 @@ class SlackMessage:
return ",".join(tags)
- async def render(self) -> str:
+ async def render(
+ self,
+ context: Literal["conversation", "thread"],
+ ) -> str:
prefix_coro = self.render_prefix()
- message_coro = self.render_message()
+ message_coro = self.render_message(context)
prefix, message = await gather(prefix_coro, message_coro)
self._rendered = f"{prefix}\t{message}"
return self._rendered
@@ -382,9 +387,15 @@ class SlackMessage:
self._rendered_message = text + text_edited + reactions
return self._rendered_message
- async def render_message(self, rerender: bool = False) -> str:
- thread_prefix = self._create_thread_prefix()
+ async def render_message(
+ self,
+ context: Literal["conversation", "thread"],
+ rerender: bool = False,
+ ) -> str:
text = await self._render_message(rerender=rerender)
+ if context == "thread":
+ return text
+ thread_prefix = self._create_thread_prefix()
thread = self._create_thread_string()
return thread_prefix + text + thread