mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Chat Filter (April Fools) (#14999)
This commit is contained in:
parent
8ca2182a7c
commit
4434b3752c
4 changed files with 106 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
namespace Content.Server.Speech.Components;
|
||||
|
||||
// #####. ##### ### ###. #####? ### #####!
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class ChatFilterAccentComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
public sealed class ChatFilterAccentSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private static readonly Dictionary<string, string> DirectReplacements = new()
|
||||
{
|
||||
{ "fuck", "####" },
|
||||
{ "shit", "####" },
|
||||
{ "ass", "###" },
|
||||
{ "dick", "####" },
|
||||
{ "bitch", "#####" },
|
||||
{ "piss", "####" },
|
||||
{ "damn", "####" },
|
||||
{ "kill", "####" },
|
||||
{ "hurt", "####" },
|
||||
{ "god", "###" },
|
||||
{ "hell", "####" },
|
||||
{ "nuke", "####" },
|
||||
{ "dang", "####" },
|
||||
{ "lol", "###" },
|
||||
{ "nukies", "#####" },
|
||||
{ "nukie", "#####" },
|
||||
{ "gun", "###" },
|
||||
{ "ammo", "####" },
|
||||
{ "bridge", "#####" },
|
||||
{ "med", "###" },
|
||||
{ "clown", "#####" },
|
||||
{ "admin", "#####" },
|
||||
{ "badmin", "######" },
|
||||
{ "admeme", "######" },
|
||||
{ "badmeme", "######" },
|
||||
{ "centcom", "#######" },
|
||||
{ "singulo", "#######" },
|
||||
{ "singuloose", "##########" },
|
||||
{ "sword", "#####" },
|
||||
{ "dead", "####" },
|
||||
{ "died", "####" },
|
||||
{ "sus", "###" },
|
||||
{ "aos", "###" },
|
||||
{ "kos", "###" },
|
||||
{ "anomaly", "#######" },
|
||||
{ "shuttle", "#######" },
|
||||
{ "hos", "###" },
|
||||
{ "drunk", "#####" },
|
||||
{ "bar", "###" },
|
||||
{ "arrest", "#####" },
|
||||
{ "bomb", "####" },
|
||||
{ "I", "#" },
|
||||
{ "traitor", "#######" },
|
||||
{ "tator", "#####" },
|
||||
{ "bad", "###" },
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ChatFilterAccentComponent, AccentGetEvent>(OnAccentGet);
|
||||
}
|
||||
|
||||
public string Accentuate(string message)
|
||||
{
|
||||
var msg = message;
|
||||
|
||||
if (_cfg.GetCVar(CCVars.GameChatFilter) == true)
|
||||
{
|
||||
|
||||
foreach (var (first, replace) in DirectReplacements)
|
||||
{
|
||||
msg = Regex.Replace(msg, $@"{first}", replace, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
private void OnAccentGet(EntityUid uid, ChatFilterAccentComponent component, AccentGetEvent args)
|
||||
{
|
||||
args.Message = Accentuate(args.Message);
|
||||
}
|
||||
}
|
||||
|
|
@ -276,6 +276,12 @@ namespace Content.Shared.CCVar
|
|||
public static readonly CVarDef<bool> GameTableBonk =
|
||||
CVarDef.Create("game.table_bonk", false, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the Roblox chat filter. True by default.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> GameChatFilter =
|
||||
CVarDef.Create("game.chat_filter", true, CVar.SERVERONLY);
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
/// <summary>
|
||||
/// Amount of times round start must fail before the server is shut down.
|
||||
|
|
|
|||
|
|
@ -396,3 +396,4 @@
|
|||
interfaces:
|
||||
- key: enum.HumanoidMarkingModifierKey.Key # sure, this can go here too
|
||||
type: HumanoidMarkingModifierBoundUserInterface
|
||||
- type: ChatFilterAccent
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue