From 22a1924bfd9713f0ec4fa9d646f5a0e7045db8c4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Mar 2026 05:44:48 +0000 Subject: [PATCH] Allow Command::FindCommandFromService to skip hidden commands. --- include/commands.h | 2 +- modules/chanserv/cs_access.cpp | 2 +- modules/chanserv/cs_list.cpp | 2 +- modules/chanserv/cs_register.cpp | 2 +- modules/chanserv/cs_xop.cpp | 4 ++-- modules/hostserv/hs_request.cpp | 2 +- modules/memoserv/ms_read.cpp | 2 +- src/command.cpp | 11 +++++++---- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/commands.h b/include/commands.h index cf71ed664..f35847c3c 100644 --- a/include/commands.h +++ b/include/commands.h @@ -189,5 +189,5 @@ public: * @param name If found, is set to the command name, eg REGISTER * @return true if the given command service exists */ - static bool FindCommandFromService(const Anope::string &command_service, BotInfo *&bi, Anope::string &name); + static bool FindFromService(const Anope::string &command_service, BotInfo *&bi, Anope::string &name); }; diff --git a/modules/chanserv/cs_access.cpp b/modules/chanserv/cs_access.cpp index abd8c834b..3a603caa3 100644 --- a/modules/chanserv/cs_access.cpp +++ b/modules/chanserv/cs_access.cpp @@ -671,7 +671,7 @@ public: BotInfo *bi; Anope::string cmd; - if (Command::FindCommandFromService("chanserv/levels", bi, cmd)) + if (Command::FindFromService("chanserv/levels", bi, cmd)) { source.Reply(" "); source.Reply(_( diff --git a/modules/chanserv/cs_list.cpp b/modules/chanserv/cs_list.cpp index 838ac98bb..07a5e1334 100644 --- a/modules/chanserv/cs_list.cpp +++ b/modules/chanserv/cs_list.cpp @@ -245,7 +245,7 @@ public: BotInfo *bi; Anope::string cmd; - if (Command::FindCommandFromService("chanserv/list", bi, cmd)) + if (Command::FindFromService("chanserv/list", bi, cmd)) { source.Reply(_("When \002private\002 is set, the channel will not appear in %s's %s command."), bi->nick.c_str(), cmd.c_str()); diff --git a/modules/chanserv/cs_register.cpp b/modules/chanserv/cs_register.cpp index 797197b02..0c66a36d5 100644 --- a/modules/chanserv/cs_register.cpp +++ b/modules/chanserv/cs_register.cpp @@ -105,7 +105,7 @@ public: BotInfo *bi; Anope::string cmd; - if (Command::FindCommandFromService("chanserv/access", bi, cmd)) + if (Command::FindFromService("chanserv/access", bi, cmd)) { source.Reply(" "); source.Reply(_( diff --git a/modules/chanserv/cs_xop.cpp b/modules/chanserv/cs_xop.cpp index 760aa8308..70db3d43f 100644 --- a/modules/chanserv/cs_xop.cpp +++ b/modules/chanserv/cs_xop.cpp @@ -636,8 +636,8 @@ public: BotInfo *access_bi, *flags_bi; Anope::string access_cmd, flags_cmd; - Command::FindCommandFromService("chanserv/access", access_bi, access_cmd); - Command::FindCommandFromService("chanserv/flags", flags_bi, flags_cmd); + Command::FindFromService("chanserv/access", access_bi, access_cmd); + Command::FindFromService("chanserv/flags", flags_bi, flags_cmd); if (!access_cmd.empty() || !flags_cmd.empty()) { source.Reply(_("Alternative methods of modifying channel access lists are available.")); diff --git a/modules/hostserv/hs_request.cpp b/modules/hostserv/hs_request.cpp index e9c613e8f..9c95cc664 100644 --- a/modules/hostserv/hs_request.cpp +++ b/modules/hostserv/hs_request.cpp @@ -285,7 +285,7 @@ public: BotInfo *bi; Anope::string cmd; - if (dnsmanager && Command::FindCommandFromService("hostserv/validate", bi, cmd)) + if (dnsmanager && Command::FindFromService("hostserv/validate", bi, cmd)) { source.Reply(_( "Your vhost \002%s\002 has been requested. If the requested vhost is for a valid " diff --git a/modules/memoserv/ms_read.cpp b/modules/memoserv/ms_read.cpp index 9a3be556b..ca047645c 100644 --- a/modules/memoserv/ms_read.cpp +++ b/modules/memoserv/ms_read.cpp @@ -90,7 +90,7 @@ public: BotInfo *bi; Anope::string cmd; - if (Command::FindCommandFromService("memoserv/del", bi, cmd)) + if (Command::FindFromService("memoserv/del", bi, cmd)) { if (ci) source.Reply(_("To delete, type: \002%s %s %d\002"), bi->GetQueryCommand({}, cmd).c_str(), ci->name.c_str(), index + 1); diff --git a/src/command.cpp b/src/command.cpp index 1bec86905..ebcaccb9a 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -364,9 +364,10 @@ bool Command::Run(CommandSource &source, const Anope::string &cmdname, const Com return true; } -bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo *&bot, Anope::string &name) +bool Command::FindFromService(const Anope::string &command_service, BotInfo *&bot, Anope::string &name) { - bot = NULL; + bot = nullptr; + name.clear(); for (const auto &[_, bi] : *BotListByNick) { @@ -377,9 +378,11 @@ bool Command::FindCommandFromService(const Anope::string &command_service, BotIn bot = bi; name = c_name; - return true; + + if (!info.hide) + return true; } } - return false; + return name.empty(); }