From a6c6d7ec4a75d2d954b7c7174a3ee3a07c0563a7 Mon Sep 17 00:00:00 2001 From: "Charles P." Date: Tue, 19 Mar 2024 10:33:11 +0100 Subject: [PATCH] :technologist: feat: allow builtins to define configurations --- allay/core/src/bot_config.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/allay/core/src/bot_config.py b/allay/core/src/bot_config.py index 7a99689c..a7998ff3 100644 --- a/allay/core/src/bot_config.py +++ b/allay/core/src/bot_config.py @@ -42,6 +42,7 @@ def load(setup_if_missing: bool = False): "Check basic requirements and start the setup script if something is missing" plugin_path = "allay/plugins" + builtins_path = "allay/builtins" config_file_exist = os.path.isfile("config.yaml") # Load config template @@ -50,10 +51,16 @@ def load(setup_if_missing: bool = False): # Load plugin config template for plugin in os.listdir(plugin_path): - if os.path.isfile(file := plugin_path + plugin + "/config.yaml"): + if os.path.isfile(file := plugin_path + "/" + plugin + "/config.yaml"): with open(file, encoding='utf-8') as file: BotConfig.__global_config.update({"plugins":{plugin: yaml.safe_load(file)}}) + # Load builtins config template + for builtin in os.listdir(builtins_path): + if os.path.isfile(file := builtins_path + "/" + builtin + "/config.yaml"): + with open(file, encoding='utf-8') as file: + BotConfig.__global_config.update({"builtins":{builtin: yaml.safe_load(file)}}) + # If a config already exist -> overwrite the templates if config_file_exist: with open("config.yaml", "r", encoding='utf-8') as file: