add command: `unban profile <profile-id>`
To remove a banned profile ID from the ban list.
This commit is contained in:
parent
2cd7abf0bd
commit
52c270a210
|
@ -107,6 +107,17 @@ public static class BanLists {
|
||||||
IPs.Remove(ipv4);
|
IPs.Remove(ipv4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void UnbanProfile(Client user) {
|
||||||
|
UnbanProfile(user.Id);
|
||||||
|
}
|
||||||
|
private static void UnbanProfile(string str) {
|
||||||
|
if (!Guid.TryParse(str, out Guid id)) { return; }
|
||||||
|
UnbanProfile(id);
|
||||||
|
}
|
||||||
|
private static void UnbanProfile(Guid id) {
|
||||||
|
Profiles.Remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void Save() {
|
private static void Save() {
|
||||||
Settings.SaveSettings(true);
|
Settings.SaveSettings(true);
|
||||||
|
@ -203,7 +214,7 @@ public static class BanLists {
|
||||||
|
|
||||||
public static string HandleUnbanCommand(string[] args) {
|
public static string HandleUnbanCommand(string[] args) {
|
||||||
if (args.Length != 2) {
|
if (args.Length != 2) {
|
||||||
return "Usage: unban ip <ipv4-address>";
|
return "Usage: unban {profile|ip} <value>";
|
||||||
}
|
}
|
||||||
|
|
||||||
string cmd = args[0];
|
string cmd = args[0];
|
||||||
|
@ -211,7 +222,18 @@ public static class BanLists {
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
default:
|
default:
|
||||||
return "Usage: unban ip <ipv4-address>";
|
return "Usage: unban {profile|ip} <value>";
|
||||||
|
|
||||||
|
case "profile":
|
||||||
|
if (!Guid.TryParse(val, out Guid id)) {
|
||||||
|
return "Invalid profile ID value!";
|
||||||
|
}
|
||||||
|
if (!IsProfileBanned(id)) {
|
||||||
|
return "Profile " + id.ToString() + " is not banned.";
|
||||||
|
}
|
||||||
|
UnbanProfile(id);
|
||||||
|
Save();
|
||||||
|
return "Unbanned profile: " + id.ToString();
|
||||||
|
|
||||||
case "ip":
|
case "ip":
|
||||||
if (!IsIPv4(val)) {
|
if (!IsIPv4(val)) {
|
||||||
|
|
Loading…
Reference in New Issue