summaryrefslogtreecommitdiff
path: root/src/command.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-05-08 12:57:27 +0100
committerSadie Powell <sadie@witchery.services>2025-05-08 16:53:10 +0100
commit34582a40ef8f719c7cef45cb80855573b045feb9 (patch)
tree51aca4d4dff1b0dcfde36e0bda2215d6866a8567 /src/command.cpp
parent0b7b4aa42d07e6d492fea1657c5d73c26a0fd519 (diff)
Change Command::Run to return true on success.
Diffstat (limited to 'src/command.cpp')
-rw-r--r--src/command.cpp21
1 files changed, 11 insertions, 10 deletions
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)