]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_blockamsg.cpp
Some more to fix still, modules probably wont load correctly atm
[user/henk/code/inspircd.git] / src / modules / m_blockamsg.cpp
index 0164590bef6cad81a9b0c5a746664dfd11f4643e..9a6d6e34a406cea969a1789a113cae345dcb5b52 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
-#include "hashcomp.h"
 
 /* $ModDesc: Attempt to block /amsg, at least some of the irritating mIRC scripts. */
 
@@ -53,6 +49,8 @@ class ModuleBlockAmsg : public Module
        {
                
                this->OnRehash(NULL,"");
+               Implementation eventlist[] = { I_OnRehash, I_OnPreCommand, I_OnCleanup };
+               ServerInstance->Modules->Attach(eventlist, this, 3);
        }
 
        void Implements(char* List)
@@ -69,7 +67,7 @@ class ModuleBlockAmsg : public Module
                return Version(1,1,0,0,VF_VENDOR,API_VERSION);
        }
        
-       virtual void OnRehash(userrec* user, const std::string &parameter)
+       virtual void OnRehash(User* user, const std::string &parameter)
        {
                ConfigReader Conf(ServerInstance);
                
@@ -92,7 +90,7 @@ class ModuleBlockAmsg : public Module
                        action = IBLOCK_KILLOPERS;
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, User *user, bool validated, const std::string &original_line)
        {
                // Don't do anything with unregistered users, or remote ones.
                if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
@@ -148,7 +146,7 @@ class ModuleBlockAmsg : public Module
                                        ServerInstance->WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
 
                                if(action == IBLOCK_KILL || action == IBLOCK_KILLOPERS)
-                                       userrec::QuitUser(ServerInstance, user, "Global message (/amsg or /ame) detected");
+                                       User::QuitUser(ServerInstance, user, "Global message (/amsg or /ame) detected");
                                else if(action == IBLOCK_NOTICE || action == IBLOCK_NOTICEOPERS)
                                        user->WriteServ( "NOTICE %s :Global message (/amsg or /ame) detected", user->nick);
                                                                        
@@ -175,7 +173,7 @@ class ModuleBlockAmsg : public Module
        {
                if(target_type == TYPE_USER)
                {
-                       userrec* user = (userrec*)item;
+                       User* user = (User*)item;
                        BlockedMessage* m;
                        user->GetExt("amsgblock", m);
                        if(m)
@@ -188,4 +186,4 @@ class ModuleBlockAmsg : public Module
 };
 
 
-MODULE_INIT(ModuleBlockAmsg);
+MODULE_INIT(ModuleBlockAmsg)