diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-07 01:14:12 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-07 01:14:12 +0000 |
commit | a8be208da166d092ecfd094be6068413905e6c1a (patch) | |
tree | 6913b76dd1b23a4b8fcf627eb371638da2f1e640 | |
parent | abbb602463f05c77e695f15d63a323eddc242f7d (diff) |
Add some options to botserv/botlist to make admining easier.
-rw-r--r-- | language/anope.en_US.po | 11 | ||||
-rw-r--r-- | modules/botserv/bs_botlist.cpp | 41 |
2 files changed, 46 insertions, 6 deletions
diff --git a/language/anope.en_US.po b/language/anope.en_US.po index 6084b017f..24e668919 100644 --- a/language/anope.en_US.po +++ b/language/anope.en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Anope\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-12 17:11+0000\n" +"POT-Creation-Date: 2025-02-07 01:13+0000\n" "PO-Revision-Date: 2024-11-25 01:32+0000\n" "Last-Translator: Sadie Powell <sadie@witchery.services>\n" "Language-Team: English\n" @@ -3764,7 +3764,14 @@ msgstr "" msgid "" "Lists all available bots on this network.\n" -"Bots prefixed by a * are reserved for IRC Operators." +"\n" +"If the OPERONLY, UNUSED or VANITY options are given only\n" +"bots which, respectively, are oper-only, unused or were\n" +"added at runtime will be displayed. If multiple options are\n" +"given, all nicks matching at least one option will be\n" +"displayed.\n" +"\n" +"Note that these options are limited to Services Operators." msgstr "" msgid "Lists all channel records" diff --git a/modules/botserv/bs_botlist.cpp b/modules/botserv/bs_botlist.cpp index 8ad7dd9c9..dbb92a999 100644 --- a/modules/botserv/bs_botlist.cpp +++ b/modules/botserv/bs_botlist.cpp @@ -15,13 +15,32 @@ class CommandBSBotList final : public Command { public: - CommandBSBotList(Module *creator) : Command(creator, "botserv/botlist", 0, 0) + CommandBSBotList(Module *creator) : Command(creator, "botserv/botlist", 0, 1) { this->SetDesc(_("Lists available bots")); + this->SetSyntax("[OPERONLY] [UNUSED] [VANITY]"); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { + const bool is_admin = source.HasCommand("botserv/administration"); + auto operonly = false; + auto unused = false; + auto vanity = false; + if (is_admin && !params.empty()) + { + spacesepstream keywords(params[0]); + for (Anope::string keyword; keywords.GetToken(keyword); ) + { + if (keyword.equals_ci("OPERONLY")) + operonly = true; + if (keyword.equals_ci("UNUSED")) + unused = true; + if (keyword.equals_ci("VANITY")) + vanity = true; + } + } + unsigned count = 0; ListFormatter list(source.GetAccount()); @@ -29,11 +48,18 @@ public: for (const auto &[_, bi] : *BotListByNick) { - if (source.HasPriv("botserv/administration") || !bi->oper_only) + if (is_admin || !bi->oper_only) { + if (operonly && !bi->oper_only) + continue; + if (unused && bi->GetChannelCount()) + continue; + if (vanity && bi->conf) + continue; + ++count; ListFormatter::ListEntry entry; - entry["Nick"] = (bi->oper_only ? "* " : "") + bi->nick; + entry["Nick"] = bi->nick; entry["Mask"] = bi->GetIdent() + "@" + bi->host; entry["Real name"] = bi->realname; list.AddEntry(entry); @@ -62,7 +88,14 @@ public: this->SendSyntax(source); source.Reply(" "); source.Reply(_("Lists all available bots on this network.\n" - "Bots prefixed by a * are reserved for IRC Operators.")); + "\n" + "If the OPERONLY, UNUSED or VANITY options are given only\n" + "bots which, respectively, are oper-only, unused or were\n" + "added at runtime will be displayed. If multiple options are\n" + "given, all nicks matching at least one option will be\n" + "displayed.\n" + "\n" + "Note that these options are limited to \037Services Operators\037.")); return true; } }; |