refactor to be uber profesh
This commit is contained in:
parent
c91ef2b935
commit
101ec90dbb
12
trifling.py
12
trifling.py
|
@ -892,8 +892,10 @@ def weather(bot, trigger):
|
|||
|
||||
@sopel.module.commands('yeezy')
|
||||
def yeezy(bot, trigger):
|
||||
try:
|
||||
res = requests.get('https://api.kanye.rest')
|
||||
bot.say(res.json()['quote'])
|
||||
except Exception as e:
|
||||
bot.say('borked: {}'.format(e)
|
||||
headers = {'User-Agent': 'monerobux-irc-bot-#wownero'}
|
||||
resp = requests.get('https://api.kanye.rest', headers=headers, timeout=3)
|
||||
resp.raise_for_status()
|
||||
blob = resp.json()
|
||||
if 'quote' not in blob or not isinstance(blob['quote'], str):
|
||||
raise Exception('malformed response')
|
||||
bot.say(blob['quote'])
|
||||
|
|
Loading…
Reference in New Issue