useful.py 文件源码

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

项目:PTSCogs 作者: PlanetTeamSpeakk 项目源码 文件源码
def qrcode(self, ctx, url):
        """Creates a qrcode from a link."""
        shorten = Shortener('Bitly', bitly_token='dd800abec74d5b12906b754c630cdf1451aea9e0')
        short_link = shorten.short(url)
        async with aiohttp.get(shorten.qrcode(width=128, height=128)) as r:
            file = await r.content.read()
        number = random.randint(1000, 9999)
        fileloc = "data/useful/qrcode{}.png".format(number)
        with open(fileloc, 'wb') as f:
            f.write(file)
            file = None
            f = None
        await self.bot.send_file(ctx.message.channel, fp="data/useful/qrcode{}.png".format(number), filename="qrcode{}.png".format(number))
        os.remove("data/useful/qrcode{}.png".format(number))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号