diff options
author | V13Axel <alex@stechstudio.com> | 2017-04-17 21:03:35 -0400 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2018-04-12 23:56:18 +0200 |
commit | ca280d7024bb75db4e1a893b1e1d7089b7a1746c (patch) | |
tree | abb7416b965c1e2cd229db1797aa78310b904d84 | |
parent | 6bf0107db63908e97c74503a447f358c64acc2d5 (diff) | |
download | wee-slack-ca280d7024bb75db4e1a893b1e1d7089b7a1746c.tar.gz |
Move formatting to its own function
-rw-r--r-- | wee_slack.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index ff3b394..5cfdeb4 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1368,7 +1368,7 @@ class SlackDMChannel(SlackChannel): self.type = 'im' self.update_color() self.set_name(self.slack_name) - self.slack_topic = {"value": "[{}] {}".format(users[dmuser].profile.get("status_emoji"), users[dmuser].profile.get("status_text"))} + self.slack_topic = {"value": create_user_status_string(users[dmuser].profile)} def set_name(self, slack_name): self.name = slack_name def create_buffer(self): @@ -1935,7 +1935,7 @@ def process_user_change(message_json, eventrouter, **kwargs): 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="[{}] {}".format(team.users[user["id"]].profile["status_emoji"], team.users[user["id"]].profile["status_text"])) + team.channels[dmchannel].render_topic(topic=create_user_status_string(profile)) def process_user_typing(message_json, eventrouter, **kwargs): channel = kwargs["channel"] @@ -2401,6 +2401,11 @@ def resolve_ref(ref): # Something else, just return as-is 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): |