diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-12 20:51:16 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-12 20:51:16 +0200 |
commit | 97449ad5695dd63841c9e8426e75f3c6543c16da (patch) | |
tree | 3e6bd32d41876be9c13958982e3624dd7f973c43 | |
parent | cfa32a6561e0152ebbd7135eaec9f7c794c170b1 (diff) |
Run the OnPostCommand hook from LoopCall()
-rw-r--r-- | include/command_parse.h | 8 | ||||
-rw-r--r-- | src/command_parse.cpp | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index 895fbb6e5..7809b67b8 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -96,6 +96,10 @@ class CoreExport CommandParser * If the usemax parameter is true (the default) the function only parses until it reaches * ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam. * + * The OnPostCommand hook is executed for each item after it has been processed by the handler, with the + * original line parameter being empty (to indicate that the command in that form was created by this function). + * This only applies if the user executing the command is local. + * * If there are two lists and the second list runs out of tokens before the first list then parameters[extra] * will be an EMPTY string when Handle() is called for the remaining tokens in the first list, even if it is * in the middle of parameters[]! Moreover, empty tokens in the second list are allowed, and those will also @@ -104,7 +108,7 @@ class CoreExport CommandParser * as the last item in the vector. * * @param user The user who sent the command - * @param CommandObj the command object to call for each parameter in the list + * @param handler The command handler to call for each parameter in the list * @param parameters Parameter list as a vector of strings * @param splithere The first parameter index to split as a comma seperated list * @param extra The second parameter index to split as a comma seperated list, or -1 (the default) if there is only one list @@ -113,7 +117,7 @@ class CoreExport CommandParser * command handler for each entry on the list. When this occurs, the caller should return without doing anything, * otherwise it should continue into its main section of code. */ - static bool LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere, int extra = -1, bool usemax = true); + static bool LoopCall(User* user, Command* handler, const std::vector<std::string>& parameters, unsigned int splithere, int extra = -1, bool usemax = true); /** Take a raw input buffer from a recvq, and process it on behalf of a user. * @param buffer The buffer line to process diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 6331b5da4..35cb1601b 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -44,7 +44,7 @@ int InspIRCd::PassCompare(Extensible* ex, const std::string &data, const std::st return (data != input); // this seems back to front, but returns 0 if they *match*, 1 else } -bool CommandParser::LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere, int extra, bool usemax) +bool CommandParser::LoopCall(User* user, Command* handler, const std::vector<std::string>& parameters, unsigned int splithere, int extra, bool usemax) { if (splithere >= parameters.size()) return false; @@ -73,6 +73,7 @@ bool CommandParser::LoopCall(User* user, Command* CommandObj, const std::vector< irc::commasepstream items2(extra >= 0 ? parameters[extra] : "", true); std::string item; unsigned int max = 0; + LocalUser* localuser = IS_LOCAL(user); /* Attempt to iterate these lists and call the command handler * for every parameter or parameter pair until there are no more @@ -93,7 +94,14 @@ bool CommandParser::LoopCall(User* user, Command* CommandObj, const std::vector< new_parameters[extra] = item; } - CommandObj->Handle(new_parameters, user); + CmdResult result = handler->Handle(new_parameters, user); + if (localuser) + { + // Run the OnPostCommand hook with the last parameter (original line) being empty + // to indicate that the command had more targets in its original form. + item.clear(); + FOREACH_MOD(I_OnPostCommand, OnPostCommand(handler, new_parameters, localuser, result, item)); + } } } |