commands.py 文件源码

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

项目:BuffBot 作者: Cmoen11 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号