aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2018-03-09 21:59:33 +0100
committerTollef Fog Heen <tfheen@err.no>2018-03-09 21:59:33 +0100
commitf3b8fa7867c6b2807efb4120e64c0bcdcbde54e6 (patch)
tree2cfad8f0b8e24cf51aaa412bc96882a91b155e82 /wee_slack.py
parent603801db24c083c88ca434b479c7ba79a3d005fb (diff)
downloadwee-slack-f3b8fa7867c6b2807efb4120e64c0bcdcbde54e6.tar.gz
Implement /whois command
Fixes: 507, based on the work done in that PR by @Shaac.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 9ebe788..a8819d7 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3018,6 +3018,34 @@ def topic_command_cb(data, current_buffer, command):
EVENTROUTER.receive(s)
return w.WEECHAT_RC_OK_EAT
+@slack_buffer_or_ignore
+@utf8_decode
+def whois_command_cb(data, current_buffer, command):
+ """
+ Get real name of user
+ /whois <display_name>
+ """
+
+ args = command.split()
+ if len(args) < 2:
+ w.prnt(current_buffer, "Not enough arguments")
+ return w.WEECHAT_RC_OK_EAT
+ user = args[1]
+ if (user.startswith('@')):
+ user = user[1:]
+ team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
+ u = team.users.get(team.get_username_map().get(user))
+ if u:
+ team.buffer_prnt("[{}]: {}".format(user, u.real_name))
+ if u.profile.get("status_text"):
+ team.buffer_prnt("[{}]: {} {}".format(user, u.profile.status_emoji, u.profile.status_text))
+ team.buffer_prnt("[{}]: Real name: {}".format(user, u.profile.get('real_name_normalized', '')))
+ team.buffer_prnt("[{}]: Title: {}".format(user, u.profile.get('title', '')))
+ team.buffer_prnt("[{}]: Email: {}".format(user, u.profile.get('email', '')))
+ team.buffer_prnt("[{}]: Phone: {}".format(user, u.profile.get('phone', '')))
+ else:
+ team.buffer_prnt("[{}]: No such user".format(user))
+ return w.WEECHAT_RC_OK_EAT
@slack_buffer_or_ignore
@utf8_decode
@@ -3526,6 +3554,7 @@ def setup_hooks():
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_command_run('/whois', 'whois_command_cb', '')
w.hook_completion("nicks", "complete @-nicks for slack", "nick_completion_cb", "")
w.hook_completion("emoji", "complete :emoji: for slack", "emoji_completion_cb", "")