CatStation/Content.Server/Speech/EntitySystems/MothAccentSystem.cs
Morb0 05929d24a3 Merge remote-tracking branch 'upstream/master' into upstream-sync
# Conflicts:
#	Content.Server/Speech/EntitySystems/MothAccentSystem.cs
2023-12-16 12:36:47 +03:00

55 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text.RegularExpressions;
using Content.Server.Speech.Components;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems;
public sealed class MothAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!; // Corvax-Localization
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MothAccentComponent, AccentGetEvent>(OnAccent);
}
private void OnAccent(EntityUid uid, MothAccentComponent component, AccentGetEvent args)
{
var message = args.Message;
// buzzz
message = Regex.Replace(message, "z{1,3}", "zzz");
// buZZZ
message = Regex.Replace(message, "Z{1,3}", "ZZZ");
// Corvax-Localization-Start
// ж => жжж
message = Regex.Replace(
message,
"ж+",
_random.Pick(new List<string>() { "жж", "жжж" })
);
// Ж => ЖЖЖ
message = Regex.Replace(
message,
"Ж+",
_random.Pick(new List<string>() { "ЖЖ", "ЖЖЖ" })
);
// з => ссс
message = Regex.Replace(
message,
"з+",
_random.Pick(new List<string>() { "зз", "ззз" })
);
// З => CCC
message = Regex.Replace(
message,
"З+",
_random.Pick(new List<string>() { "ЗЗ", "ЗЗЗ" })
);
// Corvax-Localization-End
args.Message = message;
}
}