memes.py 文件源码

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

项目:dogbot 作者: slice 项目源码 文件源码
def orly(self, ctx, title, guide, author, *, top_text=''):
        """Generates O'Reilly book covers."""

        api_base = 'https://orly-appstore.herokuapp.com/generate?'

        url = (api_base +
               f'title={urlescape(title)}&top_text={urlescape(top_text)}&image_code={randrange(0, 41)}' +
               f'&theme={randrange(0, 17)}&author={urlescape(author)}&guide_text={urlescape(guide)}' +
               f'&guide_text_placement=bottom_right')

        try:
            async with ctx.typing():
                async with ctx.bot.session.get(url) as resp:
                    with BytesIO(await resp.read()) as bio:
                        await ctx.send(file=discord.File(filename='orly.png', fp=bio))
        except aiohttp.ClientError:
            await ctx.send("Couldn't contact the API.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号