plugin.py 文件源码

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

项目:apex-sigma 作者: lu-ci 项目源码 文件源码
def load_info(self, bot):
        with open(os.path.join(self.path, 'plugin.yml')) as yml_file:
            yml = yaml.safe_load(yml_file)

            if 'enabled' not in yml or not yml['enabled']:
                raise PluginNotEnabled

            path = self.path.split('/')
            name = path.pop()

            # use the directory as plugin name if it is not set
            if 'name' not in yml:
                yml['name'] = name

            self.name = yml['name']

            self.log = create_logger(self.name)
            self.log.info('Loading plugin {:s}'.format(self.name))

            # set categories from rest of pathname
            if 'categories' not in yml:
                it = iter(path)
                cat = [dropwhile(lambda x: x != 'plugins', it)][1:]
                yml['categories'] = cat

            self.categories = yml['categories']

            if 'commands' in yml:
                self.commands_info = yml['commands']

            if 'events' in yml:
                self.events_info = yml['events']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号