aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-04-05 14:05:14 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-06-02 23:02:07 +0200
commit8304491a63566fad1764f569d6be1052f7889982 (patch)
tree563e679cbbc05a47d65c8923f16a48d33aaccfd6
parentcb5fb9d4683edf849ff7756354856eeebcded738 (diff)
downloadwee-slack-8304491a63566fad1764f569d6be1052f7889982.tar.gz
Set conditions for muted channels on channel instead of message
Instead of setting tags on each message to prevent notify and highlights, set variables on the buffer to prevent it.
-rw-r--r--wee_slack.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/wee_slack.py b/wee_slack.py
index bccde0b..632064e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1609,6 +1609,17 @@ class SlackChannel(SlackChannelCommon):
h_str = ",".join(self.highlights())
w.buffer_set(self.channel_buffer, "highlight_words", h_str)
+ if self.muted and config.muted_channels_activity != "all":
+ notify_level = "0" if config.muted_channels_activity == "none" else "1"
+ w.buffer_set(self.channel_buffer, "notify", notify_level)
+ else:
+ w.buffer_set(self.channel_buffer, "notify", "3")
+
+ if self.muted and config.muted_channels_activity == "none":
+ w.buffer_set(self.channel_buffer, "highlight_tags_restrict", "highlight_force")
+ else:
+ w.buffer_set(self.channel_buffer, "highlight_tags_restrict", "")
+
def create_buffer(self):
"""
Creates the weechat buffer where the channel magic happens.
@@ -1685,7 +1696,7 @@ class SlackChannel(SlackChannelCommon):
tagset = "default"
self.new_messages = True
- tags = tag(tagset, user=tag_nick, muted=self.muted)
+ tags = tag(tagset, user=tag_nick)
try:
if (config.unhide_buffers_with_activity
@@ -2119,7 +2130,7 @@ class SlackThreadChannel(SlackChannelCommon):
# tags = tag("dm")
# self.new_messages = True
# else:
- tags = tag("default", thread=True, muted=self.muted)
+ tags = tag("default")
# self.new_messages = True
w.prnt_date_tags(self.channel_buffer, ts.major, tags, data)
modify_last_print_time(self.channel_buffer, ts.minor)
@@ -3399,7 +3410,7 @@ def format_nick(nick, previous_nick=None):
return nick_prefix_color + nick_prefix + w.color("reset") + nick + nick_suffix_color + nick_suffix + w.color("reset")
-def tag(tagset, user=None, thread=False, muted=False):
+def tag(tagset, user=None):
tagsets = {
# messages in the team/server buffer, e.g. "new channel created"
"team_info": {"no_highlight", "log3"},
@@ -3419,13 +3430,6 @@ def tag(tagset, user=None, thread=False, muted=False):
nick_tag = {"nick_{}".format(user or "unknown").replace(" ", "_")}
slack_tag = {"slack_{}".format(tagset)}
tags = nick_tag | slack_tag | tagsets[tagset]
- if muted:
- tags.add("slack_muted_channel")
- if not thread and config.muted_channels_activity != "all":
- tags -= {"notify_highlight", "notify_message", "notify_private"}
- tags.add("notify_none")
- if config.muted_channels_activity == "none":
- tags.add("no_highlight")
return ",".join(tags)
###### New/converted command_ commands