summaryrefslogtreecommitdiff
path: root/modules/pseudoclients/hostserv.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
committerAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
commit1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch)
tree4486f0784bdf050fd7eb225c0cb9df352ce1f45a /modules/pseudoclients/hostserv.cpp
parent781defb7076ddfddf723ca08cd0a518b6657b64f (diff)
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'modules/pseudoclients/hostserv.cpp')
-rw-r--r--modules/pseudoclients/hostserv.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index d8cd74d69..acca6f7ff 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -22,11 +22,7 @@ class HostServCore : public Module
if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
- HostServ = BotInfo::Find(Config->HostServ);
- if (!HostServ)
- throw ModuleException("No bot named " + Config->HostServ);
-
- Implementation i[] = { I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
+ Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
@@ -35,6 +31,20 @@ class HostServCore : public Module
HostServ = NULL;
}
+ void OnReload(Configuration::Conf *conf) anope_override
+ {
+ const Anope::string &hsnick = conf->GetModule(this)->Get<const Anope::string &>("client");
+
+ if (hsnick.empty())
+ throw ConfigException(this->name + ": <client> must be defined");
+
+ BotInfo *bi = BotInfo::Find(hsnick, true);
+ if (!bi)
+ throw ConfigException(this->name + ": no bot named " + hsnick);
+
+ HostServ = bi;
+ }
+
void OnBotDelete(BotInfo *bi) anope_override
{
if (bi == HostServ)
@@ -76,9 +86,9 @@ class HostServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service->nick != Config->HostServ)
+ if (!params.empty() || source.c || source.service != HostServ)
return EVENT_CONTINUE;
- source.Reply(_("%s commands:"), Config->HostServ.c_str());
+ source.Reply(_("%s commands:"), HostServ->nick.c_str());
return EVENT_CONTINUE;
}
};