aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
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):