diff options
author | Ryan Huber <rhuber@gmail.com> | 2017-01-26 09:47:39 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2017-01-26 09:47:39 -0800 |
commit | 56cdf97dabbe1bbea979e1be4ff751db12c6a8ba (patch) | |
tree | e7d0ea21afc6eac514fc7ba44aff694132721628 /wee_slack.py | |
parent | d2fafbe05544d459f04a70b40d6b46a1515f0e40 (diff) | |
parent | 2db4ea03ba635fc948c0a0cf4e384e5b0d43e3ee (diff) | |
download | wee-slack-56cdf97dabbe1bbea979e1be4ff751db12c6a8ba.tar.gz |
Merge commit 'refs/pull/285/head' of github.com:rawdigits/wee-slack
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2719d14..41dd7bb 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -374,6 +374,19 @@ class SlackServer(object): pass # w.prnt("", "%s\t%s" % (user, message)) + def set_away(self, msg): + async_slack_api_request(self.domain, self.token, 'presence.set', {"presence": "away"}) + for c in self.channels: + if c.channel_buffer is not None: + w.buffer_set(c.channel_buffer, "localvar_set_away", msg) + + def set_active(self): + async_slack_api_request(self.domain, self.token, 'presence.set', {"presence": "active"}) + for c in self.channels: + if c.channel_buffer is not None: + w.buffer_set(c.channel_buffer, "localvar_set_away", '') + w.buffer_set(c.channel_buffer, "localvar_del_away", '') + def buffer_input_cb(b, buffer, data): channel = channels.find(buffer) @@ -1298,6 +1311,25 @@ def command_test(current_buffer, args): w.prnt(current_buffer, "worked!") +def away_command_cb(data, current_buffer, args): + (all, message) = re.match("^/away(?:\s+(-all))?(?:\s+(.+))?", args).groups() + if all is None: + server = servers.find(current_domain_name()) + if not server: + return w.WEECHAT_RC_OK + if message is None: + server.set_active() + else: + server.set_away(message) + return w.WEECHAT_RC_OK_EAT + for server in servers: + if message is None: + server.set_active() + else: + server.set_away(message) + return w.WEECHAT_RC_OK + + @slack_buffer_required def command_away(current_buffer, args): """ @@ -2571,6 +2603,7 @@ if __name__ == "__main__": w.hook_command_run('/topic', 'topic_command_cb', '') w.hook_command_run('/msg', 'msg_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.bar_item_new('slack_typing_notice', 'typing_bar_item_cb', '') |