2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
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.
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
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/>.
22 #include "servercommand.h"
23 #include "commandbuilder.h"
27 class CommandRConnect : public Command
30 CommandRConnect(Module* Creator);
31 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
32 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
35 class CommandRSQuit : public Command
38 CommandRSQuit(Module* Creator);
39 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
40 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
43 class CommandMap : public Command
45 /** Show MAP output to a user (recursive)
47 void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
49 /** Returns oper-specific MAP information
51 std::string MapOperInfo(TreeServer* Current);
54 CommandMap(Module* Creator);
55 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
56 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
59 class CommandSVSJoin : public ServerCommand
62 CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
63 CmdResult Handle(User* user, std::vector<std::string>& params);
64 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
67 class CommandSVSPart : public ServerCommand
70 CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 2) { }
71 CmdResult Handle(User* user, std::vector<std::string>& params);
72 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
75 class CommandSVSNick : public ServerCommand
78 CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
79 CmdResult Handle(User* user, std::vector<std::string>& params);
80 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
83 class CommandMetadata : public ServerCommand
86 CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
87 CmdResult Handle(User* user, std::vector<std::string>& params);
89 class Builder : public CmdBuilder
92 Builder(User* user, const std::string& key, const std::string& val);
93 Builder(Channel* chan, const std::string& key, const std::string& val);
94 Builder(const std::string& key, const std::string& val);
98 class CommandUID : public ServerOnlyServerCommand<CommandUID>
101 CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
102 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
104 class Builder : public CmdBuilder
111 class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
114 CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
115 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
117 class Builder : public CmdBuilder
125 class CommandFJoin : public ServerCommand
127 /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
128 * This does not update the timestamp of the target channel, this must be done seperately.
130 static void RemoveStatus(Channel* c);
131 static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
132 bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
134 CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
135 CmdResult Handle(User* user, std::vector<std::string>& params);
138 class CommandFMode : public ServerCommand
141 CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
142 CmdResult Handle(User* user, std::vector<std::string>& params);
145 class CommandFTopic : public ServerCommand
148 CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
149 CmdResult Handle(User* user, std::vector<std::string>& params);
151 class Builder : public CmdBuilder
154 Builder(Channel* chan);
155 Builder(User* user, Channel* chan);
159 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
162 CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
163 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
166 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
169 CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
170 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
173 class CommandFName : public UserOnlyServerCommand<CommandFName>
176 CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
177 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
180 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
183 CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
184 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
187 class CommandResync : public ServerOnlyServerCommand<CommandResync>
190 CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
191 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
194 class CommandAway : public UserOnlyServerCommand<CommandAway>
197 CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
198 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
200 class Builder : public CmdBuilder
204 Builder(User* user, const std::string& msg);
209 class CommandAddLine : public ServerCommand
212 CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
213 CmdResult Handle(User* user, std::vector<std::string>& parameters);
215 class Builder : public CmdBuilder
218 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
222 class CommandDelLine : public ServerCommand
225 CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
226 CmdResult Handle(User* user, std::vector<std::string>& parameters);
229 class CommandEncap : public ServerCommand
232 CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
233 CmdResult Handle(User* user, std::vector<std::string>& parameters);
234 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
237 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
240 CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
241 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
242 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
245 class CommandNick : public UserOnlyServerCommand<CommandNick>
248 CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
249 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
252 class CommandPing : public ServerCommand
255 CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
256 CmdResult Handle(User* user, std::vector<std::string>& parameters);
257 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
260 class CommandPong : public ServerOnlyServerCommand<CommandPong>
263 CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
264 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
265 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
268 class CommandPush : public ServerCommand
271 CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
272 CmdResult Handle(User* user, std::vector<std::string>& parameters);
273 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
276 class CommandSave : public ServerCommand
279 CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
280 CmdResult Handle(User* user, std::vector<std::string>& parameters);
283 class CommandServer : public ServerOnlyServerCommand<CommandServer>
286 CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
287 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
289 class Builder : public CmdBuilder
292 Builder(TreeServer* server);
296 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
299 CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
300 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
303 class CommandSNONotice : public ServerCommand
306 CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
307 CmdResult Handle(User* user, std::vector<std::string>& parameters);
310 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
313 CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
314 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
317 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
320 CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
321 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
324 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
327 CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
328 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
331 class SpanningTreeCommands
334 CommandSVSJoin svsjoin;
335 CommandSVSPart svspart;
336 CommandSVSNick svsnick;
337 CommandMetadata metadata;
339 CommandOpertype opertype;
342 CommandResync resync;
344 CommandFTopic ftopic;
346 CommandFIdent fident;
349 CommandAddLine addline;
350 CommandDelLine delline;
358 CommandServer server;
360 CommandSNONotice snonotice;
361 CommandVersion version;
363 CommandEndBurst endburst;
364 SpanningTreeCommands(ModuleSpanningTree* module);