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))
评论列表
文章目录