]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_filter.cpp
Updated to keep lowermap const within hashcomp.cpp
[user/henk/code/inspircd.git] / src / modules / m_filter.cpp
index 91efe49c03066d9073a30b31f4ca278e09bf08b0..59a82d61012a78f78398e5f4b4a88a97bb3daa59 100644 (file)
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
+#include "helperfuncs.h"
 
 /* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */
 
-        
-
 class ModuleFilter : public Module
 {
  Server *Srv;
@@ -48,7 +47,8 @@ class ModuleFilter : public Module
                if ((filterfile == "") || (!MyConf->Verify()))
                {
                        printf("Error, could not find <filter file=\"\"> definition in your config file!");
-                       exit(0);
+                       log(DEFAULT,"Error, could not find <filter file=\"\"> definition in your config file!");
+                       return;
                }
                Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
        }
@@ -64,11 +64,11 @@ class ModuleFilter : public Module
        
        virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
        {
-               std::string text2 = text + " ";
+               std::string text2 = text+" ";
                for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
                {
                        std::string pattern = MyConf->ReadValue("keyword","pattern",index);
-                       if (Srv->MatchText(text2,pattern))
+                       if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
                        {
                                std::string target = "";
                                std::string reason = MyConf->ReadValue("keyword","reason",index);
@@ -113,11 +113,11 @@ class ModuleFilter : public Module
        
        virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
        {
-               std::string text2 = text + " ";
+               std::string text2 = text+" ";
                for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
                {
                        std::string pattern = MyConf->ReadValue("keyword","pattern",index);
-                       if (Srv->MatchText(text2,pattern))
+                       if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
                        {
                                std::string target = "";
                                std::string reason = MyConf->ReadValue("keyword","reason",index);
@@ -172,7 +172,8 @@ class ModuleFilter : public Module
                {
                        // bail if the user forgot to create a config file
                        printf("Error, could not find <filter file=\"\"> definition in your config file!");
-                       exit(0);
+                       log(DEFAULT,"Error, could not find <filter file=\"\"> definition in your config file!");
+                       return;
                }
                Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
        }
@@ -180,7 +181,7 @@ class ModuleFilter : public Module
        virtual Version GetVersion()
        {
                // This is version 2 because version 1.x is the unreleased unrealircd module
-               return Version(2,0,0,0,0);
+               return Version(2,0,0,1,VF_VENDOR);
        }
        
 };