aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-02-21 17:26:26 -0800
committerRyan Huber <rhuber@gmail.com>2017-02-21 17:26:26 -0800
commitbfcd9dbb0a71b76a598b2ad46fc02abb098fc80d (patch)
treece3381efaaf379f07a123cbe9953500c90d1ee91
parent1b5fcb47332b40906424c2cdb04db263e7ebbaa4 (diff)
downloadwee-slack-bfcd9dbb0a71b76a598b2ad46fc02abb098fc80d.tar.gz
put back away/back
-rw-r--r--wee_slack.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 62a9916..218cb48 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2668,6 +2668,36 @@ def command_upload(data, current_buffer, args):
command = 'curl -F file=@{} -F channels={} -F token={} {}'.format(file_path, channel.identifier, team.token, url)
w.hook_process(command, config.slack_timeout, '', '')
+def away_command_cb(data, current_buffer, args):
+ #TODO: reimplement all.. maybe
+ (all, message) = re.match("^/away(?:\s+(-all))?(?:\s+(.+))?", args).groups()
+ if message is None:
+ command_back(data, current_buffer, args)
+ else:
+ command_away(data, current_buffer, args)
+ return w.WEECHAT_RC_OK
+
+@slack_buffer_required
+def command_away(data, current_buffer, args):
+ """
+ Sets your status as 'away'
+ /slack away
+ """
+ team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
+ s = SlackRequest(team.token, "presence.set", {"presence": "away"}, team_hash=team.team_hash)
+ EVENTROUTER.receive(s)
+
+
+@slack_buffer_required
+def command_back(data, current_buffer, args):
+ """
+ Sets your status as 'back'
+ /slack back
+ """
+ team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
+ s = SlackRequest(team.token, "presence.set", {"presence": "active"}, team_hash=team.team_hash)
+ EVENTROUTER.receive(s)
+
@slack_buffer_required
def label_command_cb(data, current_buffer, args):
channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer)
@@ -2772,12 +2802,12 @@ 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('/away', 'away_command_cb', '')
w.hook_completion("nicks", "complete @-nicks for slack", "nick_completion_cb", "")
w.hook_completion("emoji", "complete :emoji: for slack", "emoji_completion_cb", "")
# Hooks to fix/implement
- #w.hook_command_run('/away', 'away_command_cb', '')
#w.hook_timer(1000 * 60 * 5, 0, 0, "cache_write_cb", "")
#w.hook_signal('buffer_opened', "buffer_opened_cb", "")
#w.hook_signal('window_scrolled', "scrolled_cb", "")