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);
134 * Lowers the TS on the given channel: removes all modes, unsets all extensions,
135 * clears the topic and removes all pending invites.
136 * @param chan The target channel whose TS to lower
137 * @param TS The new TS to set
138 * @param newname The new name of the channel; must be the same or a case change of the current name
140 static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
141 bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
143 CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
144 CmdResult Handle(User* user, std::vector<std::string>& params);
147 class CommandFMode : public ServerCommand
150 CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
151 CmdResult Handle(User* user, std::vector<std::string>& params);
154 class CommandFTopic : public ServerCommand
157 CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
158 CmdResult Handle(User* user, std::vector<std::string>& params);
160 class Builder : public CmdBuilder
163 Builder(Channel* chan);
164 Builder(User* user, Channel* chan);
168 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
171 CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
172 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
175 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
178 CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
179 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
182 class CommandFName : public UserOnlyServerCommand<CommandFName>
185 CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
186 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
189 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
192 CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
193 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
196 class CommandResync : public ServerOnlyServerCommand<CommandResync>
199 CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
200 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
203 class CommandAway : public UserOnlyServerCommand<CommandAway>
206 CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
207 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
209 class Builder : public CmdBuilder
213 Builder(User* user, const std::string& msg);
218 class CommandAddLine : public ServerCommand
221 CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
222 CmdResult Handle(User* user, std::vector<std::string>& parameters);
224 class Builder : public CmdBuilder
227 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
231 class CommandDelLine : public ServerCommand
234 CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
235 CmdResult Handle(User* user, std::vector<std::string>& parameters);
238 class CommandEncap : public ServerCommand
241 CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
242 CmdResult Handle(User* user, std::vector<std::string>& parameters);
243 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
246 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
249 CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
250 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
251 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
254 class CommandNick : public UserOnlyServerCommand<CommandNick>
257 CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
258 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
261 class CommandPing : public ServerCommand
264 CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
265 CmdResult Handle(User* user, std::vector<std::string>& parameters);
266 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
269 class CommandPong : public ServerOnlyServerCommand<CommandPong>
272 CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
273 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
274 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
277 class CommandPush : public ServerCommand
280 CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
281 CmdResult Handle(User* user, std::vector<std::string>& parameters);
282 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
285 class CommandSave : public ServerCommand
288 CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
289 CmdResult Handle(User* user, std::vector<std::string>& parameters);
292 class CommandServer : public ServerOnlyServerCommand<CommandServer>
295 CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
296 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
298 class Builder : public CmdBuilder
301 Builder(TreeServer* server);
305 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
308 CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
309 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
312 class CommandSNONotice : public ServerCommand
315 CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
316 CmdResult Handle(User* user, std::vector<std::string>& parameters);
319 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
322 CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
323 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
326 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
329 CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
330 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
333 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
336 CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
337 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
340 class SpanningTreeCommands
343 CommandSVSJoin svsjoin;
344 CommandSVSPart svspart;
345 CommandSVSNick svsnick;
346 CommandMetadata metadata;
348 CommandOpertype opertype;
351 CommandResync resync;
353 CommandFTopic ftopic;
355 CommandFIdent fident;
358 CommandAddLine addline;
359 CommandDelLine delline;
367 CommandServer server;
369 CommandSNONotice snonotice;
370 CommandVersion version;
372 CommandEndBurst endburst;
373 SpanningTreeCommands(ModuleSpanningTree* module);