aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-14 18:28:03 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit184bf08360003538179e3c19b2711016c823eadd (patch)
treee7f77291fcb56dba5b28ebc4431f9ce26816254d
parente8c464b7e3512e39c7c1d97a78904ae7b437f932 (diff)
downloadwee-slack-184bf08360003538179e3c19b2711016c823eadd.tar.gz
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.
-rw-r--r--slack/shared.py1
-rw-r--r--slack/slack_buffer.py6
-rw-r--r--slack/slack_message.py5
3 files changed, 11 insertions, 1 deletions
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)