diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2019-03-05 22:00:24 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-03-05 22:00:24 +0100 |
commit | 05657c23c1e74e90a2e0588df75fe0a535ac6323 (patch) | |
tree | 093fc8695d0dfc486278480c60c876597243d2ce | |
parent | 8d778b7ece7c8f484252b719464f7d05bab9bca4 (diff) | |
download | wee-slack-05657c23c1e74e90a2e0588df75fe0a535ac6323.tar.gz |
Check if user exists before updating status
The team may have external users (i.e. guests or users from other
teams), which we don't store in the team user list, so ignore status
updates for those.
-rw-r--r-- | wee_slack.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py index 310be3c..8d19190 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2574,10 +2574,12 @@ 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.find_channel_by_members({user["id"]}, channel_type='im') + profile = user.get('profile') + team = kwargs['team'] + team_user = team.users.get(user['id']) + if team_user: + team_user.update_status(profile.get('status_emoji'), profile.get('status_text')) + dmchannel = team.find_channel_by_members({user['id']}, channel_type='im') if dmchannel: dmchannel.set_topic(create_user_status_string(profile)) |