From 184bf08360003538179e3c19b2711016c823eadd Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 14 Oct 2023 18:28:03 +0200 Subject: Apply highlights in chat even when notify is none When notify is none, the buffer should not appear in the hotlist even for a highlight. However, when switching to the buffer, we want the line to be highlighted. To achieve this use a tag added to highlight_tags on the buffer. --- slack/shared.py | 1 + slack/slack_buffer.py | 6 ++++++ slack/slack_message.py | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/slack/shared.py b/slack/shared.py index 1661a04..eeb6df5 100644 --- a/slack/shared.py +++ b/slack/shared.py @@ -29,6 +29,7 @@ class Shared: self.config: SlackConfig self.uncaught_errors: List[UncaughtError] = [] self.standard_emojis: Dict[str, Emoji] + self.highlight_tag = "highlight" shared = Shared() diff --git a/slack/slack_buffer.py b/slack/slack_buffer.py index 9554db1..adad7b7 100644 --- a/slack/slack_buffer.py +++ b/slack/slack_buffer.py @@ -203,6 +203,12 @@ class SlackBuffer(ABC): name, buffer_props = await self.get_name_and_buffer_props() full_name = self.get_full_name(name) + buffer_props["highlight_tags"] = ( + f"{buffer_props['highlight_tags']},{shared.highlight_tag}" + if buffer_props.get("highlight_tags") + else shared.highlight_tag + ) + if switch: buffer_props["display"] = "1" diff --git a/slack/slack_message.py b/slack/slack_message.py index c51c8b4..ddb2ceb 100644 --- a/slack/slack_message.py +++ b/slack/slack_message.py @@ -383,7 +383,10 @@ class SlackMessage: elif priority == MessagePriority.LOW: return None elif priority == MessagePriority.NONE: - return "notify_none" + tags = ["notify_none"] + if self.should_highlight(False): + tags.append(shared.highlight_tag) + return ",".join(tags) else: assert_never(priority) -- cgit