diff --git a/plugins/authy.py b/default_plugins/authy.py similarity index 100% rename from plugins/authy.py rename to default_plugins/authy.py diff --git a/plugins/hotload.py b/default_plugins/hotload.py similarity index 100% rename from plugins/hotload.py rename to default_plugins/hotload.py diff --git a/main.py b/main.py index 0545c39..1d27b3b 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,9 @@ from client import client -olive = client() +from sys import argv, exit + +olive = None +if len(argv) < 2: + olive = client() # is this clean? who knows! +else: + olive = client(config_path = argv[1]) olive.run() \ No newline at end of file diff --git a/plugin_manager.py b/plugin_manager.py index 730f2b8..0fd2163 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -3,21 +3,25 @@ import sys class plugin_manager(): def __init__(self, logger, plugin_path = "./plugins"): - sys.path.append(plugin_path) # needed to __import__ scripts without a hassle, shouldn't cause an issue - plugins = [name.split(".py")[0] for name in os.listdir(plugin_path) if name.endswith(".py")] + self.logger = logger self.plugins_loaded = [] + self.load_folder("./default_plugins") + self.load_folder(plugin_path) + def load_folder(self, path): + sys.path.append(path) # needed to __import__ scripts without a hassle, shouldn't cause an issue + plugins = [name.split(".py")[0] for name in os.listdir(path) if name.endswith(".py")] for plugin in plugins: try: module = __import__(plugin) except: - logger.write(f"error loading plugin {plugin}") + self.logger.write(f"error loading plugin {plugin}") continue if not(hasattr(module, "run")) or not(hasattr(module, "hooks")): - logger.write(f"plugin {plugin} is invalid: crucial attribute missing!") + self.logger.write(f"plugin {plugin} is invalid: crucial attribute missing!") continue else: self.plugins_loaded.append(module) - logger.write(f"loaded plugin {module.__name__}") # this name will be used for hotloading + self.logger.write(f"loaded plugin {module.__name__}") # this name will be used for hotloading def handle(self, event, ctx, bot): for plugin in self.plugins_loaded: if event in plugin.hooks: