epsilon.py 文件源码

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

项目:Epsilon 作者: Capuno 项目源码 文件源码
def cmd_info(message, parameters, recursion=0):
    await client.send_typing(message.channel)
    async for msg in client.logs_from(message.channel, limit=25):
        try:
            if msg.attachments:
                img = msg.attachments[0]['url']
                while not tokenAvailable:
                    asyncio.get_event_loop().create_task(tokenTimedOut())
                    await asyncio.sleep(1)
                api = OAuth2Session(aestheticsApiClientID, token=aesthToken)
                params = {'url': img, 'num_keywords': 10}
                keywords = api.get('https://api.everypixel.com/v1/keywords', params=params).json()
                quality = api.get('https://api.everypixel.com/v1/quality', params=params).json()
                if 'error' in params.keys() or 'error' in quality.keys():
                    await client.send_message(message.channel, "**Error:** API limit, you'll either have to wait like 5 mins so I get more requests or manually upload the image to https://everypixel.com/aesthetics")
                    return
                e = discord.Embed(colour=0x4DB15A)
                tags = [ tag['keyword'] for tag in keywords['keywords'] ]
                e.description = "```fix\nScore = {}% Awesome Image!```\n```md\n#{}```".format('{0:.1f}'.format(float(quality['quality']['score'])*100.0), "\n#".join(tags))
                await client.send_message(message.channel, embed=e)
                return
        except Exception as e:
            raise e
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号