]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_showwhois.cpp
Merge pull request #1157 from SaberUK/insp20+fix-cron-restart
[user/henk/code/inspircd.git] / src / modules / m_showwhois.cpp
index 6eec64bd5e5daf0e92a032ab0584efcf27ccd9b7..398ebf571bda40d549319385a4aed41536d7550a 100644 (file)
 
 /** Handle user mode +W
  */
-class SeeWhois : public ModeHandler
+class SeeWhois : public SimpleUserModeHandler
 {
  public:
-       SeeWhois(Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, "showwhois", 'W', PARAM_NONE, MODETYPE_USER)
+       SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
        {
                oper = IsOpersOnly;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('W'))
-                       {
-                               dest->SetMode('W',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('W'))
-                       {
-                               dest->SetMode('W',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
 };
 
 class WhoisNoticeCmd : public Command
 {
  public:
-       WhoisNoticeCmd(Module* Creator) : Command(Creator,"WHOISNOTICE", 1)
+       WhoisNoticeCmd(Module* Creator) : Command(Creator,"WHOISNOTICE", 2)
        {
                flags_needed = FLAG_SERVERONLY;
        }
@@ -96,18 +74,23 @@ class ModuleShowwhois : public Module
 
  public:
 
-       ModuleShowwhois() : cmd(this)
+       ModuleShowwhois()
+               : sw(NULL), cmd(this)
+       {
+       }
+
+       void init()
        {
-               ConfigReader conf;
-               bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0);
-               ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0);
+               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()