1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 15:44:46 +02:00

Remove hard coded references to default access levels.

This commit is contained in:
Sadie Powell
2026-05-21 11:43:30 +01:00
parent 6d2c4fb612
commit 59c60849b6
10 changed files with 89 additions and 35 deletions
+3
View File
@@ -67,6 +67,9 @@ public:
*/ */
virtual ChanAccess *Create() = 0; virtual ChanAccess *Create() = 0;
virtual void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) = 0;
static void SendAccess(CommandSource &source, const Anope::string &pname);
private: private:
static std::list<AccessProvider *> Providers; static std::list<AccessProvider *> Providers;
public: public:
+20 -19
View File
@@ -16,8 +16,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Anope\n" "Project-Id-Version: Anope\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-05-20 17:40+0100\n" "POT-Creation-Date: 2026-05-21 11:52+0100\n"
"PO-Revision-Date: 2026-05-20 17:41+0100\n" "PO-Revision-Date: 2026-05-21 11:52+0100\n"
"Last-Translator: Sadie Powell <sadie@sadiepowell.dev>\n" "Last-Translator: Sadie Powell <sadie@sadiepowell.dev>\n"
"Language-Team: English\n" "Language-Team: English\n"
"Language: en_US\n" "Language: en_US\n"
@@ -25,7 +25,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.9\n" "X-Generator: Poedit 3.4.2\n"
#: ../modules/operserv/os_forbid.cpp #: ../modules/operserv/os_forbid.cpp
#, c-format #, c-format
@@ -2487,10 +2487,7 @@ msgid "Bans a given nick or mask on a channel"
msgstr "" msgstr ""
#: ../modules/chanserv/cs_ban.cpp #: ../modules/chanserv/cs_ban.cpp
msgid "" msgid "Bans a given nick or mask on a channel. An optional expiry may be given to cause services to remove the ban after a set amount of time. Channel founders may ban masks."
"Bans a given nick or mask on a channel. An optional expiry may be given to cause services to remove the ban after a set amount of time.\n"
"\n"
"By default, limited to AOPs or those with level 5 access and above on the channel. Channel founders may ban masks."
msgstr "" msgstr ""
#: ../modules/chanserv/cs_enforce.cpp #: ../modules/chanserv/cs_enforce.cpp
@@ -2683,6 +2680,11 @@ msgstr ""
msgid "Bot won't kick for repeats anymore." msgid "Bot won't kick for repeats anymore."
msgstr "" msgstr ""
#: ../src/access.cpp
#, c-format
msgid "By default, the %s command is limited to:"
msgstr ""
#: ../modules/operserv/os_info.cpp #: ../modules/operserv/os_info.cpp
msgid "CLEAR target" msgid "CLEAR target"
msgstr "" msgstr ""
@@ -4012,6 +4014,10 @@ msgstr ""
msgid "Fixed layout" msgid "Fixed layout"
msgstr "" msgstr ""
#: ../modules/chanserv/cs_flags.cpp
msgid "Flag"
msgstr ""
#: ../modules/chanserv/cs_flags.cpp #: ../modules/chanserv/cs_flags.cpp
msgid "Flags" msgid "Flags"
msgstr "" msgstr ""
@@ -4319,10 +4325,7 @@ msgid "Kicks a specified nick from a channel"
msgstr "" msgstr ""
#: ../modules/chanserv/cs_kick.cpp #: ../modules/chanserv/cs_kick.cpp
msgid "" msgid "Kicks a specified nick from a channel. Channel founders can also specify masks."
"Kicks a specified nick from a channel.\n"
"\n"
"By default, limited to AOPs or those with level 5 access and above on the channel. Channel founders can also specify masks."
msgstr "" msgstr ""
#: ../modules/operserv/os_kill.cpp #: ../modules/operserv/os_kill.cpp
@@ -6908,18 +6911,12 @@ msgstr ""
#: ../modules/chanserv/cs_invite.cpp #: ../modules/chanserv/cs_invite.cpp
#, c-format #, c-format
msgid "" msgid "Tells %s to invite you or an optionally specified nick into the given channel."
"Tells %s to invite you or an optionally specified nick into the given channel.\n"
"\n"
"By default, limited to AOPs or those with level 5 access and above on the channel."
msgstr "" msgstr ""
#: ../modules/chanserv/cs_unban.cpp #: ../modules/chanserv/cs_unban.cpp
#, c-format #, c-format
msgid "" msgid "Tells %s to remove all bans preventing you or the given user from entering the given channel. If no channel is given, all bans affecting you in channels you have access in are removed."
"Tells %s to remove all bans preventing you or the given user from entering the given channel. If no channel is given, all bans affecting you in channels you have access in are removed.\n"
"\n"
"By default, limited to AOPs or those with level 5 access and above on the channel."
msgstr "" msgstr ""
#: ../modules/operserv/os_jupe.cpp #: ../modules/operserv/os_jupe.cpp
@@ -8007,6 +8004,10 @@ msgstr ""
msgid "Word" msgid "Word"
msgstr "" msgstr ""
#: ../modules/chanserv/cs_xop.cpp
msgid "XOP"
msgstr ""
#: ../modules/nickserv/ns_group.cpp #: ../modules/nickserv/ns_group.cpp
#, c-format #, c-format
msgid "You are already a member of the account of %s." msgid "You are already a member of the account of %s."
+7
View File
@@ -92,6 +92,13 @@ public:
{ {
return new AccessChanAccess(this); return new AccessChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
auto it = defaultLevels.find(p->name);
if (it != defaultLevels.end())
access[_("Level")] = LevelToString(source, it->second);
}
}; };
AccessAccessProvider *AccessAccessProvider::me; AccessAccessProvider *AccessAccessProvider::me;
+5 -4
View File
@@ -272,11 +272,12 @@ public:
source.Reply(_( source.Reply(_(
"Bans a given nick or mask on a channel. An optional expiry may " "Bans a given nick or mask on a channel. An optional expiry may "
"be given to cause services to remove the ban after a set amount " "be given to cause services to remove the ban after a set amount "
"of time." "of time. Channel founders may ban masks."
"\n\n"
"By default, limited to AOPs or those with level 5 access "
"and above on the channel. Channel founders may ban masks."
)); ));
source.Reply(" ");
AccessProvider::SendAccess(source, "BAN");
return true; return true;
} }
}; };
+7
View File
@@ -84,6 +84,13 @@ public:
{ {
return new FlagsChanAccess(this); return new FlagsChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
auto it = defaultFlags.find(p->name);
if (it != defaultFlags.end())
access[_("Flag")] = Anope::ToString(it->second);
}
}; };
FlagsAccessProvider *FlagsAccessProvider::ap; FlagsAccessProvider *FlagsAccessProvider::ap;
+4 -3
View File
@@ -95,11 +95,12 @@ public:
source.Reply(_( source.Reply(_(
"Tells %s to invite you or an optionally specified " "Tells %s to invite you or an optionally specified "
"nick into the given channel." "nick into the given channel."
"\n\n"
"By default, limited to AOPs or those with level 5 access and above "
"on the channel."
), ),
source.service->nick.c_str()); source.service->nick.c_str());
source.Reply(" ");
AccessProvider::SendAccess(source, "INVITE");
return true; return true;
} }
}; };
+5 -6
View File
@@ -134,12 +134,11 @@ public:
{ {
this->SendSyntax(source); this->SendSyntax(source);
source.Reply(" "); source.Reply(" ");
source.Reply(_( source.Reply(_("Kicks a specified nick from a channel. Channel founders can also specify masks."));
"Kicks a specified nick from a channel."
"\n\n" source.Reply(" ");
"By default, limited to AOPs or those with level 5 access " AccessProvider::SendAccess(source, "KICK");
"and above on the channel. Channel founders can also specify masks."
));
return true; return true;
} }
}; };
+4 -3
View File
@@ -128,11 +128,12 @@ public:
"user from entering the given channel. If no channel is " "user from entering the given channel. If no channel is "
"given, all bans affecting you in channels you have access " "given, all bans affecting you in channels you have access "
"in are removed." "in are removed."
"\n\n"
"By default, limited to AOPs or those with level 5 access and above "
"on the channel."
), ),
source.service->nick.c_str()); source.service->nick.c_str());
source.Reply(" ");
AccessProvider::SendAccess(source, "UNBAN");
return true; return true;
} }
}; };
+13
View File
@@ -100,6 +100,19 @@ public:
{ {
return new XOPChanAccess(this); return new XOPChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
for (const auto& xop : order)
{
const auto &privs = permissions[xop];
if (std::find(privs.begin(), privs.end(), p->name) != privs.end())
{
access[_("XOP")] = xop;
return;
}
}
}
}; };
class CommandCSXOP final class CommandCSXOP final
+21
View File
@@ -94,6 +94,27 @@ const std::list<AccessProvider *>& AccessProvider::GetProviders()
return Providers; return Providers;
} }
void AccessProvider::SendAccess(CommandSource &source, const Anope::string& pname)
{
auto *p = PrivilegeManager::FindPrivilege(pname);
if (!p)
return; // Privilege missing.
Anope::map<Anope::string> access;
for (auto *service : Service::GetServices("AccessProvider"))
{
auto *accessprovider = static_cast<AccessProvider *>(service);
accessprovider->GetAccess(source, p, access);
}
if (access.empty())
return; // No access systems???
source.Reply(_("By default, the \002%s\002 command is limited to:"), source.command.c_str());
for (const auto& [system, privilege] : access)
source.Reply(" \002%s\002: %s", source.Translate(system), privilege.c_str());
}
ChanAccess::ChanAccess(AccessProvider *p) ChanAccess::ChanAccess(AccessProvider *p)
: Serializable(CHANACCESS_TYPE) : Serializable(CHANACCESS_TYPE)
, provider(p) , provider(p)