]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_clones.cpp
Finally change all the Version() objects
[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* const* 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                 // XXX I really don't like marking global_clones public for this. at all. -- w00t
48                 for (clonemap::iterator x = ServerInstance->Users->global_clones.begin(); x != ServerInstance->Users->global_clones.end(); x++)
49                 {
50                         if (x->second >= limit)
51                                 user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + assign(x->first));
52                 }
53
54                 user->WriteServ(clonesstr + " END");
55
56                 return CMD_LOCALONLY;
57         }
58 };
59
60
61 class ModuleClones : public Module
62 {
63  private:
64         CommandClones *mycommand;
65  public:
66         ModuleClones(InspIRCd* Me) : Module(Me)
67         {
68                 
69                 mycommand = new CommandClones(ServerInstance);
70                 ServerInstance->AddCommand(mycommand);
71
72         }
73         
74         virtual ~ModuleClones()
75         {
76         }
77         
78         virtual Version GetVersion()
79         {
80                 return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
81         }
82
83         
84 };
85
86 MODULE_INIT(ModuleClones)