]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_testnet.cpp
Merge pull request #959 from Alef-Burzmali/master+fixcloaking
[user/henk/code/inspircd.git] / src / modules / m_testnet.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #include "inspircd.h"
21
22 class CommandTest : public Command
23 {
24  public:
25         CommandTest(Module* parent) : Command(parent, "TEST", 1)
26         {
27                 syntax = "<action> <parameters>";
28         }
29
30         CmdResult Handle(const std::vector<std::string> &parameters, User *user)
31         {
32                 if (parameters[0] == "flood")
33                 {
34                         unsigned int count = parameters.size() > 1 ? atoi(parameters[1].c_str()) : 100;
35                         std::string line = parameters.size() > 2 ? parameters[2] : ":z.z NOTICE !flood :Flood text";
36                         for(unsigned int i=0; i < count; i++)
37                                 user->Write(line);
38                 }
39                 else if (parameters[0] == "freeze" && IS_LOCAL(user) && parameters.size() > 1)
40                 {
41                         IS_LOCAL(user)->CommandFloodPenalty += atoi(parameters[1].c_str());
42                 }
43                 return CMD_SUCCESS;
44         }
45 };
46
47 class ModuleTest : public Module
48 {
49         CommandTest cmd;
50  public:
51         ModuleTest() : cmd(this)
52         {
53         }
54
55         void init() CXX11_OVERRIDE
56         {
57                 if (!strstr(ServerInstance->Config->ServerName.c_str(), ".test"))
58                         throw ModuleException("Don't load modules without reading their descriptions!");
59         }
60
61         Version GetVersion() CXX11_OVERRIDE
62         {
63                 return Version("Provides a module for testing the server while linked in a network", VF_VENDOR|VF_OPTCOMMON);
64         }
65 };
66
67 MODULE_INIT(ModuleTest)