diff --git a/Bot/IRC_Bot.cpp b/Bot/IRC_Bot.cpp index bbbda91..05695be 100644 --- a/Bot/IRC_Bot.cpp +++ b/Bot/IRC_Bot.cpp @@ -173,12 +173,6 @@ void IRC_Bot::setCommandAccessLevels() set_command_access_levels(section->getName() + "Commands"_jrs); } -int IRC_Bot::OnRehash() -{ - IRC_Bot::setCommandAccessLevels(); - return 0; -} - void IRC_Bot::OnChat(const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &message) { int chanIndex = this->getChannelIndex(channel); diff --git a/Bot/IRC_Bot.h b/Bot/IRC_Bot.h index 2850103..1842a7f 100644 --- a/Bot/IRC_Bot.h +++ b/Bot/IRC_Bot.h @@ -42,7 +42,7 @@ class IRCCommand; /** * @brief Provies extendable bot-like interfacing with the IRC client. */ -class JUPITER_BOT_API IRC_Bot : public Jupiter::IRC::Client, public Jupiter::Rehashable +class JUPITER_BOT_API IRC_Bot : public Jupiter::IRC::Client { public: diff --git a/Bot/Main.cpp b/Bot/Main.cpp index 1a0778d..725538a 100644 --- a/Bot/Main.cpp +++ b/Bot/Main.cpp @@ -87,6 +87,13 @@ void inputLoop() } } +int rehash_config() +{ + o_config.reload(); + serverManager->OnConfigRehash(); + return 0; +} + int main(int argc, const char **args) { atexit(onExit); @@ -124,6 +131,8 @@ int main(int argc, const char **args) exit(0); } + Jupiter::addOnRehash(rehash_config); + puts("Config loaded."); if (plugins_directory.isEmpty()) diff --git a/Bot/ServerManager.cpp b/Bot/ServerManager.cpp index 34105f1..1db4775 100644 --- a/Bot/ServerManager.cpp +++ b/Bot/ServerManager.cpp @@ -68,6 +68,19 @@ size_t ServerManager::removeCommand(const Jupiter::ReadableString &command) return r; } +void ServerManager::OnConfigRehash() +{ + IRC_Bot *server; + for (size_t index = 0; index != ServerManager::servers.size(); ++index) + { + server = ServerManager::servers.get(index); + + server->setPrimaryConfigSection(g_config->getSection(server->getConfigSection())); + server->setSecondaryConfigSection(g_config->getSection("Defualt"_jrs)); + server->setCommandAccessLevels(); + } +} + size_t ServerManager::syncCommands() { for (size_t i = 0; i != ServerManager::servers.size(); i++) diff --git a/Bot/ServerManager.h b/Bot/ServerManager.h index 5b2b6f9..feb63fc 100644 --- a/Bot/ServerManager.h +++ b/Bot/ServerManager.h @@ -76,6 +76,11 @@ public: */ size_t removeCommand(const Jupiter::ReadableString &command); + /** + * @brief Called when g_config is rehashed + */ + void OnConfigRehash(); + /** * @brief Syncs command access levels from the configuration file. * diff --git a/Release/Bot.lib b/Release/Bot.lib index 7fdf946..1e11571 100644 Binary files a/Release/Bot.lib and b/Release/Bot.lib differ diff --git a/Release/Plugins/RenX.Core.lib b/Release/Plugins/RenX.Core.lib index cae83ca..d5fb12c 100644 Binary files a/Release/Plugins/RenX.Core.lib and b/Release/Plugins/RenX.Core.lib differ