diff options
| author | 2018-08-30 11:41:02 +0100 | |
|---|---|---|
| committer | 2018-08-30 11:41:02 +0100 | |
| commit | 01a5032e8701193557e908b2b3d2cf4258557e5d (patch) | |
| tree | 0077ae75300a74a3d240c178a4bd1ffd79981c89 | |
| parent | Return config from Config.load_config instead of setting it on bot (diff) | |
| signature | ||
Load whitelist in start.py, pass to ModuleManager.load_modules
| -rw-r--r-- | ModuleManager.py | 8 | ||||
| -rwxr-xr-x | start.py | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/ModuleManager.py b/ModuleManager.py index 2354a799..e601ce9e 100644 --- a/ModuleManager.py +++ b/ModuleManager.py @@ -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,9 +70,10 @@ 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(): - self.load_module(filename) + if whitelist == None or filename in whitelist: + self.load_module(filename) def unload_module(self, module): # this is such a bad idea @@ -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 = [] |
