diff options
author | Sadie Powell <sadie@witchery.services> | 2025-03-08 13:36:41 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-03-08 14:07:15 +0000 |
commit | 62bfa33464df8cc413fa4f111ab62e189be0ca32 (patch) | |
tree | 5dd8b0bb0caa1fc3c76e05253641f332a3c10af4 /modules/nickserv/nickserv.cpp | |
parent | b4ab7dadb94c463b46e8bef5bce8c8c531bf1995 (diff) |
Rework how nickname protection works.
- Rename the command and module from kill to protect (this command
hasn't actually killed users in a long time).
- Replace QUICK/IMMED with a duration option.
Diffstat (limited to 'modules/nickserv/nickserv.cpp')
-rw-r--r-- | modules/nickserv/nickserv.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp index 7d34061c7..c09367914 100644 --- a/modules/nickserv/nickserv.cpp +++ b/modules/nickserv/nickserv.cpp @@ -211,31 +211,27 @@ public: if (Config->GetModule("nickserv").Get<bool>("nonicknameownership")) return; - if (!na->nc->HasExt("KILL_IMMED")) + if (na->nc->HasExt("PROTECT")) { - u->SendMessage(NickServ, NICK_IS_SECURE, NickServ->GetQueryCommand().c_str()); - } - if (na->nc->HasExt("KILLPROTECT")) - { - if (na->nc->HasExt("KILL_IMMED")) - { - u->SendMessage(NickServ, FORCENICKCHANGE_NOW); - this->Collide(u, na); - } - else if (na->nc->HasExt("KILL_QUICK")) + auto &block = Config->GetModule(this); + auto protectafter = na->nc->GetExt<time_t>("PROTECT_AFTER"); + + auto protect = protectafter ? *protectafter : block.Get<time_t>("defaultprotect", "1m"); + protect = std::clamp(protect, block.Get<time_t>("minprotect", "10s"), block.Get<time_t>("maxprotect", "10m")); + + if (protect) { - time_t killquick = Config->GetModule("nickserv").Get<time_t>("killquick", "20s"); - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str()); - new NickServCollide(this, this, u, na, killquick); + u->SendMessage(NickServ, NICK_IS_SECURE, NickServ->GetQueryCommand().c_str()); + u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), + Anope::Duration(protect, u->Account()).c_str()); + new NickServCollide(this, this, u, na, protect); } else { - time_t kill = Config->GetModule("nickserv").Get<time_t>("kill", "60s"); - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(kill, u->Account()).c_str()); - new NickServCollide(this, this, u, na, kill); + u->SendMessage(NickServ, FORCENICKCHANGE_NOW); + this->Collide(u, na); } } - } void OnUserLogin(User *u) override |