randomreddit: handle invalid json response
parent
6ecbe4ca18
commit
9f11190f0b
|
@ -35,8 +35,11 @@ def randomreddit(phenny, input):
|
|||
except:
|
||||
raise GrumbleError('Reddit or subreddit unreachable.')
|
||||
|
||||
try:
|
||||
reddit = json.loads(resp)
|
||||
post = choice(reddit['data']['children'])
|
||||
except:
|
||||
raise GrumbleError('Error parsing response from Reddit.')
|
||||
|
||||
nsfw = False
|
||||
if post['data']['over_18']:
|
||||
|
|
Loading…
Reference in New Issue