diff options
-rw-r--r-- | src/coremods/core_message.cpp | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp index 961307b06..f649cf9a7 100644 --- a/src/coremods/core_message.cpp +++ b/src/coremods/core_message.cpp @@ -305,7 +305,35 @@ class CommandMessage : public Command * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE; + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE + { + if (CommandParser::LoopCall(user, this, parameters, 0)) + return CMD_SUCCESS; + + // The specified message was empty. + if (parameters[1].empty()) + { + user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send"); + return CMD_FAILURE; + } + + // The target is a server glob. + if (parameters[0][0] == '$') + return HandleServerTarget(user, parameters); + + // If the message begins with a status character then look it up. + const char* target = parameters[0].c_str(); + PrefixMode* pmh = ServerInstance->Modes->FindPrefix(target[0]); + if (pmh) + target++; + + // The target is a channel name. + if (*target == '#') + return HandleChannelTarget(user, parameters, target, pmh); + + // The target is a nickname. + return HandleUserTarget(user, parameters); + } RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE { @@ -317,29 +345,6 @@ class CommandMessage : public Command } }; -CmdResult CommandMessage::Handle(User* user, const Params& parameters) -{ - if (CommandParser::LoopCall(user, this, parameters, 0)) - return CMD_SUCCESS; - - // The target is a server glob. - if (parameters[0][0] == '$') - return HandleServerTarget(user, parameters); - - // If the message begins with a status character then look it up. - const char* target = parameters[0].c_str(); - PrefixMode* pmh = ServerInstance->Modes->FindPrefix(target[0]); - if (pmh) - target++; - - // The target is a channel name. - if (*target == '#') - return HandleChannelTarget(user, parameters, target, pmh); - - // The target is a nickname. - return HandleUserTarget(user, parameters); -} - class ModuleCoreMessage : public Module { private: |