]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_deaf.cpp
Fix these to use new hook system (u_listmode wasnt fixed yet)
[user/henk/code/inspircd.git] / src / modules / m_deaf.cpp
index b5328f785293243e5fc653e05a4596523432244f..8e4378ef3d75b89507acd09a3c84277745107024 100644 (file)
@@ -25,7 +25,7 @@ class User_d : public ModeHandler
  public:
        User_d(InspIRCd* Instance) : ModeHandler(Instance, 'd', 0, 0, false, MODETYPE_USER, false) { }
 
-       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (adding)
                {
@@ -60,31 +60,33 @@ class ModuleDeaf : public Module
                : Module(Me)
        {
                m1 = new User_d(ServerInstance);
-               if (!ServerInstance->AddMode(m1, 'd'))
+               if (!ServerInstance->AddMode(m1))
                        throw ModuleException("Could not add new modes!");
 
                OnRehash(NULL, "");
+               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_OnBuildExemptList };
+               ServerInstance->Modules->Attach(eventlist, this, 4);
        }
 
        void Implements(char* List)
        {
-               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
+               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = List[I_OnBuildExemptList] = 1;
        }
 
-       virtual void OnRehash(userrec* user, const std::string&)
+       virtual void OnRehash(User* user, const std::string&)
        {
                ConfigReader* conf = new ConfigReader(ServerInstance);
                deaf_bypasschars = conf->ReadValue("deaf", "bypasschars", 0);
                deaf_bypasschars_uline = conf->ReadValue("deaf", "bypasscharsuline", 0);
 
-               DELETE(conf);
+               delete conf;
        }
 
-       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (target_type == TYPE_CHANNEL)
                {
-                       chanrec* chan = (chanrec*)dest;
+                       Channel* chan = (Channel*)dest;
                        if (chan)
                                this->BuildDeafList(MSG_NOTICE, chan, user, status, text, exempt_list);
                }
@@ -92,11 +94,11 @@ class ModuleDeaf : public Module
                return 0;
        }
 
-       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (target_type == TYPE_CHANNEL)
                {
-                       chanrec* chan = (chanrec*)dest;
+                       Channel* chan = (Channel*)dest;
                        if (chan)
                                this->BuildDeafList(MSG_PRIVMSG, chan, user, status, text, exempt_list);
                }
@@ -104,7 +106,12 @@ class ModuleDeaf : public Module
                return 0;
        }
 
-       virtual void BuildDeafList(MessageType message_type, chanrec* chan, userrec* sender, char status, std::string &text, CUList &exempt_list)
+       virtual void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text)
+       {
+               BuildDeafList(message_type, chan, sender, status, text, exempt_list);
+       }
+
+       virtual void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list)
        {
                CUList *ulist;
                bool is_a_uline;
@@ -173,7 +180,7 @@ class ModuleDeaf : public Module
        virtual ~ModuleDeaf()
        {
                ServerInstance->Modes->DelMode(m1);
-               DELETE(m1);
+               delete m1;
        }
 
        virtual Version GetVersion()