def add_smug(self, ctx, path):
allowed_content = {'image/jpeg': 'jpg', 'image/png': 'png', 'image/gif': 'gif'}
if not global_methods.is_admin(ctx.message.author):
await self.bot.say("You're not a big boy")
async with aiohttp.get(path) as r:
if r.status == 200:
file = await r.content.read()
type = r.headers['Content-Type']
if type not in allowed_content:
await self.bot.say("That kind of file is not allowed")
return
else:
hash = hashlib.md5(file).hexdigest()
filename = "smug-anime-faces/{}.{}".format(hash, allowed_content[type])
with open(filename, 'wb') as f:
f.write(file)
await self.bot.say("Smugness levels increased")
评论列表
文章目录