diff options
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_filter.h | 26 |
3 files changed, 25 insertions, 7 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index 4f52c8a86..64bb949bc 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -163,6 +163,7 @@ class ModuleFilterPCRE : public FilterBase ServerInstance->Log(DEFAULT,"Regular expression %s loaded.", pattern.c_str()); } } + FilterBase::OnRehash(user, parameter); } virtual int OnStats(char symbol, User* user, string_list &results) @@ -174,6 +175,10 @@ class ModuleFilterPCRE : public FilterBase { results.push_back(sn+" 223 "+user->nick+" :REGEXP:"+i->freeform+" "+i->flags+" "+i->action+" "+ConvToStr(i->gline_time)+" :"+i->reason); } + for (std::vector<std::string>::iterator i = exemptfromfilter.begin(); i != exemptfromfilter.end(); ++i) + { + results.push_back(sn+" 223 "+user->nick+" :EXEMPT "+(*i)); + } } return 0; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 1da41bf0d..32b80d283 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -113,6 +113,7 @@ class ModuleFilter : public FilterBase filters[pattern] = x; } delete MyConf; + FilterBase::OnRehash(user, parameter); } virtual int OnStats(char symbol, User* user, string_list &results) diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index aa866ee82..c4d2e71ef 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -94,10 +94,11 @@ class FilterBase : public Module { CommandFilter* filtcommand; int flags; +protected: + std::vector<std::string> exemptfromfilter; // List of channel names excluded from filtering. public: FilterBase(InspIRCd* Me, const std::string &source); virtual ~FilterBase(); - virtual void Implements(char* List); virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); virtual FilterResult* FilterMatch(User* user, const std::string &text, int flags) = 0; virtual bool DeleteFilter(const std::string &freeform) = 0; @@ -225,17 +226,14 @@ FilterBase::FilterBase(InspIRCd* Me, const std::string &source) : Module(Me) { filtcommand = new CommandFilter(this, Me, source); ServerInstance->AddCommand(filtcommand); + Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncOtherMetaData, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 7); } FilterBase::~FilterBase() { } -void FilterBase::Implements(char* List) -{ - List[I_OnPreCommand] = List[I_OnStats] = List[I_OnSyncOtherMetaData] = List[I_OnDecodeMetaData] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1; -} - int FilterBase::OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { flags = FLAG_PRIVMSG; @@ -264,6 +262,8 @@ int FilterBase::OnUserPreNotice(User* user,void* dest,int target_type, std::stri { Channel* t = (Channel*)dest; target = std::string(t->name); + std::vector<std::string>::iterator i = find(exemptfromfilter.begin(), exemptfromfilter.end(), target); + if (i != exemptfromfilter.end()) return 0; } if (f->action == "block") { @@ -321,6 +321,8 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters if (pcnt < 2) return 0; + std::vector<std::string>::iterator i = find(exemptfromfilter.begin(), exemptfromfilter.end(), parameters[0]); + if (i != exemptfromfilter.end()) return 0; checkline = parameters[1]; replacepoint = 1; parting = true; @@ -385,8 +387,18 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters void FilterBase::OnRehash(User* user, const std::string ¶meter) { + ConfigReader* MyConf = new ConfigReader(ServerInstance); + vector<std::string>().swap(exemptfromfilter); + for (int index = 0; index < MyConf->Enumerate("exemptfromfilter"); ++index) + { + std::string chan = MyConf->ReadValue("exemptfromfilter", "channel", index); + if (!chan.empty()) { + exemptfromfilter.push_back(chan); + } + } + delete MyConf; } - + Version FilterBase::GetVersion() { return Version(1,1,0,2,VF_VENDOR|VF_COMMON,API_VERSION); |