diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-28 22:28:13 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-28 22:28:13 +0000 |
commit | ccbf152ca4a40eadd577234011de329bf5aa292a (patch) | |
tree | f10b836c175104be00f43d97dea17852cbfce8f3 | |
parent | 5183b9b8207a26b6196b7da0a1d092bb1f6e8429 (diff) |
Next bit of filter flags system
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7179 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.h | 26 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index bafb40070..7faa4a40b 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -57,7 +57,7 @@ class ModuleFilterPCRE : public FilterBase { } - virtual FilterResult* FilterMatch(const std::string &text) + virtual FilterResult* FilterMatch(const std::string &text, int flags) { for (std::vector<PCREFilter>::iterator index = filters.begin(); index != filters.end(); index++) { diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 5d0e2ec1d..bcbf3d2bf 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -38,7 +38,7 @@ class ModuleFilter : public FilterBase { } - virtual FilterResult* FilterMatch(const std::string &text) + virtual FilterResult* FilterMatch(const std::string &text, int flags) { for (filter_t::iterator index = filters.begin(); index != filters.end(); index++) { diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index f8c688d70..4fc7cfff4 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -13,6 +13,15 @@ #include "xline.h" +enum FilterFlags +{ + FLAG_NOOPERS, + FLAG_PART, + FLAG_QUIT, + FLAG_PRIVMSG, + FLAG_NOTICE +}; + class FilterResult : public classbase { public: @@ -84,12 +93,13 @@ class cmd_filter; class FilterBase : public Module { cmd_filter* filtcommand; + int flags; public: FilterBase(InspIRCd* Me, const std::string &source); virtual ~FilterBase(); virtual void Implements(char* List); virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); - virtual FilterResult* FilterMatch(const std::string &text) = 0; + virtual FilterResult* FilterMatch(const std::string &text, int flags) = 0; virtual bool DeleteFilter(const std::string &freeform) = 0; virtual void SyncFilters(Module* proto, void* opaque) = 0; virtual void SendFilter(Module* proto, void* opaque, FilterResult* iter); @@ -212,16 +222,20 @@ void FilterBase::Implements(char* List) int FilterBase::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { + flags = FLAG_PRIVMSG; return OnUserPreNotice(user,dest,target_type,text,status,exempt_list); } int FilterBase::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { + if (!flags) + flags = FLAG_NOTICE; + /* Leave ulines alone */ if ((ServerInstance->ULine(user->server)) || (!IS_LOCAL(user))) return 0; - FilterResult* f = this->FilterMatch(text); + FilterResult* f = this->FilterMatch(text, flags); if (f) { std::string target = ""; @@ -265,6 +279,7 @@ int FilterBase::OnUserPreNotice(userrec* user,void* dest,int target_type, std::s int FilterBase::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { + flags = 0; if ((validated == 1) && (IS_LOCAL(user))) { std::string checkline; @@ -280,6 +295,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters checkline = parameters[0]; replacepoint = 0; parting = false; + flags |= FLAG_QUIT; } else if (command == "PART") { @@ -290,12 +306,16 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters checkline = parameters[1]; replacepoint = 1; parting = true; + flags |= FLAG_PART; } else /* We're only messing with PART and QUIT */ return 0; - FilterResult* f = this->FilterMatch(checkline); + FilterResult* f = NULL; + + if (flags) + f = this->FilterMatch(checkline, flags); if (!f) /* PART or QUIT reason doesnt match a filter */ |