Load whitelist in start.py, pass to ModuleManager.load_modules

This commit is contained in:
jesopo 2018-08-30 11:41:02 +01:00
parent 568d714fb2
commit 01a5032e87
2 changed files with 8 additions and 6 deletions

View file

@ -15,9 +15,6 @@ class ModuleManager(object):
def _load_module(self, filename):
name = self.module_name(filename)
whitelist = self.bot.config.get("module_whitelist", [])
if whitelist and name not in whitelist: return
with open(filename) as module_file:
while True:
line = module_file.readline().strip()
@ -73,8 +70,9 @@ class ModuleManager(object):
else:
sys.stderr.write("module '%s' not loaded.\n" % filename)
def load_modules(self):
def load_modules(self, whitelist=None):
for filename in self.list_modules():
if whitelist == None or filename in whitelist:
self.load_module(filename)
def unload_module(self, module):

View file

@ -24,7 +24,11 @@ config = Config.Config(bot, args.config)
bot.database = database
bot.config = config.load_config()
bot.args = args
bot.modules.load_modules()
whitelist = bot.config.get("module_whitelist", None)
if not whitelist == None:
whitelist = whitelist.split(",")
bot.modules.load_modules(whitelist=whitelist)
server_details = database.servers.get_all()
servers = []