aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason2016-08-01 11:34:14 -0600
committerjason2016-08-01 11:36:54 -0600
commit1a54414afff62561dff03e8a9f43287fa38176b6 (patch)
tree649c7b79be64ebf3d22a63c0c87b265cb62f3d8b
parent68f1e25218c19a8addd897d5f3e8bc02ae3c2edd (diff)
downloadwarmachine-ng-1a54414afff62561dff03e8a9f43287fa38176b6.tar.gz
warmachine-ng-1a54414afff62561dff03e8a9f43287fa38176b6.zip
Fix a bug where sometimes the nick isn't in the change user info
-rw-r--r--warmachine/connections/slack.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/warmachine/connections/slack.py b/warmachine/connections/slack.py
index 90903e7..7f54a55 100644
--- a/warmachine/connections/slack.py
+++ b/warmachine/connections/slack.py
@@ -166,12 +166,17 @@ class SlackWS(Connection):
166 https://api.slack.com/events/user_change 166 https://api.slack.com/events/user_change
167 """ 167 """
168 user_info = msg['user'] 168 user_info = msg['user']
169 old_nick = self.user_map[user_info['id']]['nick'] 169 try:
170 old_nick = self.user_map[user_info['id']]['nick']
171 except KeyError as e:
172 old_nick = None
173 self.log.exception('KeyError: {}'.format(e))
174 self.log.exception('{}'.format(msg))
170 175
171 self.user_map[user_info['id']] = user_info 176 self.user_map[user_info['id']] = user_info
172 177
173 # Update the nick mapping if the user changed their nickname 178 # Update the nick mapping if the user changed their nickname
174 if old_nick != user_info['nick']: 179 if old_nick and old_nick != user_info['nick']:
175 del self.user_nick_to_id[old_nick] 180 del self.user_nick_to_id[old_nick]
176 self.user_nick_to_id[user_info['nick']] = user_info['id'] 181 self.user_nick_to_id[user_info['nick']] = user_info['id']
177 182