randomreddit: handle invalid json response
This commit is contained in:
@@ -35,8 +35,11 @@ def randomreddit(phenny, input):
|
|||||||
except:
|
except:
|
||||||
raise GrumbleError('Reddit or subreddit unreachable.')
|
raise GrumbleError('Reddit or subreddit unreachable.')
|
||||||
|
|
||||||
|
try:
|
||||||
reddit = json.loads(resp)
|
reddit = json.loads(resp)
|
||||||
post = choice(reddit['data']['children'])
|
post = choice(reddit['data']['children'])
|
||||||
|
except:
|
||||||
|
raise GrumbleError('Error parsing response from Reddit.')
|
||||||
|
|
||||||
nsfw = False
|
nsfw = False
|
||||||
if post['data']['over_18']:
|
if post['data']['over_18']:
|
||||||
|
|||||||
Reference in New Issue
Block a user