1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 20:23:11 +02:00

Show the default levels in LEVELS DESC.

Closes #564.
This commit is contained in:
Sadie Powell
2026-03-10 23:28:54 +00:00
parent 12545ccbde
commit fa5bb3f1bf
2 changed files with 21 additions and 13 deletions
+15 -10
View File
@@ -23,6 +23,17 @@ static inline void reset_levels(ChannelInfo *ci)
ci->SetLevel(priv, level);
}
static Anope::string LevelToString(CommandSource &source, int16_t level)
{
if (level == ACCESS_INVALID)
return Language::Translate(source.GetAccount(), _("(disabled)"));
if (level == ACCESS_FOUNDER)
return Language::Translate(source.GetAccount(), _("(founder only)"));
return Anope::ToString(level);
}
class AccessChanAccess final
: public ChanAccess
{
@@ -768,14 +779,7 @@ class CommandCSLevels final
ListFormatter::ListEntry entry;
entry["Name"] = p.name;
if (j == ACCESS_INVALID)
entry["Level"] = Language::Translate(source.GetAccount(), _("(disabled)"));
else if (j == ACCESS_FOUNDER)
entry["Level"] = Language::Translate(source.GetAccount(), _("(founder only)"));
else
entry["Level"] = Anope::ToString(j);
entry["Level"] = LevelToString(source, j);
list.AddEntry(entry);
}
@@ -852,13 +856,14 @@ public:
source.Reply(_("The following feature/function names are available:"));
ListFormatter list(source.GetAccount());
list.AddColumn(_("Name")).AddColumn(_("Description"));
list.SetFlexible(_("\002{name}\002: {description}"));
list.AddColumn(_("Name")).AddColumn(_("Default")).AddColumn(_("Description"));
list.SetFlexible(_("\002{name}\002: defaults to {default} ({description})"));
for (const auto &p : PrivilegeManager::GetPrivileges())
{
ListFormatter::ListEntry entry;
entry["Name"] = p.name;
entry["Default"] = LevelToString(source, defaultLevels[p.name]);
entry["Description"] = Language::Translate(source.nc, p.desc.c_str());
list.AddEntry(entry);
}