]> 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 c5b34c72f0e655d3c8a64e557c75252e5141ace1..f855c7b6c91d9afd234a8f4366b6ded8f72711da 100644 (file)
@@ -1,11 +1,12 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   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>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2004-2007 Craig Edwards <craigedwards@brainbox.cc>
- *   Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
- *   Copyright (C) 2005 Craig McLure <craig@chatspike.net>
+ *   Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 
 #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)
+{
+}
+
 CmdResult SplitCommand::Handle(User* user, const Params& parameters)
 {
        switch (user->usertype)