]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_silence.cpp
Mode +b stuff, probably wont work yet
[user/henk/code/inspircd.git] / src / modules / m_silence.cpp
index 31baf899f73565a1e1a4cdc9731fce5395924860..d921545fbd838c7e58ea53ec4d514531bb0f802f 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -36,7 +36,7 @@ typedef std::vector<std::string> silencelist;
 class cmd_silence : public command_t
 {
  public:
-       cmd_silence() : command_t("SILENCE", 0, 1)
+       cmd_silence() : command_t("SILENCE", 0, 0)
        {
                this->source = "m_silence.so";
        }
@@ -71,27 +71,27 @@ class cmd_silence : public command_t
                                // does it contain any entries and does it exist?
                                if (sl)
                                {
-                                       if (sl->size())
-                                       {
-                                               for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
-                                               {
+                                       if (sl->size())
+                                       {
+                                               for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
+                                               {
                                                        // search through for the item
                                                        irc::string listitem = i->c_str();
                                                        irc::string target = nick;
                                                        if (listitem == target)
-                                                       {
-                                                               sl->erase(i);
+                                                       {
+                                                               sl->erase(i);
                                                                WriteServ(user->fd,"950 %s %s :Removed %s!*@* from silence list",user->nick, user->nick,nick);
                                                                // we have modified the vector from within a loop, we must now bail out
-                                                               return;
-                                                       }
-                                               }
-                                       }
+                                                               return;
+                                                       }
+                                               }
+                                       }
                                        if (!sl->size())
                                        {
                                                // tidy up -- if a user's list is empty, theres no use having it
                                                // hanging around in the user record.
-                                               delete sl;
+                                               DELETE(sl);
                                                user->Shrink("silence_list");
                                        }
                                }
@@ -143,17 +143,17 @@ class ModuleSilence : public Module
 
        void Implements(char* List)
        {
-               List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[OnUserPreMessage] = 1;
+               List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
        }
 
-       virtual void OnUserQuit(userrec* user, std::string reason)
+       virtual void OnUserQuit(userrec* user, const std::string &reason)
        {
                // when the user quits tidy up any silence list they might have just to keep things tidy
                // and to prevent a HONKING BIG MEMORY LEAK!
                silencelist* sl = (silencelist*)user->GetExt("silence_list");
                if (sl)
                {
-                       delete sl;
+                       DELETE(sl);
                        user->Shrink("silence_list");
                }
        }
@@ -164,7 +164,7 @@ class ModuleSilence : public Module
                output = output + " SILENCE=999";
        }
        
-       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
        {
                // im not sure how unreal's silence operates but ours is sensible. It blocks notices and
                // privmsgs from people on the silence list, directed privately at the user.
@@ -178,9 +178,9 @@ class ModuleSilence : public Module
                        {
                                for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
                                {
-                                        irc::string listitem = c->c_str();
-                                        irc::string target = user->nick;
-                                        if (listitem == target)
+                                       irc::string listitem = c->c_str();
+                                       irc::string target = user->nick;
+                                       if (listitem == target)
                                        {
                                                return 1;
                                        }
@@ -190,27 +190,10 @@ class ModuleSilence : public Module
                return 0;
        }
 
-        virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
-        {
-                if (target_type == TYPE_USER)
-                {
-                        userrec* u = (userrec*)dest;
-                        silencelist* sl = (silencelist*)u->GetExt("silence_list");
-                        if (sl)
-                        {
-                                for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
-                                {
-                                        irc::string listitem = c->c_str();
-                                        irc::string target = user->nick;
-                                        if (listitem == target)
-                                        {
-                                                return 1;
-                                        }
-                                }
-                        }
-                }
-                return 0;
-        }
+       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
+       {
+               return OnUserPreNotice(user,dest,target_type,text,status);
+       }
 
        virtual ~ModuleSilence()
        {