]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_stub.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / coremods / core_stub.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
5  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
6  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
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
25 /** Handle /CONNECT.
26  */
27 class CommandConnect : public Command
28 {
29  public:
30         /** Constructor for connect.
31          */
32         CommandConnect(Module* parent)
33                 : Command(parent, "CONNECT", 1)
34         {
35                 flags_needed = 'o';
36                 syntax = "<servername>";
37         }
38
39         /** Handle command.
40          * @param parameters The parameters to the command
41          * @param user The user issuing the command
42          * @return A value from CmdResult to indicate command success or failure.
43          */
44         CmdResult Handle(const std::vector<std::string>& parameters, User* user)
45         {
46                 /*
47                  * This is handled by the server linking module, if necessary. Do not remove this stub.
48                  */
49                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
50                 return CMD_SUCCESS;
51         }
52 };
53
54 /** Handle /LINKS.
55  */
56 class CommandLinks : public Command
57 {
58  public:
59         /** Constructor for links.
60          */
61         CommandLinks(Module* parent)
62                 : Command(parent, "LINKS", 0, 0)
63         {
64         }
65
66         /** Handle command.
67          * @param parameters The parameters to the command
68          * @param user The user issuing the command
69          * @return A value from CmdResult to indicate command success or failure.
70          */
71         CmdResult Handle(const std::vector<std::string>& parameters, User* user)
72         {
73                 user->WriteNumeric(RPL_LINKS, ServerInstance->Config->ServerName, ServerInstance->Config->ServerName, InspIRCd::Format("0 %s", ServerInstance->Config->ServerDesc.c_str()));
74                 user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
75                 return CMD_SUCCESS;
76         }
77 };
78
79 /** Handle /SERVER.
80  */
81 class CommandServer : public Command
82 {
83  public:
84         /** Constructor for server.
85          */
86         CommandServer(Module* parent)
87                 : Command(parent, "SERVER")
88         {
89                 works_before_reg = true;
90         }
91
92         /** Handle command.
93          * @param parameters The parameters to the command
94          * @param user The user issuing the command
95          * @return A value from CmdResult to indicate command success or failure.
96          */
97         CmdResult Handle(const std::vector<std::string>& parameters, User* user)
98         {
99                 if (user->registered == REG_ALL)
100                 {
101                         user->WriteNumeric(ERR_ALREADYREGISTERED, "You are already registered. (Perhaps your IRC client does not have a /SERVER command).");
102                 }
103                 else
104                 {
105                         user->WriteNumeric(ERR_NOTREGISTERED, "SERVER", "You may not register as a server (servers have separate ports from clients, change your config)");
106                 }
107                 return CMD_FAILURE;
108         }
109 };
110
111 /** Handle /SQUIT.
112  */
113 class CommandSquit : public Command
114 {
115  public:
116         /** Constructor for squit.
117          */
118         CommandSquit(Module* parent)
119                 : Command(parent, "SQUIT", 1, 2)
120         {
121                 flags_needed = 'o';
122                 syntax = "<servername>";
123         }
124
125         /** Handle command.
126          * @param parameters The parameters to the command
127          * @param user The user issuing the command
128          * @return A value from CmdResult to indicate command success or failure.
129          */
130         CmdResult Handle(const std::vector<std::string>& parameters, User* user)
131         {
132                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
133                 return CMD_FAILURE;
134         }
135 };
136
137 class CoreModStub : public Module
138 {
139         CommandConnect cmdconnect;
140         CommandLinks cmdlinks;
141         CommandServer cmdserver;
142         CommandSquit cmdsquit;
143
144  public:
145         CoreModStub()
146                 : cmdconnect(this), cmdlinks(this), cmdserver(this), cmdsquit(this)
147         {
148         }
149
150         Version GetVersion()
151         {
152                 return Version("Provides the stub commands CONNECT, LINKS, SERVER and SQUIT", VF_VENDOR|VF_CORE);
153         }
154 };
155
156 MODULE_INIT(CoreModStub)