2023-07-31 09:33:04 +03:00
|
|
|
using Content.Server.Administration;
|
|
|
|
|
using Content.Server.Chat.Managers;
|
|
|
|
|
using Content.Shared.Administration;
|
|
|
|
|
using Content.Shared.CCVar;
|
2024-01-28 18:37:24 +07:00
|
|
|
using Content.Shared._White;
|
2023-07-31 09:33:04 +03:00
|
|
|
using Robust.Shared.Configuration;
|
|
|
|
|
using Robust.Shared.Console;
|
|
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
namespace Content.Server._White.Commands;
|
2023-07-31 09:33:04 +03:00
|
|
|
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
|
|
|
|
public sealed class AntispamCommand : IConsoleCommand
|
|
|
|
|
{
|
|
|
|
|
public string Command => "setantispam";
|
|
|
|
|
public string Description => "Переключает антиспам систему.";
|
|
|
|
|
public string Help => "setantispam <bool>";
|
|
|
|
|
|
|
|
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length != 1 || !bool.TryParse(args[0], out var value))
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError($"{args[0]} is not a valid boolean.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_cfg.SetCVar(WhiteCVars.ChatAntispam, value);
|
|
|
|
|
|
|
|
|
|
var toggle = value ? "включил" : "выключил";
|
|
|
|
|
var announce = $"{shell.Player?.Name} {toggle} антиспам систему";
|
|
|
|
|
|
|
|
|
|
IoCManager.Resolve<IChatManager>().DispatchServerAnnouncement(announce, Color.Red);
|
|
|
|
|
}
|
|
|
|
|
}
|