aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2015-10-13 20:36:40 +0200
committerTollef Fog Heen <tfheen@err.no>2015-10-13 20:38:56 +0200
commit03d7771396b61bb5b6c5b5a25c8876867570850e (patch)
tree75228e63815170a5a998d3a7a222e3317ec33a48
parent2d50c4e59ae603706840ea42ec1e718c62232458 (diff)
downloadwee-slack-03d7771396b61bb5b6c5b5a25c8876867570850e.tar.gz
Handle muted of channels by not showing activity for them
If a channel is muted, don't show any activity for it, unless you're explicitly mentioned. Fixes: #25
-rw-r--r--wee_slack.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index db4b178..e691a97 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -287,6 +287,8 @@ class SlackServer(object):
item["last_read"] = 0
name = self.users.find(item["user"]).name
self.add_channel(DmChannel(self, name, item["id"], item["is_open"], item["last_read"]))
+ for item in data['self']['prefs']['muted_channels'].split(','):
+ self.channels.find(item).muted = True
for item in self.channels:
item.get_history()
@@ -338,6 +340,7 @@ class Channel(object):
self.last_received = None
self.messages = []
self.scrolling = False
+ self.muted = False
if active:
self.create_buffer()
self.attach_buffer()
@@ -569,6 +572,8 @@ class Channel(object):
tags = "notify_highlight"
elif user != self.server.nick and self.name in self.server.users:
tags = "notify_private,notify_message"
+ elif self.muted:
+ tags = "no_highlight,notify_none,logger_backlog_end"
elif user in [x.strip() for x in w.prefix("join"), w.prefix("quit")]:
tags = "irc_smart_filter"
else:
@@ -1169,6 +1174,19 @@ def process_pong(message_json):
pass
+def process_pref_change(message_json):
+ server = servers.find(message_json["myserver"])
+ if message_json['name'] == u'muted_channels':
+ muted = message_json['value'].split(',')
+ for c in server.channels:
+ if c.identifier in muted:
+ c.muted = True
+ else:
+ c.muted = False
+ else:
+ dbg("Preference change not implemented: {}\n{}".format(message_json['name']))
+
+
def process_team_join(message_json):
server = servers.find(message_json["myserver"])
item = message_json["user"]