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
46 CommandMap(Module* Creator);
47 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
48 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
51 class CommandSVSJoin : public ServerCommand
54 CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
55 CmdResult Handle(User* user, std::vector<std::string>& params);
56 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
59 class CommandSVSPart : public ServerCommand
62 CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 2) { }
63 CmdResult Handle(User* user, std::vector<std::string>& params);
64 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
67 class CommandSVSNick : public ServerCommand
70 CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
71 CmdResult Handle(User* user, std::vector<std::string>& params);
72 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
75 class CommandMetadata : public ServerCommand
78 CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
79 CmdResult Handle(User* user, std::vector<std::string>& params);
81 class Builder : public CmdBuilder
84 Builder(User* user, const std::string& key, const std::string& val);
85 Builder(Channel* chan, const std::string& key, const std::string& val);
86 Builder(const std::string& key, const std::string& val);
90 class CommandUID : public ServerOnlyServerCommand<CommandUID>
93 CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
94 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
96 class Builder : public CmdBuilder
103 class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
106 CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
107 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
109 class Builder : public CmdBuilder
117 class CommandFJoin : public ServerCommand
119 /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
120 * This does not update the timestamp of the target channel, this must be done seperately.
122 static void RemoveStatus(Channel* c);
123 static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
126 * Lowers the TS on the given channel: removes all modes, unsets all extensions,
127 * clears the topic and removes all pending invites.
128 * @param chan The target channel whose TS to lower
129 * @param TS The new TS to set
130 * @param newname The new name of the channel; must be the same or a case change of the current name
132 static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
133 bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
135 CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
136 CmdResult Handle(User* user, std::vector<std::string>& params);
139 class CommandFMode : public ServerCommand
142 CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
143 CmdResult Handle(User* user, std::vector<std::string>& params);
146 class CommandFTopic : public ServerCommand
149 CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
150 CmdResult Handle(User* user, std::vector<std::string>& params);
152 class Builder : public CmdBuilder
155 Builder(Channel* chan);
156 Builder(User* user, Channel* chan);
160 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
163 CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
164 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
167 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
170 CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
171 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
174 class CommandFName : public UserOnlyServerCommand<CommandFName>
177 CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
178 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
181 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
184 CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
185 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
188 class CommandResync : public ServerOnlyServerCommand<CommandResync>
191 CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
192 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
195 class CommandAway : public UserOnlyServerCommand<CommandAway>
198 CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
199 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
201 class Builder : public CmdBuilder
205 Builder(User* user, const std::string& msg);
210 class CommandAddLine : public ServerCommand
213 CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
214 CmdResult Handle(User* user, std::vector<std::string>& parameters);
216 class Builder : public CmdBuilder
219 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
223 class CommandDelLine : public ServerCommand
226 CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
227 CmdResult Handle(User* user, std::vector<std::string>& parameters);
230 class CommandEncap : public ServerCommand
233 CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
234 CmdResult Handle(User* user, std::vector<std::string>& parameters);
235 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
238 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
241 CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
242 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
243 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
246 class CommandNick : public UserOnlyServerCommand<CommandNick>
249 CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
250 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
253 class CommandPing : public ServerCommand
256 CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
257 CmdResult Handle(User* user, std::vector<std::string>& parameters);
258 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
261 class CommandPong : public ServerOnlyServerCommand<CommandPong>
264 CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
265 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
266 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
269 class CommandPush : public ServerCommand
272 CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
273 CmdResult Handle(User* user, std::vector<std::string>& parameters);
274 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
277 class CommandSave : public ServerCommand
280 CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
281 CmdResult Handle(User* user, std::vector<std::string>& parameters);
284 class CommandServer : public ServerOnlyServerCommand<CommandServer>
287 CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
288 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
290 class Builder : public CmdBuilder
293 Builder(TreeServer* server);
297 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
300 CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
301 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
304 class CommandSNONotice : public ServerCommand
307 CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
308 CmdResult Handle(User* user, std::vector<std::string>& parameters);
311 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
314 CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
315 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
318 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
321 CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
322 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
325 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
328 CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
329 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
332 class SpanningTreeCommands
335 CommandSVSJoin svsjoin;
336 CommandSVSPart svspart;
337 CommandSVSNick svsnick;
338 CommandMetadata metadata;
340 CommandOpertype opertype;
343 CommandResync resync;
345 CommandFTopic ftopic;
347 CommandFIdent fident;
350 CommandAddLine addline;
351 CommandDelLine delline;
359 CommandServer server;
361 CommandSNONotice snonotice;
362 CommandVersion version;
364 CommandEndBurst endburst;
365 SpanningTreeCommands(ModuleSpanningTree* module);