X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands.cpp;h=f855c7b6c91d9afd234a8f4366b6ded8f72711da;hb=b00cf4ca15d992623720b24a9c2487d41be8d6cb;hp=c5b34c72f0e655d3c8a64e557c75252e5141ace1;hpb=384ef31bc01e4a1a2e59d082c9066002410ba54a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands.cpp b/src/commands.cpp index c5b34c72f..f855c7b6c 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1,11 +1,12 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2018, 2020 Sadie Powell + * Copyright (C) 2012 Robby + * Copyright (C) 2009 Robin Burchell * Copyright (C) 2009 Daniel De Graaf * Copyright (C) 2007 Dennis Friis - * Copyright (C) 2004-2007 Craig Edwards - * Copyright (C) 2006 Oliver Lupton - * Copyright (C) 2005 Craig McLure + * Copyright (C) 2006, 2010 Craig Edwards * * 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 @@ -23,6 +24,65 @@ #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)