]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_clones.cpp
m_namedmodes Only show chan key to members and opers with channels/auspex
[user/henk/code/inspircd.git] / src / modules / m_clones.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6  *   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21
22 #include "inspircd.h"
23
24 /* $ModDesc: Provides the /CLONES command to retrieve information on clones. */
25
26 /** Handle /CLONES
27  */
28 class CommandClones : public Command
29 {
30  public:
31         CommandClones(Module* Creator) : Command(Creator,"CLONES", 1)
32         {
33                 flags_needed = 'o'; syntax = "<limit>";
34         }
35
36         CmdResult Handle (const std::vector<std::string> &parameters, User *user)
37         {
38
39                 std::string clonesstr = "304 " + user->nick + " :CLONES";
40
41                 unsigned long limit = atoi(parameters[0].c_str());
42
43                 /*
44                  * Syntax of a /clones reply:
45                  *  :server.name 304 target :CLONES START
46                  *  :server.name 304 target :CLONES <count> <ip>
47                  *  :server.name 304 target :CLONES END
48                  */
49
50                 user->WriteServ(clonesstr + " START");
51
52                 /* hostname or other */
53                 // XXX I really don't like marking global_clones public for this. at all. -- w00t
54                 for (clonemap::iterator x = ServerInstance->Users->global_clones.begin(); x != ServerInstance->Users->global_clones.end(); x++)
55                 {
56                         if (x->second >= limit)
57                                 user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + x->first.str());
58                 }
59
60                 user->WriteServ(clonesstr + " END");
61
62                 return CMD_SUCCESS;
63         }
64 };
65
66
67 class ModuleClones : public Module
68 {
69  private:
70         CommandClones cmd;
71  public:
72         ModuleClones() : cmd(this)
73         {
74         }
75
76         void init()
77         {
78                 ServerInstance->Modules->AddService(cmd);
79         }
80
81         virtual ~ModuleClones()
82         {
83         }
84
85         virtual Version GetVersion()
86         {
87                 return Version("Provides the /CLONES command to retrieve information on clones.", VF_VENDOR);
88         }
89
90
91 };
92
93 MODULE_INIT(ModuleClones)