aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-04-12 23:59:03 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-04-13 00:05:08 +0200
commit64bf34e280ad1db6ef092c73f0737fd7bfe71334 (patch)
treea20c8961437e1e561869c1cd72e0a479b4e94c14 /wee_slack.py
parent37840baea2a48db7192c2ef502b5b36995476981 (diff)
parentca280d7024bb75db4e1a893b1e1d7089b7a1746c (diff)
downloadwee-slack-64bf34e280ad1db6ef092c73f0737fd7bfe71334.tar.gz
Sync branch 'status_as_dm_topic' with master
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1b6919d..6ebba2e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1633,6 +1633,7 @@ class SlackDMChannel(SlackChannel):
self.type = 'im'
self.update_color()
self.set_name(self.slack_name)
+ self.topic = create_user_status_string(users[dmuser].profile)
def set_name(self, slack_name):
self.name = slack_name
@@ -1942,6 +1943,10 @@ class SlackUser(object):
self.color_name = get_nick_color_name(self.name)
self.color = w.color(self.color_name)
+ def update_status(self, status_emoji, status_text):
+ self.profile["status_emoji"] = status_emoji
+ self.profile["status_text"] = status_text
+
def formatted_name(self, prepend="", enable_color=True):
if enable_color:
return self.color + prepend + self.name
@@ -2295,6 +2300,18 @@ def process_pref_change(message_json, eventrouter, **kwargs):
dbg("Preference change not implemented: {}\n".format(message_json['name']))
+def process_user_change(message_json, eventrouter, **kwargs):
+ """
+ Currently only used to update status, but lots here we could do.
+ """
+ user = message_json['user']
+ profile = user.get("profile")
+ team = kwargs["team"]
+ team.users[user["id"]].update_status(profile.get("status_emoji"), profile.get("status_text"))
+ dmchannel = team.get_channel_map()[user["name"]]
+ team.channels[dmchannel].render_topic(topic=create_user_status_string(profile))
+
+
def process_user_typing(message_json, eventrouter, **kwargs):
channel = kwargs["channel"]
team = kwargs["team"]
@@ -2821,6 +2838,12 @@ def resolve_ref(ref):
return ref
+def create_user_status_string(profile):
+ status_emoji = profile.get("status_emoji") if profile.get("status_emoji") else "None"
+ status_text = profile.get("status_text") if profile.get("status_text") else "None"
+ return "[{}] {}".format(status_emoji, status_text)
+
+
def create_reaction_string(reactions):
count = 0
if not isinstance(reactions, list):