aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-09-24 01:34:42 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2017-09-24 01:34:42 +0200
commit7357af12b7ec41b8054d4b06bcb9d1553d5e2d7b (patch)
treed92411664b88f59abea6751c57273eb6565d2be9 /wee_slack.py
parentdf3f6ab6b25a9eff1df908bf8a4110e7f66ff144 (diff)
downloadwee-slack-7357af12b7ec41b8054d4b06bcb9d1553d5e2d7b.tar.gz
feat: Add support for /input set_unread(_current_buffer)
This hooks into the weechat commands `/input set_unread` and `/input set_unread_current_buffer` and implements them. For set_unread we iterate over all the channels and mark them as read. For set_unread_current_buffer we mark the current buffer as read. Fixes #323
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 939722a..977470b 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3175,6 +3175,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)))
@@ -3276,6 +3293,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", "")