1
0
Fork 0
mirror of synced 2024-05-17 19:12:33 +12:00

Change how Horses and Snakes are accessed (#25)

* Update Animal Image Fetch 1/4

* Animal Image Fetch 2/4

* Requested changes for Animal Image Fetch 3/4
This commit is contained in:
MahxieNoodle 2019-11-04 20:56:41 -07:00 committed by Dan Hess
parent b963fad7be
commit edb0f8ac2c

View file

@ -54,17 +54,19 @@ class Images(commands.Cog):
EXAMPLE: !snek EXAMPLE: !snek
RESULT: A beautiful picture of a snek o3o""" RESULT: A beautiful picture of a snek o3o"""
result = await utils.request("http://hrsendl.com/snake") data = await utils.request("http://hrsendl.com/api/snake")
if result is None:
if data is None:
await ctx.send("I couldn't connect! Sorry no snakes right now ;w;") await ctx.send("I couldn't connect! Sorry no snakes right now ;w;")
return return
filename = result.get('image', None) result = data['data']
filename = result.get('file_url_size_large', None)
if filename is None: if filename is None:
await ctx.send("I couldn't connect! Sorry no snakes right now ;w;") await ctx.send("I couldn't connect! Sorry no snakes right now ;w;")
return return
image = await utils.download_image(filename) image = await utils.download_image(filename)
filename = re.search('.*/snakes/(.*)', filename).group(1) filename = re.search('.*/optimized/large/(.*)', filename).group(1)
f = discord.File(image, filename=filename) f = discord.File(image, filename=filename)
await ctx.send(file=f) await ctx.send(file=f)
@ -75,17 +77,19 @@ class Images(commands.Cog):
EXAMPLE: !horse EXAMPLE: !horse
RESULT: A beautiful picture of a horse o3o""" RESULT: A beautiful picture of a horse o3o"""
result = await utils.request("http://hrsendl.com/horse") data = await utils.request("http://hrsendl.com/api/horse")
if result is None:
if data is None:
await ctx.send("I couldn't connect! Sorry no horses right now ;w;") await ctx.send("I couldn't connect! Sorry no horses right now ;w;")
return return
filename = result.get('image', None) result = data['data']
filename = result.get('file_url_size_large', None)
if filename is None: if filename is None:
await ctx.send("I couldn't connect! Sorry no horses right now ;w;") await ctx.send("I couldn't connect! Sorry no horses right now ;w;")
return return
image = await utils.download_image(filename) image = await utils.download_image(filename)
filename = re.search('.*/horses/(.*)', filename).group(1) filename = re.search('.*/optimized/large/(.*)', filename).group(1)
f = discord.File(image, filename=filename) f = discord.File(image, filename=filename)
await ctx.send(file=f) await ctx.send(file=f)