diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2018-08-11 12:18:55 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2018-09-04 20:48:27 +0200 |
commit | 871781879c2a19877a19be8d59bf5938f57f5d58 (patch) | |
tree | c76f4de57991488ae4edaa33f8725dc95f042d58 /wee_slack.py | |
parent | 24ad703676fd03077d7b943f11a942e61da694e0 (diff) | |
download | wee-slack-871781879c2a19877a19be8d59bf5938f57f5d58.tar.gz |
Add a 'muted_channels_activity' config option
This allows you to control which activity from muted channels you will
be notified for.
The default is set to personal_highlights, as I find that the most
useful. The official client doesn't send a notification for any
activity, but it shows highlights in the sidebar, so all_highlights is
probably the closest to that. However, since there isn't any difference
between highlights from muted and non-muted channels in wee-slack, I
think getting channel highlights from muted channels is a bit much.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py index 830d1cc..6962c4b 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1100,6 +1100,8 @@ class SlackTeam(object): def set_muted_channels(self, muted_str): self.muted_channels = {x for x in muted_str.split(',') if x} + for channel in self.channels.itervalues(): + channel.set_highlights() def set_highlight_words(self, highlight_str): self.highlight_words = {x for x in highlight_str.split(',') if x} @@ -1303,7 +1305,7 @@ class SlackChannel(object): def set_unread_count_display(self, count): self.unread_count_display = count self.new_messages = bool(self.unread_count_display) - if self.muted: + if self.muted and config.muted_channels_activity != "all": return for c in range(self.unread_count_display): if self.type in ["im", "mpim"]: @@ -1378,7 +1380,11 @@ class SlackChannel(object): return {'@' + self.team.nick, self.team.myidentifier} def highlights(self): - return self.team.highlight_words.union(self.mentions()).union({"!here", "!channel", "!everyone"}) + personal_highlights = self.team.highlight_words.union(self.mentions()) + if self.muted and config.muted_channels_activity == "personal_highlights": + return personal_highlights + else: + return personal_highlights.union({"!here", "!channel", "!everyone"}) def set_highlights(self): # highlight my own name and any set highlights @@ -3151,9 +3157,11 @@ def tag(tagset, user=None, muted=False): nick_tag = {"nick_{}".format(user or "unknown").replace(" ", "_")} slack_tag = {"slack_{}".format(tagset)} tags = nick_tag | slack_tag | tagsets[tagset] - if muted: + if muted and config.muted_channels_activity != "all": tags -= {"notify_highlight", "notify_message", "notify_private"} - tags |= {"no_highlight", "notify_none"} + tags.add("notify_none") + if config.muted_channels_activity == "none": + tags.add("no_highlight") return ",".join(tags) ###### New/converted command_ commands @@ -3845,6 +3853,14 @@ class PluginConfig(object): desc='When sending underlined text to slack, use this formatting' ' character for it. The default ("_") sends it as italics. Use' ' "*" to send bold instead.'), + 'muted_channels_activity': Setting( + default='personal_highlights', + desc="Control which activity you see from muted channels, either" + " none, personal_highlights, all_highlights or all. none: Don't" + " show any activity. personal_highlights: Only show personal" + " highlights, i.e. not @channel and @here. all_highlights: Show" + " all highlights, but not other messages. all: Show all activity," + " like other channels."), 'never_away': Setting( default='false', desc='Poke Slack every five minutes so that it never marks you "away".'), @@ -3973,6 +3989,7 @@ class PluginConfig(object): get_external_user_suffix = get_string get_group_name_prefix = get_string get_map_underline_to = get_string + get_muted_channels_activity = get_string get_render_bold_as = get_string get_render_italic_as = get_string get_shared_name_prefix = get_string |