Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Text.RegularExpressions;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
using Content.Shared.Humanoid; //DS14
using Content.Shared.Humanoid.Prototypes; //DS14

namespace Content.Server.Chat.Managers;

Expand Down Expand Up @@ -117,8 +119,24 @@ private static readonly (Regex regex, string emoteKey)[] ShorthandToEmote =
Entry("['=", "chatsan-tearfully-smiles"),
];

// DS14-Start
// Эмоции, для которых мы и юзаем половые варианты(Пополнить список, если я чтот забыл)
private static readonly HashSet<string> GenderedEmotes = new()
{
"chatsan-surprised",
"chatsan-uncertain",
"chatsan-annoyed",
"chatsan-unimpressed",
"chatsan-wide-eyed",
"chatsan-confused"
};
// DS14-End

[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
// DS14-Start
[Dependency] private readonly IEntityManager _entityManager = default!;
// DS14-End

private bool _doSanitize;

Expand Down Expand Up @@ -146,6 +164,15 @@ public bool TrySanitizeEmoteShorthands(string message,
if (!_doSanitize)
return false;

// DS14-Start
// Определение пола
Sex sex = Sex.Unsexed;
if (_entityManager.TryGetComponent<HumanoidAppearanceComponent>(speaker, out var humanoid))
{
sex = humanoid.Sex;
}
// DS14-End

// -1 is just a canary for nothing found yet
var lastEmoteIndex = -1;

Expand All @@ -161,7 +188,26 @@ public bool TrySanitizeEmoteShorthands(string message,
if (lastMatch.Index > lastEmoteIndex)
{
lastEmoteIndex = lastMatch.Index;
emote = _loc.GetString(emoteKey, ("ent", speaker));

// DS14-Start
// Суффиксы, да
string finalEmoteKey;
if (GenderedEmotes.Contains(emoteKey))
{
finalEmoteKey = sex switch
{
Sex.Female => $"{emoteKey}-female",
Sex.Male => $"{emoteKey}-male",
_ => $"{emoteKey}-unsexed"
};
}
else
{
finalEmoteKey = emoteKey;
}

emote = _loc.GetString(finalEmoteKey);
// DS14-End
}

message = r.Replace(message, string.Empty);
Expand All @@ -187,4 +233,4 @@ private static (Regex regex, string emoteKey) Entry(string shorthand, string emo

return (pattern, emoteKey);
}
}
}
35 changes: 29 additions & 6 deletions Resources/Locale/ru-RU/chat/sanitizer-replacements.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ chatsan-smiles = улыбается
chatsan-frowns = грустит
chatsan-smiles-widely = широко улыбается
chatsan-frowns-deeply = сильно грустит
chatsan-surprised = выглядит удивлённым
chatsan-uncertain = выглядит растерянным
chatsan-grins = ухмыляется
chatsan-pouts = дуется
chatsan-laughs = смеётся
chatsan-cries = плачет
chatsan-smiles-smugly = самодовольно улыбается
chatsan-annoyed = выглядит раздражённым
chatsan-sighs = вздыхает
chatsan-stick-out-tongue = показывает язык
chatsan-wide-eyed = выглядит шокированным
chatsan-confused = выглядит смущённым
chatsan-unimpressed = кажется не впечатлённым
chatsan-waves = машет
chatsan-salutes = отдаёт честь
chatsan-tearfully-salutes = отдаёт честь со слезами на глазах
Expand All @@ -23,3 +17,32 @@ chatsan-winks = подмигивает
chatsan-shrugs = пожимает плечами
chatsan-claps = хлопает
chatsan-snaps = щёлкает
# surprised
chatsan-surprised-female = выглядит удивлённой
chatsan-surprised-male = выглядит удивлённым
chatsan-surprised-unsexed = выглядят удивлёнными

# uncertain
chatsan-uncertain-female = выглядит растерянной
chatsan-uncertain-male = выглядит растерянным
chatsan-uncertain-unsexed = выглядят растерянными

# annoyed
chatsan-annoyed-female = выглядит раздражённой
chatsan-annoyed-male = выглядит раздражённым
chatsan-annoyed-unsexed = выглядят раздражёнными

# unimpressed
chatsan-unimpressed-female = кажется невпечатлённой
chatsan-unimpressed-male = кажется невпечатлённым
chatsan-unimpressed-unsexed = кажутся невпечатлёнными

# wide-eyed
chatsan-wide-eyed-female = выглядит шокированной
chatsan-wide-eyed-male = выглядит шокированным
chatsan-wide-eyed-unsexed = выглядят шокированными

# confused
chatsan-confused-female = выглядит смущённой
chatsan-confused-male = выглядит смущённым
chatsan-confused-unsexed = выглядят смущёнными
Loading