From 5d474dc9fbd9bd36d0a0a8df93e1ec1e180864d7 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 17 Jan 2010 17:10:45 +0000 Subject: Move initialization that throws configuration exceptions to init() git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12279 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_banredirect.cpp | 4 ++++ src/modules/m_callerid.cpp | 12 +++++++----- src/modules/m_cloaking.cpp | 4 ++++ src/modules/m_filter.cpp | 6 +++++- src/modules/m_helpop.cpp | 11 +++++++---- src/modules/m_ojoin.cpp | 13 ++++++------- src/modules/m_rline.cpp | 4 ++++ 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 1ab3c3243..afa7e4225 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -210,7 +210,11 @@ class ModuleBanRedirect : public Module : re(this) { nofollow = false; + } + + void init() + { if(!ServerInstance->Modes->AddModeWatcher(&re)) throw ModuleException("Could not add mode watcher"); diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 86d488cd8..bb847d8bc 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -344,13 +344,15 @@ private: public: ModuleCallerID() : cmd(this), myumode(this) { - OnRehash(NULL); + } - if (!ServerInstance->Modes->AddMode(&myumode)) - throw ModuleException("Could not add usermode +g"); + void init() + { + OnRehash(NULL); - ServerInstance->AddCommand(&cmd); - ServerInstance->Extensions.Register(&cmd.extInfo); + ServerInstance->Modules->AddService(myumode); + ServerInstance->Modules->AddService(cmd); + ServerInstance->Modules->AddService(cmd.extInfo); Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage }; ServerInstance->Modules->Attach(eventlist, this, 6); diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 22114c54e..1b30f410a 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -120,6 +120,10 @@ class ModuleCloaking : public Module public: ModuleCloaking() : cu(this), Hash(this, "hash/md5") + { + } + + void init() { OnRehash(NULL); diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 713643043..35aca6262 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -139,7 +139,7 @@ class ModuleFilter : public Module std::vector exemptfromfilter; // List of channel names excluded from filtering. ModuleFilter(); - + void init(); ~ModuleFilter(); ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); FilterResult* FilterMatch(User* user, const std::string &text, int flags); @@ -254,6 +254,10 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags) } ModuleFilter::ModuleFilter() : filtcommand(this), RegexEngine(this, "regex") +{ +} + +void ModuleFilter::init() { ServerInstance->AddCommand(&filtcommand); Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncNetwork, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash }; diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index cbb56c3f9..5cd8d8ea0 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -118,16 +118,19 @@ class ModuleHelpop : public Module public: ModuleHelpop() : cmd(this), ho(this) + { + } + + void init() { ReadConfig(); - if (!ServerInstance->Modes->AddMode(&ho)) - throw ModuleException("Could not add new modes!"); - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(ho); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnRehash, I_OnWhois }; ServerInstance->Modules->Attach(eventlist, this, 2); } - virtual void ReadConfig() + void ReadConfig() { ConfigReader MyConf; diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index cacc206d6..176a0e613 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -211,6 +211,10 @@ class ModuleOjoin : public Module ModuleOjoin() : np(NULL), mycommand(this) + { + } + + void init() { /* Load config stuff */ OnRehash(NULL); @@ -218,13 +222,8 @@ class ModuleOjoin : public Module /* Initialise module variables */ np = new NetworkPrefix(this); - if (!ServerInstance->Modes->AddMode(np)) - { - delete np; - throw ModuleException("Could not add new mode!"); - } - - ServerInstance->AddCommand(&mycommand); + ServerInstance->Modules->AddService(*np); + ServerInstance->Modules->AddService(mycommand); Implementation eventlist[] = { I_OnUserPreJoin, I_OnUserPreKick, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 3); diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index d52870284..0df36eb37 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -204,6 +204,10 @@ class ModuleRLine : public Module public: ModuleRLine() : rxfactory(this, "regex"), f(rxfactory), r(this, f) + { + } + + void init() { OnRehash(NULL); -- cgit v1.2.3