summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-20 01:42:29 +0000
committeraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-20 01:42:29 +0000
commit5a5d59a7916cf40d71e6a312352867a489ff2a52 (patch)
treedb40b207c26c0dd14a8a2a8c5c3e2d43ef4a7ff2
parent586c3cae3d4aeaf87c01538436ea9c84788cc23f (diff)
Update m_filter* to 1.2 API (it was still using Implements()), also implement <exemptfromfilter channel="#blah"> to exclude channels from filtering.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8742 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_filter_pcre.cpp5
-rw-r--r--src/modules/m_filter.cpp1
-rw-r--r--src/modules/m_filter.h26
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 &parameter)
{
+ 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);