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