]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / commands.cpp
index 9215a4db5b438153ba5b0fc3fa6e5adf290676ea..f855c7b6c91d9afd234a8f4366b6ded8f72711da 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
  *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
  *   Copyright (C) 2009 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
 
 #include "inspircd.h"
 
+CommandBase::CommandBase(Module* mod, const std::string& cmd, unsigned int minpara, unsigned int maxpara)
+       : ServiceProvider(mod, cmd, SERVICE_COMMAND)
+       , min_params(minpara)
+       , max_params(maxpara)
+       , allow_empty_last_param(true)
+{
+}
+
+CommandBase::~CommandBase()
+{
+}
+
+void CommandBase::EncodeParameter(std::string& parameter, unsigned int index)
+{
+}
+
+RouteDescriptor CommandBase::GetRouting(User* user, const Params& parameters)
+{
+       return ROUTE_LOCALONLY;
+}
+
+Command::Command(Module* mod, const std::string& cmd, unsigned int minpara, unsigned int maxpara)
+       : CommandBase(mod, cmd, minpara, maxpara)
+       , flags_needed(0)
+       , force_manual_route(false)
+       , Penalty(1)
+       , use_count(0)
+       , works_before_reg(false)
+{
+}
+
+Command::~Command()
+{
+       ServerInstance->Parser.RemoveCommand(this);
+}
+
+void Command::RegisterService()
+{
+       if (!ServerInstance->Parser.AddCommand(this))
+               throw ModuleException("Command already exists: " + name);
+}
+
+void Command::TellNotEnoughParameters(LocalUser* user, const Params& parameters)
+{
+       user->WriteNumeric(ERR_NEEDMOREPARAMS, name, "Not enough parameters.");
+       if (ServerInstance->Config->SyntaxHints && user->registered == REG_ALL && syntax.length())
+               user->WriteNumeric(RPL_SYNTAX, name, syntax);
+}
+
+void Command::TellNotRegistered(LocalUser* user, const Params& parameters)
+{
+       user->WriteNumeric(ERR_NOTREGISTERED, name, "You have not registered.");
+}
+
 SplitCommand::SplitCommand(Module* me, const std::string& cmd, unsigned int minpara, unsigned int maxpara)
        : Command(me, cmd, minpara, maxpara)
 {