]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_showwhois.cpp
m_spanningtree Remove unneeded #includes
[user/henk/code/inspircd.git] / src / modules / m_showwhois.cpp
index d81dd553d2743f641c9c2281a05e4e15fc6dfba1..459e4866458f8690e2a500755f527c38510a3367 100644 (file)
@@ -74,18 +74,23 @@ class ModuleShowwhois : public Module
 
  public:
 
-       ModuleShowwhois() : cmd(this)
+       ModuleShowwhois()
+               : sw(NULL), cmd(this)
        {
-               ConfigReader conf;
-               bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0);
-               ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0);
+       }
+
+       void init()
+       {
+               ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois");
+
+               bool OpersOnly = tag->getBool("opersonly", true);
+               ShowWhoisFromOpers = tag->getBool("showfromopers", true);
 
                sw = new SeeWhois(this, OpersOnly);
-               if (!ServerInstance->Modes->AddMode(sw))
-                       throw ModuleException("Could not add new modes!");
-               ServerInstance->AddCommand(&cmd);
+               ServerInstance->Modules->AddService(*sw);
+               ServerInstance->Modules->AddService(cmd);
                Implementation eventlist[] = { I_OnWhois };
-               ServerInstance->Modules->Attach(eventlist, this, 1);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        ~ModuleShowwhois()
@@ -103,7 +108,7 @@ class ModuleShowwhois : public Module
                if (!dest->IsModeSet('W') || source == dest)
                        return;
 
-               if (!ShowWhoisFromOpers && IS_OPER(source))
+               if (!ShowWhoisFromOpers && source->IsOper())
                        return;
 
                if (IS_LOCAL(dest))
@@ -120,7 +125,7 @@ class ModuleShowwhois : public Module
                        ServerInstance->PI->SendEncapsulatedData(params);
                }
        }
-
 };
 
 MODULE_INIT(ModuleShowwhois)
+