1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 23:46:39 +02:00

Allow users to opt-out of being added to channel access lists.

This commit is contained in:
Sadie Powell
2023-11-23 15:10:03 +00:00
parent 70d72b62df
commit 3371941be5
6 changed files with 115 additions and 3 deletions
+1 -1
View File
@@ -792,7 +792,7 @@ log
* nickserv/saset/autoop nickserv/saset/email nickserv/saset/greet nickserv/saset/password
* nickserv/saset/display nickserv/saset/kill nickserv/saset/language nickserv/saset/message
* nickserv/saset/private nickserv/saset/secure nickserv/saset/url nickserv/saset/noexpire
* nickserv/saset/keepmodes
* nickserv/saset/keepmodes nickserv/saset/neverop
*
* hostserv/set hostserv/del hostserv/list
*
+5
View File
@@ -107,6 +107,7 @@ module
* - memo_receive: Notify user if they have a new memo as soon as it's received
* - memo_mail: Notify user if they have a new memo by mail
* - autoop: User will be automatically opped in channels they enter and have access to
* - neverop: User can not be added to access lists
* - msg: Messages will be sent as PRIVMSGs instead of NOTICEs, requires options:useprivmsg
* to be enabled as well
* - ns_keep_modes: Enables keepmodes, which retains user modes across sessions
@@ -532,6 +533,7 @@ command { service = "NickServ"; name = "RESETPASS"; command = "nickserv/resetpas
* nickserv/set/message, nickserv/saset/message - Used to configure how services send messages to you.
* nickserv/set/password, nickserv/saset/password - Used for changing a users password.
* nickserv/set/secure, nickserv/saset/secure - Used for configuring whether a user can identify by simply being recognized by nickserv/access.
* nickserv/set/neverop, nickserv/saset/neverop - Used to configure whether a user can be added to access lists
* nickserv/saset/noexpire - Used for configuring noexpire, which prevents nicks from expiring.
*/
module
@@ -576,6 +578,9 @@ command { service = "NickServ"; name = "SASET PASSWORD"; command = "nickserv/sas
command { service = "NickServ"; name = "SET SECURE"; command = "nickserv/set/secure"; }
command { service = "NickServ"; name = "SASET SECURE"; command = "nickserv/saset/secure"; permission = "nickserv/saset/secure"; }
command { service = "NickServ"; name = "SET NEVEROP"; command = "nickserv/set/neverop"; }
command { service = "NickServ"; name = "SASET NEVEROP"; command = "nickserv/saset/neverop"; permission = "nickserv/saset/neverop"; }
command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/saset/noexpire"; permission = "nickserv/saset/noexpire"; }
+6
View File
@@ -166,6 +166,12 @@ class CommandCSAccess : public Command
source.Reply(_("Masks and unregistered users may not be on access lists."));
return;
}
else if (na && na->nc->HasExt("NEVEROP"))
{
source.Reply(_("\002%s\002 does not wish to be added to channel access lists."),
na->nc->display.c_str());
return;
}
else if (mask.find_first_of("!*@") == Anope::string::npos && !na)
{
User *targ = User::Find(mask, true);
+6
View File
@@ -120,6 +120,12 @@ class CommandCSFlags : public Command
source.Reply(_("Masks and unregistered users may not be on access lists."));
return;
}
else if (na && na->nc->HasExt("NEVEROP"))
{
source.Reply(_("\002%s\002 does not wish to be added to channel access lists."),
na->nc->display.c_str());
return;
}
else if (mask.find_first_of("!*@") == Anope::string::npos && !na)
{
User *targ = User::Find(mask, true);
+6
View File
@@ -166,6 +166,12 @@ class CommandCSXOP : public Command
source.Reply(_("Masks and unregistered users may not be on access lists."));
return;
}
else if (na && na->nc->HasExt("NEVEROP"))
{
source.Reply(_("\002%s\002 does not wish to be added to channel access lists."),
na->nc->display.c_str());
return;
}
else if (mask.find_first_of("!*@") == Anope::string::npos && !na)
{
User *targ = User::Find(mask, true);
+91 -2
View File
@@ -322,6 +322,89 @@ class CommandNSSASetAutoOp : public CommandNSSetAutoOp
}
};
class CommandNSSetNeverOp : public Command
{
public:
CommandNSSetNeverOp(Module *creator, const Anope::string &sname = "nickserv/set/neverop", size_t min = 1) : Command(creator, sname, min, min + 1)
{
this->SetDesc(_("Sets whether you can be added to a channel access list."));
this->SetSyntax("{ON | OFF}");
}
void Run(CommandSource &source, const Anope::string &user, const Anope::string &param)
{
if (Anope::ReadOnly)
{
source.Reply(READ_ONLY_MODE);
return;
}
const NickAlias *na = NickAlias::Find(user);
if (na == NULL)
{
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
return;
}
NickCore *nc = na->nc;
EventReturn MOD_RESULT;
FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param));
if (MOD_RESULT == EVENT_STOP)
return;
if (param.equals_ci("ON"))
{
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable neverop for " << na->nc->display;
nc->Extend<bool>("NEVEROP");
source.Reply(_("%s can no longer be added to channel access lists."), nc->display.c_str());
}
else if (param.equals_ci("OFF"))
{
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable neverop for " << na->nc->display;
nc->Shrink<bool>("NEVEROP");
source.Reply(_("%s can now be added to channel access lists."), nc->display.c_str());
}
else
this->OnSyntaxError(source, "NEVEROP");
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Sets whether you can be added to a channel access list."));
return true;
}
};
class CommandNSSASetNeverOp : public CommandNSSetNeverOp
{
public:
CommandNSSASetNeverOp(Module *creator) : CommandNSSetNeverOp(creator, "nickserv/saset/neverop", 2)
{
this->ClearSyntax();
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Sets whether the given nickname can be added to a channel access list."));
return true;
}
};
class CommandNSSetDisplay : public Command
{
public:
@@ -1157,6 +1240,9 @@ class NSSet : public Module
CommandNSSetAutoOp commandnssetautoop;
CommandNSSASetAutoOp commandnssasetautoop;
CommandNSSetNeverOp commandnssetneverop;
CommandNSSASetNeverOp commandnssasetneverop;
CommandNSSetDisplay commandnssetdisplay;
CommandNSSASetDisplay commandnssasetdisplay;
@@ -1183,7 +1269,7 @@ class NSSet : public Module
CommandNSSASetNoexpire commandnssasetnoexpire;
SerializableExtensibleItem<bool> autoop, killprotect, kill_quick, kill_immed,
SerializableExtensibleItem<bool> autoop, neverop, killprotect, kill_quick, kill_immed,
message, secure, noexpire;
struct KeepModes : SerializableExtensibleItem<bool>
@@ -1239,6 +1325,7 @@ class NSSet : public Module
NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnsset(this), commandnssaset(this),
commandnssetautoop(this), commandnssasetautoop(this),
commandnssetneverop(this), commandnssasetneverop(this),
commandnssetdisplay(this), commandnssasetdisplay(this),
commandnssetemail(this), commandnssasetemail(this),
commandnssetkeepmodes(this), commandnssasetkeepmodes(this),
@@ -1249,7 +1336,7 @@ class NSSet : public Module
commandnssetsecure(this), commandnssasetsecure(this),
commandnssasetnoexpire(this),
autoop(this, "AUTOOP"),
autoop(this, "AUTOOP"), neverop(this, "NEVEROP"),
killprotect(this, "KILLPROTECT"), kill_quick(this, "KILL_QUICK"),
kill_immed(this, "KILL_IMMED"), message(this, "MSG"),
secure(this, "NS_SECURE"), noexpire(this, "NS_NO_EXPIRE"),
@@ -1314,6 +1401,8 @@ class NSSet : public Module
info.AddOption(_("Message mode"));
if (autoop.HasExt(na->nc))
info.AddOption(_("Auto-op"));
if (neverop.HasExt(na->nc))
info.AddOption(_("Never-op"));
if (noexpire.HasExt(na))
info.AddOption(_("No expire"));
if (keep_modes.HasExt(na->nc))