From 26f15a4a1572f529ff628df4e03dcd51da8f765a Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 29 Aug 2023 00:48:16 +0200 Subject: Show prefix for thread broadcast messages --- slack/config.py | 7 +++++++ slack/slack_message.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'slack') diff --git a/slack/config.py b/slack/config.py index 9cca910..e7d9937 100644 --- a/slack/config.py +++ b/slack/config.py @@ -123,6 +123,13 @@ class SlackConfigSectionLook: " :]", ) + self.thread_broadcast_prefix = WeeChatOption( + self._section, + "thread_broadcast_prefix", + "prefix to distinguish thread messages that were also sent to the channel, when thread_messages_in_channel is enabled", + "+ ", + ) + self.color_nicks_in_nicklist = WeeChatOption( self._section, "color_nicks_in_nicklist", diff --git a/slack/slack_message.py b/slack/slack_message.py index 1d61950..e304a9d 100644 --- a/slack/slack_message.py +++ b/slack/slack_message.py @@ -134,6 +134,10 @@ class SlackMessage: def is_reply(self) -> bool: return self.thread_ts is not None and not self.is_thread_parent + @property + def is_thread_broadcast(self) -> bool: + return self._message_json.get("subtype") == "thread_broadcast" + @property def parent_message(self) -> Optional[SlackMessage]: if not self.is_reply or self.thread_ts is None: @@ -546,7 +550,12 @@ class SlackMessage: if not parent_message: return "" - text = f"[{parent_message.hash}]" + broadcast_text = ( + shared.config.look.thread_broadcast_prefix.value + if self.is_thread_broadcast + else "" + ) + text = f"[{broadcast_text}{parent_message.hash}]" return with_color(nick_color(str(parent_message.hash)), text) + " " def _create_thread_string(self) -> str: -- cgit