]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_clones.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / modules / m_clones.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "wildcard.h"
16
17 /* $ModDesc: Provides the /clones command to retrieve information on a user, channel, or IP address */
18
19 /** Handle /CHECK
20  */
21 class CommandClones : public Command
22 {
23  public:
24         CommandClones (InspIRCd* Instance) : Command(Instance,"CLONES", 'o', 1)
25         {
26                 this->source = "m_clones.so";
27                 syntax = "<limit>";
28         }
29
30         CmdResult Handle (const char** parameters, int pcnt, User *user)
31         {
32
33                 std::string clonesstr = "304 " + std::string(user->nick) + " :CLONES";
34
35                 unsigned long limit = atoi(parameters[0]);
36
37                 /*
38                  * Syntax of a /clones reply:
39                  *  :server.name 304 target :CLONES START
40                  *  :server.name 304 target :CLONES <count> <ip>
41                  *  :server.name 304 target :CHECK END
42                  */
43
44                 user->WriteServ(clonesstr + " START");
45
46                 /* hostname or other */
47                 for (clonemap::iterator x = ServerInstance->global_clones.begin(); x != ServerInstance->global_clones.end(); x++)
48                 {
49                         if (x->second >= limit)
50                                 user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + assign(x->first));
51                 }
52
53                 user->WriteServ(clonesstr + " END");
54
55                 return CMD_LOCALONLY;
56         }
57 };
58
59
60 class ModuleClones : public Module
61 {
62  private:
63         CommandClones *mycommand;
64  public:
65         ModuleClones(InspIRCd* Me) : Module(Me)
66         {
67                 
68                 mycommand = new CommandClones(ServerInstance);
69                 ServerInstance->AddCommand(mycommand);
70
71         }
72         
73         virtual ~ModuleClones()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
80         }
81
82         
83 };
84
85 MODULE_INIT(ModuleClones)