1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 13:36:38 +02:00

Expand GetQueryCommand to take a command name.

This commit is contained in:
Sadie Powell
2025-04-09 18:17:02 +01:00
parent 40d558ef21
commit 9351debd73
22 changed files with 144 additions and 97 deletions
+1 -1
View File
@@ -139,7 +139,7 @@ public:
CommandInfo *GetCommand(const Anope::string &cname);
/** Get the command that users can use to send a message to this bot. */
Anope::string GetQueryCommand() const;
Anope::string GetQueryCommand(const Anope::string &command = "", const Anope::string &extra = "") const;
/** Find a bot by nick
* @param nick The nick
+1 -1
View File
@@ -150,7 +150,7 @@ public:
*/
virtual void Execute(CommandSource &source, const std::vector<Anope::string> &params) = 0;
/** Called when HELP is requested for the client this command is on.
/** Called when help is requested for the client this command is on.
* @param source The source
*/
virtual void OnServHelp(CommandSource &source);
+5 -5
View File
@@ -100,9 +100,9 @@ namespace Language
} // namespace Language
/* Commonly used language strings */
#define CONFIRM_DROP _("Please confirm that you want to drop \002%s\002 with \002%s DROP %s %s\002")
#define CONFIRM_DROP _("Please confirm that you want to drop \002%s\002 with \002%s %s %s\002")
#define SERVICE_UNAVAILABLE _("Sorry, %s is temporarily unavailable.")
#define MORE_INFO _("\002%s HELP %s\002 for more information.")
#define MORE_INFO _("\002%s\002 for more information.")
#define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
#define BAD_EXPIRY_TIME _("Invalid expiry time.")
#define USERHOST_MASK_TOO_WIDE _("%s coverage is too wide; Please use a more specific mask.")
@@ -128,7 +128,7 @@ namespace Language
#define NO_EXPIRE _("does not expire")
#define LIST_INCORRECT_RANGE _("Incorrect range specified. The correct syntax is \002#\037from\037-\037to\037\002.")
#define NICK_IS_SECURE _("This nickname is registered and protected. If it is your\n" \
"nick, type \002%s IDENTIFY \037password\037\002. Otherwise,\n" \
"nick, type \002%s \037password\037\002. Otherwise,\n" \
"please choose a different nick.")
#define FORCENICKCHANGE_NOW _("This nickname has been registered; you may not use it.")
#define NICK_CANNOT_BE_REGISTERED _("Nickname \002%s\002 may not be registered.")
@@ -146,9 +146,9 @@ namespace Language
#define CHAN_INFO_HEADER _("Information about channel \002%s\002:")
#define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except has been removed.")
#define MEMO_NEW_X_MEMO_ARRIVED _("There is a new memo on channel %s.\n" \
"Type \002%s READ %s %zu\002 to read it.")
"Type \002%s %s %zu\002 to read it.")
#define MEMO_NEW_MEMO_ARRIVED _("You have a new memo from %s.\n" \
"Type \002%s READ %zu\002 to read it.")
"Type \002%s %zu\002 to read it.")
#define MEMO_HAVE_NO_MEMOS _("You have no memos.")
#define MEMO_X_HAS_NO_MEMOS _("%s has no memos.")
#define MEMO_HAVE_NO_NEW_MEMOS _("You have no new memos.")
+35 -35
View File
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Anope\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-22 21:04+0000\n"
"PO-Revision-Date: 2025-03-08 13:33+0000\n"
"POT-Creation-Date: 2025-04-10 13:32+0100\n"
"PO-Revision-Date: 2025-04-10 13:32+0100\n"
"Last-Translator: Sadie Powell <sadie@witchery.services>\n"
"Language-Team: English\n"
"Language: en_US\n"
@@ -81,7 +81,7 @@ msgid ""
"allow user bots. Available commands are listed\n"
"below; to use them, type %s command. For\n"
"more information on a specific command, type\n"
"%s %s command.\n"
"%s command.\n"
msgstr ""
#, c-format
@@ -91,7 +91,7 @@ msgid ""
"commands allow for registration and maintenance of\n"
"nicknames; to use them, type %s command.\n"
"For more information on a specific command, type\n"
"%s %s command.\n"
"%s command.\n"
msgstr ""
#, c-format
@@ -100,7 +100,7 @@ msgid ""
"The following commands allow for registration and maintenance of\n"
"accounts; to use them, type %s command.\n"
"For more information on a specific command, type\n"
"%s %s command.\n"
"%s command.\n"
msgstr ""
#, c-format
@@ -111,7 +111,7 @@ msgid ""
"who is allowed channel operator privileges. Available\n"
"commands are listed below; to use them, type\n"
"%s command. For more information on a\n"
"specific command, type %s HELP command.\n"
"specific command, type %s command.\n"
msgstr ""
#, c-format
@@ -178,6 +178,10 @@ msgstr ""
msgid "%s does not wish to be added to channel access lists."
msgstr ""
#, c-format
msgid "%s for more information."
msgstr ""
#, c-format
msgid "%s has been invited to %s."
msgstr ""
@@ -352,10 +356,6 @@ msgstr ""
msgid "%s will now permanently be ignored."
msgstr ""
#, c-format
msgid "%s HELP %s for more information."
msgstr ""
msgid "ADD nick user host real"
msgstr ""
@@ -399,7 +399,7 @@ msgstr ""
#, c-format
msgid ""
"User access levels can be seen by using the\n"
"%s command; type %s HELP LEVELS for\n"
"%s command; type %s LEVELS for\n"
"information."
msgstr ""
@@ -824,7 +824,7 @@ msgstr ""
#, c-format
msgid ""
" \n"
"See the %s command (%s HELP ACCESS) for\n"
"See the %s command (%s ACCESS) for\n"
"information on giving a subset of these privileges to\n"
"other channel users.\n"
msgstr ""
@@ -978,7 +978,7 @@ msgstr ""
#, c-format
msgid ""
" \n"
"Type %s HELP command for help on any of the\n"
"Type %s command for help on any of the\n"
"above commands."
msgstr ""
@@ -4019,7 +4019,7 @@ msgid ""
"Maintains the bad words list for a channel. The bad\n"
"words list determines which words are to be kicked\n"
"when the bad words kicker is enabled. For more information,\n"
"type %s HELP KICK %s.\n"
"type %s KICK %s.\n"
" \n"
"The ADD command adds the given word to the\n"
"bad words list. If SINGLE is specified, a kick will be\n"
@@ -4616,7 +4616,7 @@ msgid "Persistent"
msgstr ""
#, c-format
msgid "Please confirm that you want to drop %s with %s DROP %s %s"
msgid "Please confirm that you want to drop %s with %s %s %s"
msgstr ""
msgid "Please contact an Operator to get a vhost assigned to this nick."
@@ -5056,13 +5056,13 @@ msgstr ""
#, c-format
msgid ""
"See %s HELP %s for more information\n"
"See %s for more information\n"
"about the access list."
msgstr ""
#, c-format
msgid ""
"See %s HELP %s for more information\n"
"See %s for more information\n"
"about the flags system."
msgstr ""
@@ -5347,7 +5347,7 @@ msgid ""
"option tells the bot to kick users who say certain words\n"
"on the channels.\n"
"You can define bad words for your channel using the\n"
"BADWORDS command. Type %s HELP BADWORDS for\n"
"BADWORDS command. Type %s BADWORDS for\n"
"more information.\n"
" \n"
"ttb is the number of times a user can be kicked\n"
@@ -5489,7 +5489,7 @@ msgid ""
" LIMIT Sets the maximum number of memos you can\n"
" receive\n"
" \n"
"Type %s HELP %s option for more information\n"
"Type %s option for more information\n"
"on a specific option."
msgstr ""
@@ -5533,7 +5533,7 @@ msgid ""
msgstr ""
#, c-format
msgid "Setting %s not known. Type %s HELP LEVELS for a list of valid settings."
msgid "Setting %s not known. Type %s LEVELS for a list of valid settings."
msgstr ""
msgid "Setting for DEBUG must be ON, OFF, or a positive number."
@@ -6202,7 +6202,7 @@ msgstr ""
#, c-format
msgid ""
"There is a new memo on channel %s.\n"
"Type %s READ %s %zu to read it."
"Type %s %s %zu to read it."
msgstr ""
#, c-format
@@ -6409,16 +6409,16 @@ msgstr ""
#, c-format
msgid ""
"This nickname is registered and protected. If it is your\n"
"nick, type %s IDENTIFY password. Otherwise,\n"
"nick, type %s password. Otherwise,\n"
"please choose a different nick."
msgstr ""
#, c-format
msgid "To delete, type: %s %s %d"
msgid "To delete, type: %s %d"
msgstr ""
#, c-format
msgid "To delete, type: %s %s %s %d"
msgid "To delete, type: %s %s %d"
msgstr ""
msgid "To protect ops against bot kicks"
@@ -6520,15 +6520,19 @@ msgstr ""
msgid "Type"
msgstr ""
#, c-format
msgid "Type %s email in order to set your email."
msgstr ""
#, c-format
msgid ""
"Type %s HELP %s option for more information\n"
"Type %s option for more information\n"
"on a specific option."
msgstr ""
#, c-format
msgid ""
"Type %s HELP %s option for more information\n"
"Type %s option for more information\n"
"on a specific option.\n"
" \n"
"Note: access to this command is controlled by the\n"
@@ -6537,21 +6541,17 @@ msgstr ""
#, c-format
msgid ""
"Type %s HELP %s option for more information\n"
"Type %s option for more information\n"
"on a specific option. The options will be set on the given\n"
"nickname."
msgstr ""
#, c-format
msgid ""
"Type %s HELP %s option for more information on a\n"
"Type %s option for more information on a\n"
"particular option."
msgstr ""
#, c-format
msgid "Type %s SET EMAIL email in order to set your email."
msgstr ""
msgid "Un-Load a module"
msgstr ""
@@ -6593,7 +6593,7 @@ msgid "Unknown command %s."
msgstr ""
#, c-format
msgid "Unknown command %s. \"%s HELP\" for help."
msgid "Unknown command %s. \"%s\" for help."
msgstr ""
#, c-format
@@ -6601,7 +6601,7 @@ msgid "Unknown command %s. Did you mean %s?"
msgstr ""
#, c-format
msgid "Unknown command %s. Did you mean %s? \"%s HELP\" for help."
msgid "Unknown command %s. Did you mean %s? \"%s\" for help."
msgstr ""
#, c-format
@@ -6971,7 +6971,7 @@ msgstr[1] ""
#, c-format
msgid ""
"You have a new memo from %s.\n"
"Type %s READ %zu to read it."
"Type %s %zu to read it."
msgstr ""
#, c-format
+2 -2
View File
@@ -155,9 +155,9 @@ public:
"allow user bots. Available commands are listed\n"
"below; to use them, type \002%s \037command\037\002. For\n"
"more information on a specific command, type\n"
"\002%s %s \037command\037\002.\n"),
"\002%s \037command\037\002.\n"),
BotServ->nick.c_str(), BotServ->GetQueryCommand().c_str(),
BotServ->GetQueryCommand().c_str(), source.command.c_str());
BotServ->GetQueryCommand({}, source.command).c_str());
}
return EVENT_CONTINUE;
+3 -2
View File
@@ -438,7 +438,7 @@ public:
source.Reply(_("Maintains the \002bad words list\002 for a channel. The bad\n"
"words list determines which words are to be kicked\n"
"when the bad words kicker is enabled. For more information,\n"
"type \002%s HELP KICK %s\002.\n"
"type \002%s KICK %s\002.\n"
" \n"
"The \002ADD\002 command adds the given word to the\n"
"bad words list. If SINGLE is specified, a kick will be\n"
@@ -448,7 +448,8 @@ public:
"will be done if a user says a word that ends with\n"
"\037word\037. If you don't specify anything, a kick will\n"
"be issued every time \037word\037 is said by a user.\n"
" \n"), source.service->GetQueryCommand().c_str(), source.command.c_str());
" \n"), source.service->GetQueryCommand("generic/help").c_str(), source.command.c_str());
source.Reply(_("The \002DEL\002 command removes the given word from the\n"
"bad words list. If a list of entry numbers is given, those\n"
"entries are deleted. (See the example for LIST below.)\n"
+6 -4
View File
@@ -153,11 +153,12 @@ public:
}
}
source.Reply(_("Type \002%s HELP %s \037option\037\002 for more information\n"
source.Reply(_("Type \002%s \037option\037\002 for more information\n"
"on a specific option.\n"
" \n"
"Note: access to this command is controlled by the\n"
"level SET."), source.service->GetQueryCommand().c_str(), this_name.c_str());
"level SET."),
source.service->GetQueryCommand("generic/help", this_name).c_str());
return true;
}
@@ -308,12 +309,13 @@ public:
"option tells the bot to kick users who say certain words\n"
"on the channels.\n"
"You can define bad words for your channel using the\n"
"\002BADWORDS\002 command. Type \002%s HELP BADWORDS\002 for\n"
"\002BADWORDS\002 command. Type \002%s BADWORDS\002 for\n"
"more information.\n"
" \n"
"\037ttb\037 is the number of times a user can be kicked\n"
"before it gets banned. Don't give ttb to disable\n"
"the ban system once activated."), source.service->GetQueryCommand().c_str());
"the ban system once activated."),
source.service->GetQueryCommand("generic/help").c_str());
return true;
}
};
+3 -2
View File
@@ -58,8 +58,9 @@ public:
}
}
}
source.Reply(_("Type \002%s HELP %s \037option\037\002 for more information on a\n"
"particular option."), source.service->GetQueryCommand().c_str(), this_name.c_str());
source.Reply(_("Type \002%s \037option\037\002 for more information on a\n"
"particular option."),
source.service->GetQueryCommand("generic/help", this_name).c_str());
return true;
}
+3 -2
View File
@@ -266,8 +266,9 @@ public:
"who is allowed channel operator privileges. Available\n"
"commands are listed below; to use them, type\n"
"\002%s \037command\037\002. For more information on a\n"
"specific command, type \002%s HELP \037command\037\002.\n"),
ChanServ->nick.c_str(), ChanServ->nick.c_str(), ChanServ->GetQueryCommand().c_str(), ChanServ->GetQueryCommand().c_str());
"specific command, type \002%s \037command\037\002.\n"),
ChanServ->nick.c_str(), ChanServ->nick.c_str(),
ChanServ->GetQueryCommand().c_str(), ChanServ->GetQueryCommand("generic/help").c_str());
return EVENT_CONTINUE;
}
+9 -6
View File
@@ -625,9 +625,12 @@ public:
BotInfo *bi;
Anope::string cmd;
if (Command::FindCommandFromService("chanserv/levels", bi, cmd))
{
source.Reply(_("\002User access levels\002 can be seen by using the\n"
"\002%s\002 command; type \002%s HELP LEVELS\002 for\n"
"information."), cmd.c_str(), bi->GetQueryCommand().c_str());
"\002%s\002 command; type \002%s LEVELS\002 for\n"
"information."),
cmd.c_str(), bi->GetQueryCommand("generic/help").c_str());
}
return true;
}
};
@@ -662,8 +665,8 @@ class CommandCSLevels final
Privilege *p = PrivilegeManager::FindPrivilege(what);
if (p == NULL)
{
source.Reply(_("Setting \002%s\002 not known. Type \002%s HELP LEVELS\002 for a list of valid settings."),
what.c_str(), source.service->GetQueryCommand().c_str());
source.Reply(_("Setting \002%s\002 not known. Type \002%s LEVELS\002 for a list of valid settings."),
what.c_str(), source.service->GetQueryCommand("generic/help").c_str());
}
else
{
@@ -705,8 +708,8 @@ class CommandCSLevels final
return;
}
source.Reply(_("Setting \002%s\002 not known. Type \002%s HELP LEVELS\002 for a list of valid settings."),
what.c_str(), source.service->GetQueryCommand().c_str());
source.Reply(_("Setting \002%s\002 not known. Type \002%s LEVELS\002 for a list of valid settings."),
what.c_str(), source.service->GetQueryCommand("generic/help").c_str());
}
static void DoList(CommandSource &source, ChannelInfo *ci)
+1 -1
View File
@@ -58,7 +58,7 @@ public:
*code = Anope::Random(Config->GetBlock("options").Get<size_t>("codelength", 15));
}
source.Reply(CONFIRM_DROP, ci->name.c_str(), source.service->GetQueryCommand().c_str(),
source.Reply(CONFIRM_DROP, ci->name.c_str(), source.service->GetQueryCommand("chanserv/drop").c_str(),
ci->name.c_str(), code->c_str());
return;
}
+3 -2
View File
@@ -100,9 +100,10 @@ public:
Anope::string cmd;
if (Command::FindCommandFromService("chanserv/access", bi, cmd))
source.Reply(_(" \n"
"See the \002%s\002 command (\002%s HELP ACCESS\002) for\n"
"See the \002%s\002 command (\002%s ACCESS\002) for\n"
"information on giving a subset of these privileges to\n"
"other channel users.\n"), cmd.c_str(), bi->GetQueryCommand().c_str());
"other channel users.\n"),
cmd.c_str(), bi->GetQueryCommand("generic/help").c_str());
source.Reply(_(" \n"
"NOTICE: In order to register a channel, you must have\n"
"first registered your nickname."));
+3 -2
View File
@@ -59,8 +59,9 @@ public:
c->OnServHelp(source);
}
}
source.Reply(_("Type \002%s HELP %s \037option\037\002 for more information on a\n"
"particular option."), source.service->GetQueryCommand().c_str(), this_name.c_str());
source.Reply(_("Type \002%s \037option\037\002 for more information on a\n"
"particular option."),
source.service->GetQueryCommand("generic/help", this_name).c_str());
return true;
}
};
+4 -4
View File
@@ -590,11 +590,11 @@ public:
source.Reply(_("Alternative methods of modifying channel access lists are\n"
"available."));
if (!access_cmd.empty())
source.Reply(_("See \002%s HELP %s\002 for more information\n"
"about the access list."), access_bi->GetQueryCommand().c_str(), access_cmd.c_str());
source.Reply(_("See \002%s\002 for more information\n"
"about the access list."), access_bi->GetQueryCommand("generic/help", access_cmd).c_str());
if (!flags_cmd.empty())
source.Reply(_("See \002%s HELP %s\002 for more information\n"
"about the flags system."), flags_bi->GetQueryCommand().c_str(), flags_cmd.c_str());
source.Reply(_("See \002%s\002 for more information\n"
"about the flags system."), flags_bi->GetQueryCommand("generic/help", flags_cmd).c_str());
}
return true;
}
+8 -4
View File
@@ -101,7 +101,10 @@ public:
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
if (cu->user->IsIdentified() && cu->user->Account()->HasExt("MEMO_RECEIVE"))
cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), MemoServ->GetQueryCommand().c_str(), ci->name.c_str(), mi->memos->size());
{
cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), MemoServ->GetQueryCommand("memoserv/read").c_str(),
ci->name.c_str(), mi->memos->size());
}
}
}
}
@@ -116,7 +119,7 @@ public:
{
User *user = User::Find(na->nick, true);
if (user && user->IsIdentified())
user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), MemoServ->GetQueryCommand().c_str(), mi->memos->size());
user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), MemoServ->GetQueryCommand("memoserv/read").c_str(), mi->memos->size());
}
}
@@ -229,8 +232,9 @@ public:
if (!params.empty() || source.c || source.service != *MemoServ)
return;
source.Reply(_(" \n"
"Type \002%s HELP \037command\037\002 for help on any of the\n"
"above commands."), MemoServ->GetQueryCommand().c_str());
"Type \002%s \037command\037\002 for help on any of the\n"
"above commands."),
MemoServ->GetQueryCommand("generic/help").c_str());
}
};
+2 -2
View File
@@ -91,9 +91,9 @@ public:
if (Command::FindCommandFromService("memoserv/del", bi, cmd))
{
if (ci)
source.Reply(_("To delete, type: \002%s %s %s %d\002"), bi->GetQueryCommand().c_str(), cmd.c_str(), ci->name.c_str(), index + 1);
source.Reply(_("To delete, type: \002%s %s %d\002"), bi->GetQueryCommand({}, cmd).c_str(), ci->name.c_str(), index + 1);
else
source.Reply(_("To delete, type: \002%s %s %d\002"), bi->GetQueryCommand().c_str(), cmd.c_str(), index + 1);
source.Reply(_("To delete, type: \002%s %d\002"), bi->GetQueryCommand({}, cmd).c_str(), index + 1);
}
source.Reply("%s", m->text.c_str());
+3 -2
View File
@@ -232,8 +232,9 @@ public:
" LIMIT Sets the maximum number of memos you can\n"
" receive\n"
" \n"
"Type \002%s HELP %s \037option\037\002 for more information\n"
"on a specific option."), source.service->GetQueryCommand().c_str(), source.command.c_str());
"Type \002%s \037option\037\002 for more information\n"
"on a specific option."),
source.service->GetQueryCommand("generic/help", source.command).c_str());
}
else if (subcommand.equals_ci("NOTIFY"))
source.Reply(_("Syntax: \002NOTIFY {ON | LOGON | NEW | MAIL | NOMAIL | OFF}\002\n"
+6 -5
View File
@@ -221,7 +221,7 @@ public:
if (protect)
{
u->SendMessage(NickServ, NICK_IS_SECURE, NickServ->GetQueryCommand().c_str());
u->SendMessage(NickServ, NICK_IS_SECURE, NickServ->GetQueryCommand("nickserv/identify").c_str());
u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."),
Anope::Duration(protect, u->Account()).c_str());
new NickServCollide(this, this, u, na, protect);
@@ -393,8 +393,8 @@ public:
u->SendMessage(NickServ, _("You must now supply an email for your nick.\n"
"This email will allow you to retrieve your password in\n"
"case you forget it."));
u->SendMessage(NickServ, _("Type \002%s SET EMAIL \037email\037\002 in order to set your email."),
NickServ->GetQueryCommand().c_str());
u->SendMessage(NickServ, _("Type \002%s \037email\037\002 in order to set your email."),
NickServ->GetQueryCommand("nickserv/set/email").c_str());
}
for (auto *c : collides)
@@ -498,13 +498,14 @@ public:
"commands allow for registration and maintenance of\n"
"nicknames; to use them, type \002%s \037command\037\002.\n"
"For more information on a specific command, type\n"
"\002%s %s \037command\037\002.\n"), NickServ->nick.c_str(), NickServ->GetQueryCommand().c_str(), NickServ->GetQueryCommand().c_str(), source.command.c_str());
"\002%s \037command\037\002.\n"), NickServ->nick.c_str(), NickServ->GetQueryCommand().c_str(), NickServ->GetQueryCommand({}, source.command).c_str());
else
source.Reply(_("\002%s\002 allows you to register an account.\n"
"The following commands allow for registration and maintenance of\n"
"accounts; to use them, type \002%s \037command\037\002.\n"
"For more information on a specific command, type\n"
"\002%s %s \037command\037\002.\n"), NickServ->nick.c_str(), NickServ->GetQueryCommand().c_str(), NickServ->GetQueryCommand().c_str(), source.command.c_str());
"\002%s \037command\037\002.\n"),
NickServ->nick.c_str(), NickServ->GetQueryCommand().c_str(), NickServ->GetQueryCommand({}, source.command.c_str()).c_str());
return EVENT_CONTINUE;
}
+1 -1
View File
@@ -72,7 +72,7 @@ public:
*code = Anope::Random(Config->GetBlock("options").Get<size_t>("codelength", 15));
}
source.Reply(CONFIRM_DROP, na->nick.c_str(), source.service->GetQueryCommand().c_str(),
source.Reply(CONFIRM_DROP, na->nick.c_str(), source.service->GetQueryCommand("nickserv/drop").c_str(),
na->nick.c_str(), code->c_str());
return;
}
+6 -4
View File
@@ -57,8 +57,9 @@ public:
}
}
source.Reply(_("Type \002%s HELP %s \037option\037\002 for more information\n"
"on a specific option."), source.service->GetQueryCommand().c_str(), this_name.c_str());
source.Reply(_("Type \002%s \037option\037\002 for more information\n"
"on a specific option."),
source.service->GetQueryCommand("generic/help", this_name).c_str());
return true;
}
@@ -100,9 +101,10 @@ public:
}
}
source.Reply(_("Type \002%s HELP %s \037option\037\002 for more information\n"
source.Reply(_("Type \002%s \037option\037\002 for more information\n"
"on a specific option. The options will be set on the given\n"
"\037nickname\037."), source.service->GetQueryCommand().c_str(), this_name.c_str());
"\037nickname\037."),
source.service->GetQueryCommand("generic/help", this_name).c_str());
return true;
}
};
+27 -3
View File
@@ -271,11 +271,35 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname)
return NULL;
}
Anope::string BotInfo::GetQueryCommand() const
Anope::string BotInfo::GetQueryCommand(const Anope::string &command, const Anope::string &extra) const
{
Anope::string buf;
if (Config->ServiceAlias && !this->alias.empty())
return Anope::printf("/%s", this->alias.c_str());
return Anope::printf("/msg %s", this->nick.c_str());
buf.append("/").append(this->alias);
else
buf.append("/msg ").append(this->nick);
if (!command.empty())
{
Anope::string actual_command = "\036(MISSING)\036";
for (const auto &[c_name, info] : this->commands)
{
if (info.name != command)
continue; // Wrong command.
actual_command = c_name;
if (!info.hide)
break; // Keep going to find a non-hidden alternative.
}
if (!actual_command.empty())
buf.append(" ").append(actual_command);
}
if (!extra.empty())
buf.append(" ").append(extra);
return buf;
}
BotInfo *BotInfo::Find(const Anope::string &nick, bool nick_only)
+12 -7
View File
@@ -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())
{