cat.py 文件源码

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

项目:apex-sigma-core 作者: lu-ci 项目源码 文件源码
def cat(cmd, message, args):
    if 'api_key' in cmd.cfg:
        cat_api_key = cmd.cfg['api_key']
        api_url = f'http://thecatapi.com/api/images/get?format=xml&results_per_page=100&api_key={cat_api_key}'
    else:
        api_url = f'http://thecatapi.com/api/images/get?format=xml&results_per_page=100'
    async with aiohttp.ClientSession() as session:
        async with session.get(api_url) as raw_page:
            results = html.fromstring(await raw_page.text())[0][0]
    choice = secrets.choice(results)
    image_url = str(choice[0].text)
    embed = discord.Embed(color=0xFFDC5D, title='?? Meow~')
    embed.set_image(url=image_url)
    await message.channel.send(None, embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号