def hearthwiki(self, title, ctx):
"""Returns a hearthstone wiki page: ,hearthwiki 'card name'"""
url = 'http://hearthstone.wikia.com/wiki/' + urlquote(title)
typetochan = ctx.message.channel
async with aiohttp.get(url) as resp:
if resp.status == 404:
await self.bot.send_typing(typetochan)
await asyncio.sleep(1)
await self.bot.say('Could not find your page. Try a search:\n{0.url}'.format(resp))
elif resp.status == 200:
await self.bot.send_typing(typetochan)
await asyncio.sleep(1)
await self.bot.say(resp.url)
elif resp.status == 502:
await self.bot.send_typing(typetochan)
await asyncio.sleep(1)
await self.bot.say('Seems like the Hearthstone Wiki is taking too long to respond. Try again later.')
else:
await self.bot.send_typing(typetochan)
await self.bot.say('An error has occurred of status code {0.status} happened. Tell Inkx.'.format(resp))
评论列表
文章目录