diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-07-18 13:30:02 -0400 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-07-18 13:30:02 -0400 |
commit | a9c41122ddcfa3d5384f69d45a4c26ea1f91719d (patch) | |
tree | 940a293a17171639a0026d6bcfae8cc4ad549b00 | |
parent | 5acbca4afce5b6130d797bb15654e49dce3c47d4 (diff) | |
download | wee-slack-a9c41122ddcfa3d5384f69d45a4c26ea1f91719d.tar.gz |
handle "distracting" channels with command
-rw-r--r-- | wee_slack.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py index 78ed425..90a7f4a 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -834,14 +834,28 @@ def command_channels(current_buffer, args): def command_nodistractions(current_buffer, args): global hide_distractions hide_distractions = not hide_distractions - if distracting_channels[0] != "": + if distracting_channels != ['']: for channel in distracting_channels: try: - w.buffer_set(channels.find(channel).channel_buffer, "hidden", str(int(hide_distractions))) + channel_buffer = channels.find(channel).channel_buffer + if channel_buffer: + w.buffer_set(channels.find(channel).channel_buffer, "hidden", str(int(hide_distractions))) except: dbg("Can't hide channel {}".format(channel), main_buffer=True) +def command_distracting(current_buffer, args): + global distracting_channels + distracting_channels = [x.strip() for x in w.config_get_plugin("distracting_channels").split(',')] + fullname = channels.find(current_buffer).fullname() + if distracting_channels.count(fullname) == 0: + distracting_channels.append(fullname) + else: + distracting_channels.pop(distracting_channels.index(fullname)) + new = ','.join(distracting_channels) + w.config_set_plugin('distracting_channels', new) + + @slack_buffer_required def command_users(current_buffer, args): """ @@ -862,7 +876,6 @@ def command_setallreadmarkers(current_buffer, args): for channel in channels: channel.mark_read() - def command_changetoken(current_buffer, args): w.config_set_plugin('slack_api_token', args) |