aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-09-28 23:54:07 +0200
committerGitHub <noreply@github.com>2017-09-28 23:54:07 +0200
commit9fd7ca208bf56cc47796696399f5d603130267e4 (patch)
tree1d87e93b026bf387dee4328b66e08529db00adcc /wee_slack.py
parent2b5ac736bd2d5be567d12ea081f9f582bf98e18a (diff)
parent7357af12b7ec41b8054d4b06bcb9d1553d5e2d7b (diff)
downloadwee-slack-9fd7ca208bf56cc47796696399f5d603130267e4.tar.gz
Merge pull request #441 from trygveaa/feat/support-input-set-unread
Support `/input set unread` and `/input set_unread_current_buffer`
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index b5786bc..5ea3729 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1051,7 +1051,7 @@ class SlackTeam(object):
else:
return False
- def mark_read(self):
+ def mark_read(self, ts=None, update_remote=True, force=False):
pass
def connect(self):
@@ -1176,6 +1176,7 @@ class SlackChannel(object):
def set_unread_count_display(self, count):
self.unread_count_display = count
+ self.new_messages = bool(self.unread_count_display)
for c in range(self.unread_count_display):
if self.type == "im":
w.buffer_set(self.channel_buffer, "hotlist", "2")
@@ -3199,6 +3200,23 @@ def label_command_cb(data, current_buffer, args):
w.buffer_set(channel.channel_buffer, "short_name", new_name)
+def set_unread_cb(data, current_buffer, command):
+ data = decode_from_utf8(data)
+ command = decode_from_utf8(command)
+ for channel in EVENTROUTER.weechat_controller.buffers.values():
+ channel.mark_read()
+ return w.WEECHAT_RC_OK
+
+
+@slack_buffer_or_ignore
+def set_unread_current_buffer_cb(data, current_buffer, command):
+ data = decode_from_utf8(data)
+ command = decode_from_utf8(command)
+ channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer)
+ channel.mark_read()
+ return w.WEECHAT_RC_OK
+
+
def command_p(data, current_buffer, args):
args = args.split(' ', 1)[1]
w.prnt("", "{}".format(eval(args)))
@@ -3300,6 +3318,8 @@ def setup_hooks():
w.hook_command_run('/msg', 'msg_command_cb', '')
w.hook_command_run('/label', 'label_command_cb', '')
w.hook_command_run("/input complete_next", "complete_next_cb", "")
+ w.hook_command_run("/input set_unread", "set_unread_cb", "")
+ w.hook_command_run("/input set_unread_current_buffer", "set_unread_current_buffer_cb", "")
w.hook_command_run('/away', 'away_command_cb', '')
w.hook_completion("nicks", "complete @-nicks for slack", "nick_completion_cb", "")