]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/servercommand.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / servercommand.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2013-2015 Attila Molnar <attilamolnar@hush.com>
6  *
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.
10  *
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
14  * details.
15  *
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/>.
18  */
19
20
21 #include "inspircd.h"
22 #include "main.h"
23 #include "servercommand.h"
24
25 ServerCommand::ServerCommand(Module* Creator, const std::string& Name, unsigned int MinParams, unsigned int MaxParams)
26         : CommandBase(Creator, Name, MinParams, MaxParams)
27 {
28 }
29
30 void ServerCommand::RegisterService()
31 {
32         ModuleSpanningTree* st = static_cast<ModuleSpanningTree*>(static_cast<Module*>(creator));
33         st->CmdManager.AddCommand(this);
34 }
35
36 RouteDescriptor ServerCommand::GetRouting(User* user, const Params& parameters)
37 {
38         // Broadcast server-to-server commands unless overridden
39         return ROUTE_BROADCAST;
40 }
41
42 time_t ServerCommand::ExtractTS(const std::string& tsstr)
43 {
44         time_t TS = ConvToNum<time_t>(tsstr);
45         if (!TS)
46                 throw ProtocolException("Invalid TS");
47         return TS;
48 }
49
50 ServerCommand* ServerCommandManager::GetHandler(const std::string& command) const
51 {
52         ServerCommandMap::const_iterator it = commands.find(command);
53         if (it != commands.end())
54                 return it->second;
55         return NULL;
56 }
57
58 bool ServerCommandManager::AddCommand(ServerCommand* cmd)
59 {
60         return commands.insert(std::make_pair(cmd->name, cmd)).second;
61 }