refactor to be uber profesh

This commit is contained in:
lza_menace 2020-09-23 12:11:16 -07:00
parent c91ef2b935
commit 101ec90dbb
1 changed files with 13 additions and 11 deletions

View File

@ -892,8 +892,10 @@ def weather(bot, trigger):
@sopel.module.commands('yeezy') @sopel.module.commands('yeezy')
def yeezy(bot, trigger): def yeezy(bot, trigger):
try: headers = {'User-Agent': 'monerobux-irc-bot-#wownero'}
res = requests.get('https://api.kanye.rest') resp = requests.get('https://api.kanye.rest', headers=headers, timeout=3)
bot.say(res.json()['quote']) resp.raise_for_status()
except Exception as e: blob = resp.json()
bot.say('borked: {}'.format(e) if 'quote' not in blob or not isinstance(blob['quote'], str):
raise Exception('malformed response')
bot.say(blob['quote'])