From 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 01:55:04 -0400 Subject: Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in. --- modules/extra/m_sql_authentication.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'modules/extra/m_sql_authentication.cpp') diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 027b0bbcc..98fd4c2e9 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -2,6 +2,7 @@ #include "sql.h" static Module *me; +static ServiceReference nickserv("NickServService", "NickServ"); class SQLAuthenticationResult : public SQL::Interface { @@ -41,14 +42,9 @@ class SQLAuthenticationResult : public SQL::Interface if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); - if (user) - { - if (Config->NSAddAccessOnReg) - na->nc->AddAccess(user->Mask()); - - if (NickServ) - user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); - } + FOREACH_MOD(I_OnNickRegister, OnNickRegister(user, na)); + if (user && nickserv) + user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } if (!email.empty() && email != na->nc->email) @@ -80,18 +76,18 @@ class ModuleSQLAuthentication : public Module public: ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - me = this; Implementation i[] = { I_OnReload, I_OnPreCommand, I_OnCheckAuthentication }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - this->engine = reader.ReadValue("m_sql_authentication", "engine", "", 0); - this->query = reader.ReadValue("m_sql_authentication", "query", "", 0); - this->disable_reason = reader.ReadValue("m_sql_authentication", "disable_reason", "", 0); + Configuration::Block *config = conf->GetModule(this); + this->engine = config->Get("engine"); + this->query = config->Get("query"); + this->disable_reason = config->Get("disable_reason"); this->SQL = ServiceReference("SQL::Provider", this->engine); } -- cgit