2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013-2015 Attila Molnar <attilamolnar@hush.com>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "servercommand.h"
25 ServerCommand::ServerCommand(Module* Creator, const std::string& Name, unsigned int MinParams, unsigned int MaxParams)
26 : CommandBase(Creator, Name, MinParams, MaxParams)
30 void ServerCommand::RegisterService()
32 ModuleSpanningTree* st = static_cast<ModuleSpanningTree*>(static_cast<Module*>(creator));
33 st->CmdManager.AddCommand(this);
36 RouteDescriptor ServerCommand::GetRouting(User* user, const Params& parameters)
38 // Broadcast server-to-server commands unless overridden
39 return ROUTE_BROADCAST;
42 time_t ServerCommand::ExtractTS(const std::string& tsstr)
44 time_t TS = ConvToNum<time_t>(tsstr);
46 throw ProtocolException("Invalid TS");
50 ServerCommand* ServerCommandManager::GetHandler(const std::string& command) const
52 ServerCommandMap::const_iterator it = commands.find(command);
53 if (it != commands.end())
58 bool ServerCommandManager::AddCommand(ServerCommand* cmd)
60 return commands.insert(std::make_pair(cmd->name, cmd)).second;