summaryrefslogtreecommitdiff
path: root/modules/webcpanel
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-03-08 13:36:41 +0000
committerSadie Powell <sadie@witchery.services>2025-03-08 14:07:15 +0000
commit62bfa33464df8cc413fa4f111ab62e189be0ca32 (patch)
tree5dd8b0bb0caa1fc3c76e05253641f332a3c10af4 /modules/webcpanel
parentb4ab7dadb94c463b46e8bef5bce8c8c531bf1995 (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/webcpanel')
-rw-r--r--modules/webcpanel/pages/nickserv/info.cpp56
-rw-r--r--modules/webcpanel/templates/nickserv/info.html14
2 files changed, 42 insertions, 28 deletions
diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp
index e1a44a426..be8b110f5 100644
--- a/modules/webcpanel/pages/nickserv/info.cpp
+++ b/modules/webcpanel/pages/nickserv/info.cpp
@@ -56,23 +56,38 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str
na->nc->Shrink<bool>("NS_PRIVATE");
replacements["MESSAGES"] = "Private updated";
}
- if (message.post_data["kill"] == "on" && !na->nc->HasExt("KILLPROTECT"))
+ if (na->nc->HasExt("PROTECT") != !!message.post_data.count("protect"))
{
- na->nc->Extend<bool>("KILLPROTECT");
- na->nc->Shrink<bool>("KILL_QUICK");
- replacements["MESSAGES"] = "Kill updated";
- }
- else if (message.post_data["kill"] == "quick" && !na->nc->HasExt("KILL_QUICK"))
- {
- na->nc->Extend<bool>("KILLPROTECT");
- na->nc->Extend<bool>("KILL_QUICK");
- replacements["MESSAGES"] = "Kill updated";
+ if (!na->nc->HasExt("PROTECT"))
+ {
+ na->nc->Shrink<bool>("PROTECT");
+ na->nc->Shrink<time_t>("PROTECT_AFTER");
+ }
+ else
+ {
+ na->nc->Extend<bool>("PROTECT");
+ }
+ replacements["MESSAGES"] = "Protect updated";
}
- else if (message.post_data["kill"] == "off" && (!!na->nc->HasExt("KILLPROTECT") || !!na->nc->HasExt("KILL_QUICK")))
+ if (na->nc->HasExt("PROTECT") && message.post_data.count("protect_after") > 0)
{
- na->nc->Shrink<bool>("KILLPROTECT");
- na->nc->Shrink<bool>("KILL_QUICK");
- replacements["MESSAGES"] = "Kill updated";
+ auto &block = Config->GetModule("nickserv");
+ auto minprotect = block.Get<time_t>("minprotect", "10s");
+ auto maxprotect = block.Get<time_t>("maxprotect", "10m");
+
+ auto secs = Anope::TryConvert<time_t>(message.post_data["greet"]);
+ if (!secs)
+ replacements["ERRORS"] = "Protection after seconds are not valid";
+ else if (*secs < minprotect || *secs > maxprotect)
+ {
+ replacements["ERRORS"] = Anope::printf("Protection delay must be between %ld and %ld seconds.",
+ minprotect, maxprotect);
+ }
+ else
+ {
+ na->nc->Extend<time_t>("PROTECT_AFTER", *secs);
+ replacements["MESSAGES"] = "Protect after updated";
+ }
}
if (na->nc->HasExt("NS_KEEP_MODES") != !!message.post_data.count("keepmodes"))
{
@@ -113,12 +128,13 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str
replacements["AUTOOP"];
if (na->nc->HasExt("NS_PRIVATE"))
replacements["PRIVATE"];
- if (na->nc->HasExt("KILLPROTECT"))
- replacements["KILL_ON"];
- if (na->nc->HasExt("KILL_QUICK"))
- replacements["KILL_QUICK"];
- if (!na->nc->HasExt("KILLPROTECT") && !na->nc->HasExt("KILL_QUICK"))
- replacements["KILL_OFF"];
+ if (na->nc->HasExt("PROTECT"))
+ {
+ replacements["PROTECT"];
+ auto *protectafter = na->nc->GetExt<time_t>("PROTECT_AFTER");
+ if (protectafter)
+ replacements["PROTECT_AFTER"] = *protectafter;
+ }
if (na->nc->HasExt("NS_KEEP_MODES"))
replacements["KEEPMODES"];
if (na->nc->HasExt("MSG"))
diff --git a/modules/webcpanel/templates/nickserv/info.html b/modules/webcpanel/templates/nickserv/info.html
index c713cd64c..794598196 100644
--- a/modules/webcpanel/templates/nickserv/info.html
+++ b/modules/webcpanel/templates/nickserv/info.html
@@ -61,14 +61,12 @@
<td><input type="checkbox" name="private" value="on" {IF EXISTS PRIVATE}checked{END IF}></td>
</tr>
<tr>
- <td>Kill:</td>
- <td>
- <select name="kill" class="form-control input-sm">
- <option value="on" {IF EXISTS KILL_ON}selected{END IF}>On</option>
- <option value="quick" {IF EXISTS KILL_QUICK}selected{END IF}>Quick</option>
- <option value="off" {IF EXISTS KILL_OFF}selected{END IF}>Off</option>
- </select>
- </td>
+ <td>Protect:</td>
+ <td><input type="checkbox" name="protect" value="on" {IF EXISTS PROTECT}checked{END IF}></td>
+ </tr>
+ <tr>
+ <td>Protect after:</td>
+ <td><input name="protect_after" value="{PROTECT_AFTER}" class="form-control input-sm"></td>
</tr>
</tbody>
</table>