Added and imgur command, almost a direct port from the not so modular branch.

Command is to be expanded, this is a test.
This commit is contained in:
Emil Hammarstrom 2016-02-07 22:55:43 +01:00
parent 6527e026ae
commit b8d236d5a3

View File

@ -6,6 +6,7 @@ import datetime
import time
import aiohttp
import asyncio
from imgurpython import ImgurClient
settings = {"POLL_DURATION" : 60}
@ -174,6 +175,24 @@ class General:
except:
await self.bot.say("Error.")
@commands.command(no_pm=True)
async def imgur(self, *text):
"""Retrieves a random imgur picture.
If a link combination e.g. As3DsA4 is provided it will try to retrieve that image."""
imgurclient = ImgurClient("", "")
if text == ():
rand = randint(0, 59) #60 results per generated page
items = imgurclient.gallery_random(page=0)
await self.bot.say(items[rand].link)
elif text == "viral top":
items = imgurclient.gallery(section='hot', sort='viral', page=0, window='day', show_viral=True)
await self.bot.say(items[0].link)
await self.bot.say(items[1].link)
await self.bot.say(items[2].link)
else:
item = imgurclient.get_image(text)
await self.bot.say(item.link)
@commands.command(pass_context=True, no_pm=True)
async def poll(self, ctx, *text):
"""Starts/stops a poll