]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_testnet.cpp
Update m_cloaking to use free-form keys instead of weakening the hash IV
[user/henk/code/inspircd.git] / src / modules / m_testnet.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $ModDesc: Provides a module for testing the server while linked in a network */
15
16 #include "inspircd.h"
17
18 class CommandTest : public Command
19 {
20  public:
21         CommandTest(Module* parent) : Command(parent, "TEST", 1)
22         {
23                 syntax = "<action> <parameters>";
24         }
25
26         CmdResult Handle(const std::vector<std::string> &parameters, User *user)
27         {
28                 if (parameters[0] == "flood")
29                 {
30                         unsigned int count = parameters.size() > 1 ? atoi(parameters[1].c_str()) : 100;
31                         std::string line = parameters.size() > 2 ? parameters[2] : ":z.z NOTICE !flood :Flood text";
32                         for(unsigned int i=0; i < count; i++)
33                                 user->Write(line);
34                 }
35                 else if (parameters[0] == "freeze")
36                 {
37                         user->Penalty += 100;
38                 }
39                 else if (parameters[0] == "shutdown")
40                 {
41                         int i = parameters.size() > 1 ? atoi(parameters[1].c_str()) : 2;
42                         ServerInstance->SE->Shutdown(user->GetFd(), i);
43                 }
44                 return CMD_SUCCESS;
45         }
46 };
47
48 class ModuleTest : public Module
49 {
50         CommandTest cmd;
51  public:
52         ModuleTest() : cmd(this)
53         {
54                 if (!strstr(ServerInstance->Config->ServerName.c_str(), ".test"))
55                         throw ModuleException("Don't load modules without reading their descriptions!");
56                 ServerInstance->AddCommand(&cmd);
57         }
58
59         Version GetVersion()
60         {
61                 return Version("Provides a module for testing the server while linked in a network", VF_VENDOR|VF_OPTCOMMON);
62         }
63 };
64
65 MODULE_INIT(ModuleTest)
66