aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-08 13:33:55 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit359d508a31f3395ec3f004c723d185f474f63829 (patch)
tree483e6197c1f6637c6169b08750e096674715712d
parent12ce8befda90d79ff3c1533770e38f865728482f (diff)
downloadwee-slack-359d508a31f3395ec3f004c723d185f474f63829.tar.gz
Use notify_private tag in private buffers
-rw-r--r--slack/slack_conversation.py2
-rw-r--r--slack/slack_message.py41
2 files changed, 36 insertions, 7 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py
index aa8c66e..5870052 100644
--- a/slack/slack_conversation.py
+++ b/slack/slack_conversation.py
@@ -423,7 +423,7 @@ class SlackConversation(SlackBuffer):
await self.print_message(message)
else:
weechat.buffer_set(
- self.buffer_pointer, "hotlist", str(message.priority.value)
+ self.buffer_pointer, "hotlist", message.priority.value
)
parent_message = message.parent_message
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 06aac3f..2eb1bc7 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -91,10 +91,10 @@ def convert_int_to_roman(num: int) -> str:
class MessagePriority(Enum):
- LOW = 0
- MESSAGE = 1
- PRIVATE = 2
- HIGHLIGHT = 3
+ LOW = weechat.WEECHAT_HOTLIST_LOW
+ MESSAGE = weechat.WEECHAT_HOTLIST_MESSAGE
+ PRIVATE = weechat.WEECHAT_HOTLIST_PRIVATE
+ HIGHLIGHT = weechat.WEECHAT_HOTLIST_HIGHLIGHT
class SlackTs(str):
@@ -238,9 +238,35 @@ class SlackMessage:
def reactions(self) -> List[SlackMessageReaction]:
return self._message_json.get("reactions", [])
+ # This does not account for highlights
@property
def priority(self) -> MessagePriority:
- return MessagePriority.MESSAGE
+ if self.subtype in [
+ "channel_join",
+ "group_join",
+ "channel_leave",
+ "group_leave",
+ ]:
+ return MessagePriority.LOW
+ elif self.conversation.buffer_type == "private":
+ return MessagePriority.PRIVATE
+ else:
+ return MessagePriority.MESSAGE
+
+ # This does not account for highlights
+ @property
+ def priority_notify_tag(self) -> Optional[str]:
+ priority = self.priority
+ if priority == MessagePriority.HIGHLIGHT:
+ return "notify_highlight"
+ elif priority == MessagePriority.PRIVATE:
+ return "notify_private"
+ elif priority == MessagePriority.MESSAGE:
+ return "notify_message"
+ elif priority == MessagePriority.LOW:
+ return None
+ else:
+ assert_never(priority)
@property
def deleted(self) -> bool:
@@ -351,7 +377,10 @@ class SlackMessage:
elif await self.should_highlight():
log_tags = ["notify_highlight", "log1"]
else:
- log_tags = ["notify_message", "log1"]
+ log_tags = ["log1"]
+ notify_tag = self.priority_notify_tag
+ if notify_tag:
+ log_tags.append(notify_tag)
if backlog:
tags += ["no_highlight", "notify_none", "logger_backlog", "no_log"]