]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_shun.cpp
Add extban types +bb R: and M: - stops matching account masks from joining and speaki...
[user/henk/code/inspircd.git] / src / modules / m_shun.cpp
index be77f9d772beb69b65c46ebe8f24080cffc2c0d3..bdf990313098ac615d1f45a657d54a8c56c0c68d 100644 (file)
@@ -1,11 +1,4 @@
-#include <algorithm>
-#include <vector>
-#include <string>
-#include <sstream>
 #include "inspircd.h"
-#include "modules.h"
-#include "hashcomp.h"
-#include "configreader.h"
 #include "xline.h"
 
 /* $ModDesc: Provides the /shun command, which stops a user executing all commands except PING and PONG. */
@@ -168,16 +161,17 @@ class ModuleShun : public Module
 
        virtual ~ModuleShun()
        {
+               ServerInstance->XLines->DelAll("SHUN");
                ServerInstance->XLines->UnregisterFactory(f);
        }
 
        virtual int OnStats(char symbol, User* user, string_list& out)
        {
-               // XXX write me
-//format << Srv->Config->ServerName << " 223 " << user->nick << " :" << iter->banmask << " " << iter->set_on << " " << iter->length << " " << 
-//iter->set_by << " " << iter->reason; 
-               
-               return 0;
+               if (symbol != 'S')
+                       return 0;
+
+               ServerInstance->XLines->InvokeStats("SHUN", 223, user, out);
+               return 1;
        }
 
        virtual void OnUserConnect(User* user)
@@ -195,20 +189,35 @@ class ModuleShun : public Module
                }
        }
 
-       virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
+       virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
        {
-               if((command != "PONG") && (command != "PING"))
+               if (validated || !user->GetExt("shunned"))
+                       return 0;
+
+               if (!ServerInstance->XLines->MatchesLine("SHUN", user))
+               {
+                       /* The shun previously set on this user has expired or been removed */
+                       user->Shrink("shunned");
+                       return 0;
+               }
+
+               if (command == "QUIT")
                {
-                       if (user->GetExt("shunned"))
-                               return 1;
+                       /* Allow QUIT but dont show any quit message */
+                       parameters.clear();
+                       return 0;
                }
 
-               return 0;
+               /* Always allow PONG and PING */
+               if (command == "PONG" || command == "PING")
+                       return 0;
+
+               return 1;
        }
 
        virtual Version GetVersion()
        {
-               return Version(1,0,0,0,0,API_VERSION);
+               return Version(1,2,0,0,VF_VENDOR|VF_COMMON,API_VERSION);
        }
 };