summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-02-08 14:25:20 +0000
committerPeter Powell <petpow@saberuk.com>2019-02-09 10:08:50 +0000
commit1f4651e24dc9c233c3fda74dfe6186fab3d03740 (patch)
tree2bdb478d9309c3486bb0967674226d0e8b1d633e /src
parent2680c7907a0b05f65214fc63043322d57a61f455 (diff)
Move CommandMessage::Handle into the class definition.
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_message.cpp53
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: