diff options
author | Cara Salter <cara@devcara.com> | 2023-03-30 15:58:57 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-03-30 15:58:57 -0400 |
commit | e63f88aa3f8fe1c0cf8366ee09188a4b18ede166 (patch) | |
tree | a5184887a2ad23623bd1cf1c9d545bd9bf3aac4b /src | |
parent | 8233fc4bcffc82907e82b31072cb8129aa200ae5 (diff) | |
download | 142bot-e63f88aa3f8fe1c0cf8366ee09188a4b18ede166.tar.gz 142bot-e63f88aa3f8fe1c0cf8366ee09188a4b18ede166.zip |
Finish reactions module
Diffstat (limited to 'src')
-rw-r--r-- | src/bot.cpp | 5 | ||||
-rw-r--r-- | src/modules.cpp | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/bot.cpp b/src/bot.cpp index 57bf091..03bea02 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -12,10 +12,7 @@ Bot::Bot(bool devel, dpp::cluster* cluster) { dev = devel; this->core = cluster; this->loader = new ModuleLoader(this); - if (!this->loader->load("module_mmanager.so")) { - this->core->log(dpp::ll_error, "Couldn't load modulemanager"); - exit(-1); - } + this->loader->load_all(); // this->loader->LoadAll(); } diff --git a/src/modules.cpp b/src/modules.cpp index 6a8d500..b2e56e1 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -182,6 +182,22 @@ bool ModuleLoader::reload(const std::string &filename) return (unload(filename) && load(filename)); } + +/** + * Load all modules from the config file modules.json + */ +void ModuleLoader::load_all() +{ + json document; + std::ifstream configfile("./config.json"); + configfile >> document; + json modlist = document["modules"]; + for (auto entry = modlist.begin(); entry != modlist.end(); ++entry) { + std::string modulename = entry->get<std::string>(); + this->load(modulename); + } +} + /** * Return a given symbol name from a shared object represented by the ModuleNative value. */ |