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

Commit 84e4a1c

Browse files
committed
prevent invalid index exceptions
1 parent 08e0feb commit 84e4a1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rtmbot/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def output(self):
124124
result = json.loads(self.slack_client.api_call('im.open', user=destination))
125125
except ValueError:
126126
self._dbg("Parse error on im.open call results!")
127-
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
127+
channel = self.slack_client.server.channels.find(result.get(u'channel', {}).get(u'id', None))
128128
elif destination.startswith('G'):
129129
try:
130130
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
131131
except ValueError:
132132
self._dbg("Parse error on groups.open call results!")
133-
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
133+
channel = self.slack_client.server.channels.find(result.get(u'channel', {}).get(u'id', None))
134134
else:
135135
channel = self.slack_client.server.channels.find(destination)
136136
if channel != None and message != None:

0 commit comments

Comments
 (0)