From 0af4efb6b688943ae2d0ab616b0f292f49a00209 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 25 Sep 2026 12:45:49 +0200 Subject: [PATCH] Chat: read the host's own wording of each line DECAL handed the original each line as the chat window shows it, tell links included; the host now reports the same wording (DisplayText). Kill, rare, combat and !report parsing and the chat frame read that, with tags stripped for the frame exactly as before; the plugin's own formatter remains only for a line the host did not word. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../Streams/ChatLineText.cs | 6 ++++++ .../Fakes/FakeAutomation.cs | 4 +++- .../Streams/StreamGoldenTests.cs | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/OpenAC.MosswartMassacre/Streams/ChatLineText.cs b/src/OpenAC.MosswartMassacre/Streams/ChatLineText.cs index 4afc8df..93d555e 100644 --- a/src/OpenAC.MosswartMassacre/Streams/ChatLineText.cs +++ b/src/OpenAC.MosswartMassacre/Streams/ChatLineText.cs @@ -19,6 +19,12 @@ internal static class ChatLineText public static string Of(in PluginChatMessage message) { + // The host's own wording, tell links included, is the text the + // original was handed; the rest of this method is the fallback for a + // line the host did not word. + if (!string.IsNullOrEmpty(message.DisplayText)) + return message.DisplayText; + string text = message.Text ?? string.Empty; string sender = message.Sender ?? string.Empty; bool own = string.IsNullOrEmpty(sender) || sender == "You"; diff --git a/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeAutomation.cs b/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeAutomation.cs index daad549..5f3b822 100644 --- a/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeAutomation.cs +++ b/tests/OpenAC.MosswartMassacre.Tests/Fakes/FakeAutomation.cs @@ -400,11 +400,13 @@ public sealed class RecordingChat : IPluginChat string channelName = "", int logTextType = 0, int combatKind = 0, - uint senderObjectId = 0u) + uint senderObjectId = 0u, + string displayText = "") { var message = new PluginChatMessage( _nextSequence++, senderObjectId, kind, sender, text, channelName) { + DisplayText = displayText, LogTextType = logTextType, CombatKind = combatKind, Received = DateTimeOffset.UtcNow, diff --git a/tests/OpenAC.MosswartMassacre.Tests/Streams/StreamGoldenTests.cs b/tests/OpenAC.MosswartMassacre.Tests/Streams/StreamGoldenTests.cs index 10dbbc0..f742034 100644 --- a/tests/OpenAC.MosswartMassacre.Tests/Streams/StreamGoldenTests.cs +++ b/tests/OpenAC.MosswartMassacre.Tests/Streams/StreamGoldenTests.cs @@ -181,6 +181,25 @@ public sealed class StreamGoldenTests Assert.Single(harness.Frames)); } + [Fact] + public void Chat_uses_the_hosts_wording_with_tell_links_stripped_like_the_original() + { + // The original read DECAL's chat text, which carries tell links; its + // chat stream stripped tags (ChatEventRouter.cs:83-91), and its + // !report check looked for allegiance lines ending in !report". + using var harness = LoggedIn(); + + harness.Host.Automation.Chat.Deliver( + "!report", kind: 2, sender: "Horan", channelName: "Allegiance", logTextType: 18, + displayText: "[Allegiance] Horan<\\Tell> says, \"!report\""); + + Assert.Equal( + "{\"type\":\"chat\",\"timestamp\":\"" + Stamp + "\",\"character_name\":\"Mossy\"," + + "\"text\":\"[Allegiance] Horan says, \\\"!report\\\"\",\"color\":18}", + Assert.Single(harness.Frames)); + Assert.StartsWith("/a Total Kills: 0, Kills per Hour: ", Assert.Single(harness.Host.Automation.Chat.Submitted)); + } + [Fact] public void Spawn_frame_has_string_coordinates() {