summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/commands.h4
-rw-r--r--src/command.cpp21
2 files changed, 13 insertions, 12 deletions
diff --git a/include/commands.h b/include/commands.h
index 49a8e2183..c4c7df663 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -173,9 +173,9 @@ public:
* @param source The source of the command
* @param message The full message to run, the command is at the beginning of the message
*/
- static void Run(CommandSource &source, const Anope::string &message);
+ static bool Run(CommandSource &source, const Anope::string &message);
- void Run(CommandSource &source, const Anope::string &, const CommandInfo &, std::vector<Anope::string> &params);
+ bool Run(CommandSource &source, const Anope::string &, const CommandInfo &, std::vector<Anope::string> &params);
/** Looks up a command name from the service name.
* Note that if the same command exists multiple places this will return the first one encountered
diff --git a/src/command.cpp b/src/command.cpp
index 57fd1cf98..d344ffa89 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -273,7 +273,7 @@ namespace
}
}
-void Command::Run(CommandSource &source, const Anope::string &message)
+bool Command::Run(CommandSource &source, const Anope::string &message)
{
std::vector<Anope::string> params;
spacesepstream(message).GetTokens(params);
@@ -294,7 +294,7 @@ void Command::Run(CommandSource &source, const Anope::string &message)
if (it == source.service->commands.end())
{
HandleUnknownCommand(source, message);
- return;
+ return false;
}
const CommandInfo &info = it->second;
@@ -303,7 +303,7 @@ void Command::Run(CommandSource &source, const Anope::string &message)
{
HandleUnknownCommand(source, message);
Log(source.service) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!";
- return;
+ return false;
}
for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i)
@@ -315,13 +315,13 @@ void Command::Run(CommandSource &source, const Anope::string &message)
params.erase(params.begin() + c->max_params);
}
- c->Run(source, it->first, info, params);
+ return c->Run(source, it->first, info, params);
}
-void Command::Run(CommandSource &source, const Anope::string &cmdname, const CommandInfo &info, std::vector<Anope::string> &params)
+bool Command::Run(CommandSource &source, const Anope::string &cmdname, const CommandInfo &info, std::vector<Anope::string> &params)
{
if (this->RequireUser() && !source.GetUser())
- return;
+ return false;
// Command requires registered users only
if (!this->AllowUnregistered() && !source.nc)
@@ -329,7 +329,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
source.Reply(NICK_IDENTIFY_REQUIRED);
if (source.GetUser())
Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname;
- return;
+ return false;
}
source.command = cmdname;
@@ -338,12 +338,12 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
EventReturn MOD_RESULT;
FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, this, params));
if (MOD_RESULT == EVENT_STOP)
- return;
+ return false;
if (params.size() < this->min_params)
{
this->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : "");
- return;
+ return false;
}
// If the command requires a permission, and they aren't registered or don't have the required perm, DENIED
@@ -352,11 +352,12 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
source.Reply(ACCESS_DENIED);
if (source.GetUser())
Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname;
- return;
+ return false;
}
this->Execute(source, params);
FOREACH_MOD(OnPostCommand, (source, this, params));
+ return true;
}
bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo *&bot, Anope::string &name)