]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_helpop.cpp
m_auditorium Handle NULL return from Channel::GetUser() in OnSendWhoLine()
[user/henk/code/inspircd.git] / src / modules / m_helpop.cpp
index a7bd4a8c56969addd51d5bb8b80c940c21186939..4bbe8785e4ef4f7b2f22d059b56f81682eb8d6fe 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 
-/* $ModDesc: Provides the /HELPOP command, works like UnrealIRCd's helpop */
+/* $ModDesc: Provides the /HELPOP command for useful information */
 
 #include "inspircd.h"
 
@@ -29,35 +29,13 @@ static std::map<irc::string, std::string> helpop_map;
 
 /** Handles user mode +h
  */
-class Helpop : public ModeHandler
+class Helpop : public SimpleUserModeHandler
 {
  public:
-       Helpop(Module* Creator) : ModeHandler(Creator, "helpop", 'h', PARAM_NONE, MODETYPE_USER)
+       Helpop(Module* Creator) : SimpleUserModeHandler(Creator, "helpop", 'h')
        {
                oper = true;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
 };
 
 /** Handles /HELPOP
@@ -121,7 +99,6 @@ class CommandHelpop : public Command
 class ModuleHelpop : public Module
 {
        private:
-               std::string  h_file;
                CommandHelpop cmd;
                Helpop ho;
 
@@ -137,12 +114,12 @@ class ModuleHelpop : public Module
                        ServerInstance->Modules->AddService(ho);
                        ServerInstance->Modules->AddService(cmd);
                        Implementation eventlist[] = { I_OnRehash, I_OnWhois };
-                       ServerInstance->Modules->Attach(eventlist, this, 2);
+                       ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                }
 
                void ReadConfig()
                {
-                       helpop_map.clear();
+                       std::map<irc::string, std::string> help;
 
                        ConfigTagList tags = ServerInstance->Config->ConfTags("helpop");
                        for(ConfigIter i = tags.first; i != tags.second; ++i)
@@ -157,20 +134,21 @@ class ModuleHelpop : public Module
                                        throw ModuleException("m_helpop: The key 'index' is reserved for internal purposes. Please remove it.");
                                }
 
-                               helpop_map[key] = value;
+                               help[key] = value;
                        }
 
-                       if (helpop_map.find("start") == helpop_map.end())
+                       if (help.find("start") == help.end())
                        {
                                // error!
                                throw ModuleException("m_helpop: Helpop file is missing important entry 'start'. Please check the example conf.");
                        }
-                       else if (helpop_map.find("nohelp") == helpop_map.end())
+                       else if (help.find("nohelp") == help.end())
                        {
                                // error!
                                throw ModuleException("m_helpop: Helpop file is missing important entry 'nohelp'. Please check the example conf.");
                        }
 
+                       helpop_map.swap(help);
                }
 
                void OnRehash(User* user)
@@ -182,13 +160,13 @@ class ModuleHelpop : public Module
                {
                        if (dst->IsModeSet('h'))
                        {
-                               ServerInstance->SendWhoisLine(src, dst, 310, std::string(src->nick)+" "+std::string(dst->nick)+" :is available for help.");
+                               ServerInstance->SendWhoisLine(src, dst, 310, src->nick+" "+dst->nick+" :is available for help.");
                        }
                }
 
                Version GetVersion()
                {
-                       return Version("Provides the /HELPOP command, works like UnrealIRCd's helpop", VF_VENDOR);
+                       return Version("Provides the /HELPOP command for useful information", VF_VENDOR);
                }
 };