]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_stripcolor.cpp
Improved strhashcomp with no allocations
[user/henk/code/inspircd.git] / src / modules / m_stripcolor.cpp
index 625b3fc1a0bf638daa15bbc499eaccc600e70c2a..19c69ec4b5ea39e00e492ca0df8193da3e5d2807 100644 (file)
@@ -21,6 +21,7 @@ using namespace std;
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
+#include "helperfuncs.h"
 
 /* $ModDesc: Provides channel +S mode (strip ansi colour) */
 
@@ -59,21 +60,7 @@ class ModuleStripColor : public Module
 
         virtual void On005Numeric(std::string &output)
         {
-                std::stringstream line(output);
-                std::string temp1, temp2;
-                while (!line.eof())
-                {
-                        line >> temp1;
-                        if (temp1.substr(0,10) == "CHANMODES=")
-                        {
-                                // append the chanmode to the end
-                                temp1 = temp1.substr(10,temp1.length());
-                                temp1 = "CHANMODES=" + temp1 + "S";
-                        }
-                        temp2 = temp2 + temp1 + " ";
-                }
-               if (temp2.length())
-                       output = temp2.substr(0,temp2.length()-1);
+               InsertMode(output,"S",4);
         }
        
        virtual ~ModuleStripColor()
@@ -135,7 +122,7 @@ class ModuleStripColor : public Module
                text = sentence;
        }
        
-       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
        {
                bool active = false;
                if (target_type == TYPE_USER)
@@ -155,24 +142,9 @@ class ModuleStripColor : public Module
                return 0;
        }
        
-       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
        {
-               bool active = false;
-               if (target_type == TYPE_USER)
-               {
-                       userrec* t = (userrec*)dest;
-                       active = (strchr(t->modes,'S') > 0);
-               }
-               else if (target_type == TYPE_CHANNEL)
-               {
-                       chanrec* t = (chanrec*)dest;
-                       active = (t->IsCustomModeSet('S'));
-               }
-               if (active)
-               {
-                       this->ReplaceLine(text);
-               }
-               return 0;
+               return OnUserPreMessage(user,dest,target_type,text,status);
        }
        
        virtual Version GetVersion()