aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-06-01 21:55:17 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-06-02 23:09:20 +0200
commit38d523ad8efa8b6d4bbe22b117c9387afcc22721 (patch)
treef9026e4dd837b86ce8b8bbbd1be41a348d1ef115 /wee_slack.py
parentc6bf8805cbd917c242bc251c0d7889dfde435884 (diff)
downloadwee-slack-38d523ad8efa8b6d4bbe22b117c9387afcc22721.tar.gz
Support printing status with /slack status command
Now prints the status if no arguments are given. To unset the status, pass the argument -delete. Fixes #574
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 3c37102..05ddbe8 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -4038,18 +4038,25 @@ def command_away(data, current_buffer, args):
@utf8_decode
def command_status(data, current_buffer, args):
"""
- /slack status [emoji [status_message]]
+ /slack status [<emoji> [<status_message>]|-delete]
Lets you set your Slack Status (not to be confused with away/here).
+ Prints current status if no arguments are given, unsets the status if -delete is given.
"""
team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
- split_args = args.split(' ', 1)
- emoji = split_args[0]
- text = split_args[1] if len(split_args) > 1 else ""
+ split_args = args.split(" ", 1)
+ if not split_args[0]:
+ profile = team.users[team.myidentifier].profile
+ team.buffer_prnt("Status: {} {}".format(
+ profile.get("status_emoji", ""),
+ profile.get("status_text", "")))
+ return w.WEECHAT_RC_OK
- profile = {"status_text": text, "status_emoji": emoji}
+ emoji = "" if split_args[0] == "-delete" else split_args[0]
+ text = split_args[1] if len(split_args) > 1 else ""
+ new_profile = {"status_text": text, "status_emoji": emoji}
- s = SlackRequest(team.token, "users.profile.set", {"profile": profile}, team_hash=team.team_hash)
+ s = SlackRequest(team.token, "users.profile.set", {"profile": new_profile}, team_hash=team.team_hash)
EVENTROUTER.receive(s)
return w.WEECHAT_RC_OK