]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_clones.cpp
Add SHUN as a /filter action
[user/henk/code/inspircd.git] / src / modules / m_clones.cpp
index 1e5841609fa875f8f9a8c45450aabb8b8120067b..7cce32188932d51774bb95af15b708da1a852362 100644 (file)
@@ -21,9 +21,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides the /clones command to retrieve information on clones. */
-
-/** Handle /CHECK
+/** Handle /CLONES
  */
 class CommandClones : public Command
 {
@@ -33,57 +31,49 @@ class CommandClones : public Command
                flags_needed = 'o'; syntax = "<limit>";
        }
 
-       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+       CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
        {
 
-               std::string clonesstr = "304 " + std::string(user->nick) + " :CLONES";
+               std::string clonesstr = "CLONES ";
 
-               unsigned long limit = atoi(parameters[0].c_str());
+               unsigned long limit = strtoul(parameters[0].c_str(), NULL, 10);
 
                /*
                 * Syntax of a /clones reply:
                 *  :server.name 304 target :CLONES START
                 *  :server.name 304 target :CLONES <count> <ip>
-                *  :server.name 304 target :CHECK END
+                *  :server.name 304 target :CLONES END
                 */
 
-               user->WriteServ(clonesstr + " START");
+               user->WriteNumeric(304, clonesstr + "START");
 
                /* hostname or other */
-               // XXX I really don't like marking global_clones public for this. at all. -- w00t
-               for (clonemap::iterator x = ServerInstance->Users->global_clones.begin(); x != ServerInstance->Users->global_clones.end(); x++)
+               const UserManager::CloneMap& clonemap = ServerInstance->Users->GetCloneMap();
+               for (UserManager::CloneMap::const_iterator i = clonemap.begin(); i != clonemap.end(); ++i)
                {
-                       if (x->second >= limit)
-                               user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + x->first.str());
+                       const UserManager::CloneCounts& counts = i->second;
+                       if (counts.global >= limit)
+                               user->WriteNumeric(304, clonesstr + ConvToStr(counts.global) + " " + i->first.str());
                }
 
-               user->WriteServ(clonesstr + " END");
+               user->WriteNumeric(304, clonesstr + "END");
 
                return CMD_SUCCESS;
        }
 };
 
-
 class ModuleClones : public Module
 {
- private:
        CommandClones cmd;
  public:
        ModuleClones() : cmd(this)
        {
-               ServerInstance->AddCommand(&cmd);
        }
 
-       virtual ~ModuleClones()
+       Version GetVersion() CXX11_OVERRIDE
        {
+               return Version("Provides the /CLONES command to retrieve information on clones.", VF_VENDOR);
        }
-
-       virtual Version GetVersion()
-       {
-               return Version("Provides the /clones command to retrieve information on clones.", VF_VENDOR);
-       }
-
-
 };
 
 MODULE_INIT(ModuleClones)