konachan.py 文件源码

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

项目:apex-sigma-plugins 作者: lu-ci 项目源码 文件源码
def konachan(cmd, message, args):
    url_base = 'https://konachan.com/post.json?limit=100&tags='
    if not args:
        tags = 'nude'
    else:
        tags = '+'.join(args)
    url = url_base + tags
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as data:
            data = await data.read()
            data = json.loads(data)
    if len(data) == 0:
        embed = discord.Embed(color=0x696969, title='?? No results.')
    else:
        post = secrets.choice(data)
        image_url = f'https:{post["file_url"]}'
        post_url = f'http://konachan.com/post/show/{post["id"]}'
        icon_url = 'https://i.imgur.com/qc4awFL.png'
        embed = discord.Embed(color=0x473a47)
        embed.set_author(name='Konachan', url=post_url, icon_url=icon_url)
        embed.set_image(url=image_url)
        embed.set_footer(
            text=f'Score: {post["score"]} | Size: {post["width"]}x{post["height"]} | Uploaded By: {post["author"]}')
    await message.channel.send(None, embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号