]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_stripcolor.cpp
Review and optimize
[user/henk/code/inspircd.git] / src / modules / m_stripcolor.cpp
index ec7a57720b8871638f0f0bc16697b4209eab1b82..136f33d85514aca3fd0b5707ca15cefffdbb9b3c 100644 (file)
@@ -14,6 +14,8 @@
  * ---------------------------------------------------
  */
 
+using namespace std;
+
 #include <stdio.h>
 #include <string>
 #include "users.h"
@@ -28,9 +30,10 @@ class ModuleStripColor : public Module
  ConfigReader *Conf, *MyConf;
  
  public:
-       ModuleStripColor()
+       ModuleStripColor(Server* Me)
+               : Module::Module(Me)
        {
-               Srv = new Server;
+               Srv = Me;
 
                Srv->AddExtendedMode('S',MT_CHANNEL,false,0,0);
                Srv->AddExtendedMode('S',MT_CLIENT,false,0,0);
@@ -48,10 +51,28 @@ class ModuleStripColor : public Module
                        return 0;
                }
        }
+
+        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);
+        }
        
        virtual ~ModuleStripColor()
        {
-               delete Srv;
        }
        
        // ANSI colour stripping by Doc (Peter Wood)
@@ -61,7 +82,7 @@ class ModuleStripColor : public Module
                char sentence[MAXBUF];
                strncpy(sentence,text.c_str(),MAXBUF);
   
-               len = strlen (sentence);
+               len = strlen(sentence);
 
                for (i = 0; i < len; i++)
                {
@@ -80,23 +101,24 @@ class ModuleStripColor : public Module
                                case 3:
                                        remove = 1;
 
-                                       if (isdigit (sentence[i + remove]))
+                                       if (isdigit(sentence[i + remove]))
                                                remove++;
 
-                                       if (isdigit (sentence[i + remove]))
+                                       if (isdigit(sentence[i + remove]))
                                                remove++;
 
                                        if (sentence[i + remove] == ',')
                                        {
                                                remove += 2;
 
-                                               if (isdigit (sentence[i + remove]))
-                                               remove++;
+                                               if (isdigit(sentence[i + remove]))
+                                                       remove++;
                                        }
                                break;
                        }
 
-                       if (remove != 0) {
+                       if (remove != 0)
+                       {
                                len -= remove;
 
                                for (a = i; a <= len; a++)
@@ -151,7 +173,7 @@ class ModuleStripColor : public Module
        virtual Version GetVersion()
        {
                // This is version 2 because version 1.x is the unreleased unrealircd module
-               return Version(1,0,0,0);
+               return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
        }
        
 };
@@ -169,9 +191,9 @@ class ModuleStripColorFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule()
+       virtual Module * CreateModule(Server* Me)
        {
-               return new ModuleStripColor;
+               return new ModuleStripColor(Me);
        }
        
 };