From 92d83e91038eb54a8200815d5d948c2b61dacce4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 18 Mar 2020 10:54:37 +0000 Subject: Allow commands to override ERR_{NEEDSMOREPARAMS,NOTREGISTERED}. --- src/command_parse.cpp | 6 ++---- src/commands.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index c4e55c3ca..717431087 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -283,9 +283,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman if (command_p.size() < handler->min_params) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NEEDMOREPARAMS, command, "Not enough parameters."); - if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (handler->syntax.length())) - user->WriteNumeric(RPL_SYNTAX, handler->name, handler->syntax); + handler->TellNotEnoughParameters(user, command_p); FOREACH_MOD(OnCommandBlocked, (command, command_p, user)); return; } @@ -293,7 +291,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman if ((user->registered != REG_ALL) && (!handler->works_before_reg)) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NOTREGISTERED, command, "You have not registered"); + handler->TellNotRegistered(user, command_p); FOREACH_MOD(OnCommandBlocked, (command, command_p, user)); } else diff --git a/src/commands.cpp b/src/commands.cpp index 8343cfaac..d1746bc5f 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -66,6 +66,17 @@ void Command::RegisterService() 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) -- cgit v1.2.3