Change error on invalid meme format

This commit is contained in:
minerobber 2018-12-26 21:58:35 +00:00
parent fd588cffee
commit 3759e19145
1 changed files with 7 additions and 4 deletions

View File

@ -26,7 +26,10 @@ def memegen(bot,channel,nick,template,*msg):
if "://" in template: # URL
bot.say(channel,"{}: https://memegen.link/custom/{}/{}.jpg?alt={}".format(nick,top,bottom,template))
else:
r = requests.get("https://memegen.link/{}/{}/{}".format(template,top,bottom))
r.raise_for_status()
r = r.json()
bot.say(channel,"{}: {}".format(nick,r["direct"]["masked"]))
try:
r = requests.get("https://memegen.link/{}/{}/{}".format(template,top,bottom))
r.raise_for_status()
r = r.json()
bot.say(channel,"{}: {}".format(nick,r["direct"]["masked"]))
except requests.exceptions.HTTPError:
bot.say(channel,"ACCESS VIOLATION: Cannot find meme format {}.".format(template))