mirror of
https://github.com/anope/anope.git
synced 2026-06-25 19:56:39 +02:00
Expand GetQueryCommand to take a command name.
This commit is contained in:
+12
-7
@@ -212,9 +212,14 @@ bool Command::OnHelp(CommandSource &source, const Anope::string &subcommand) { r
|
||||
void Command::OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
bool has_help = source.service->commands.find("HELP") != source.service->commands.end();
|
||||
if (has_help)
|
||||
source.Reply(MORE_INFO, source.service->GetQueryCommand().c_str(), source.command.c_str());
|
||||
|
||||
auto it = std::find_if(source.service->commands.begin(), source.service->commands.end(), [](const auto &cmd)
|
||||
{
|
||||
// The help command may not be called HELP.
|
||||
return cmd.second.name == "generic/help";
|
||||
});
|
||||
if (it == source.service->commands.end())
|
||||
source.Reply(MORE_INFO, source.service->GetQueryCommand("generic/help", source.command).c_str());
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -241,13 +246,13 @@ namespace
|
||||
bool has_help = source.service->commands.find("HELP") != source.service->commands.end();
|
||||
if (has_help && similar.empty())
|
||||
{
|
||||
source.Reply(_("Unknown command \002%s\002. \"%s HELP\" for help."), message.c_str(),
|
||||
source.service->GetQueryCommand().c_str());
|
||||
source.Reply(_("Unknown command \002%s\002. \"%s\" for help."), message.c_str(),
|
||||
source.service->GetQueryCommand("generic/help").c_str());
|
||||
}
|
||||
else if (has_help)
|
||||
{
|
||||
source.Reply(_("Unknown command \002%s\002. Did you mean \002%s\002? \"%s HELP\" for help."),
|
||||
message.c_str(), similar.c_str(), source.service->GetQueryCommand().c_str());
|
||||
source.Reply(_("Unknown command \002%s\002. Did you mean \002%s\002? \"%s\" for help."),
|
||||
message.c_str(), similar.c_str(), source.service->GetQueryCommand("generic/help").c_str());
|
||||
}
|
||||
else if (similar.empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user