Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
prevent invalid index exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aerickson committed May 11, 2017
1 parent 08e0feb commit 84e4a1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rtmbot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ def output(self):
result = json.loads(self.slack_client.api_call('im.open', user=destination))
except ValueError:
self._dbg("Parse error on im.open call results!")
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
channel = self.slack_client.server.channels.find(result.get(u'channel', {}).get(u'id', None))
elif destination.startswith('G'):
try:
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
except ValueError:
self._dbg("Parse error on groups.open call results!")
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
channel = self.slack_client.server.channels.find(result.get(u'channel', {}).get(u'id', None))
else:
channel = self.slack_client.server.channels.find(destination)
if channel != None and message != None:
Expand Down

0 comments on commit 84e4a1c

Please sign in to comment.