Browse Source

g_config now gets rehashed

IRC_Bot no longer gets rehashed directly (instead, their access levels and config secitons are reset by ServerManager)
pull/3/head
Jessica James 8 years ago
parent
commit
7d9c96bfff
  1. 6
      Bot/IRC_Bot.cpp
  2. 2
      Bot/IRC_Bot.h
  3. 9
      Bot/Main.cpp
  4. 13
      Bot/ServerManager.cpp
  5. 5
      Bot/ServerManager.h
  6. BIN
      Release/Bot.lib
  7. BIN
      Release/Plugins/RenX.Core.lib

6
Bot/IRC_Bot.cpp

@ -173,12 +173,6 @@ void IRC_Bot::setCommandAccessLevels()
set_command_access_levels(section->getName() + "Commands"_jrs); 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) void IRC_Bot::OnChat(const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &message)
{ {
int chanIndex = this->getChannelIndex(channel); int chanIndex = this->getChannelIndex(channel);

2
Bot/IRC_Bot.h

@ -42,7 +42,7 @@ class IRCCommand;
/** /**
* @brief Provies extendable bot-like interfacing with the IRC client. * @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: public:

9
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) int main(int argc, const char **args)
{ {
atexit(onExit); atexit(onExit);
@ -124,6 +131,8 @@ int main(int argc, const char **args)
exit(0); exit(0);
} }
Jupiter::addOnRehash(rehash_config);
puts("Config loaded."); puts("Config loaded.");
if (plugins_directory.isEmpty()) if (plugins_directory.isEmpty())

13
Bot/ServerManager.cpp

@ -68,6 +68,19 @@ size_t ServerManager::removeCommand(const Jupiter::ReadableString &command)
return r; 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() size_t ServerManager::syncCommands()
{ {
for (size_t i = 0; i != ServerManager::servers.size(); i++) for (size_t i = 0; i != ServerManager::servers.size(); i++)

5
Bot/ServerManager.h

@ -76,6 +76,11 @@ public:
*/ */
size_t removeCommand(const Jupiter::ReadableString &command); 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. * @brief Syncs command access levels from the configuration file.
* *

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.
Loading…
Cancel
Save