HearthstoneCog.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Inkxbot 作者: InkxtheSquid 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号