Clear recipients instead of blocking - allow server logging

This commit is contained in:
Claude
2025-11-23 19:54:53 +00:00
parent 2aca59b25e
commit 96d535633a

View File

@@ -17,18 +17,19 @@ public class CHRANIBotTNG : IModApi
[HarmonyPatch(typeof(GameManager), "ChatMessageServer")] [HarmonyPatch(typeof(GameManager), "ChatMessageServer")]
public class ChatMessagePatch public class ChatMessagePatch
{ {
static bool Prefix(ClientInfo _cInfo, string _msg, List<int> _recipientEntityIds) static void Prefix(string _msg, ref List<int> _recipientEntityIds)
{ {
if (_msg != null && _msg.StartsWith("/bot ")) if (_msg != null && _msg.StartsWith("/bot "))
{ {
string playerName = _cInfo != null ? _cInfo.playerName : "Server"; // Clear recipients so no players see it in-game, but server still logs it
if (_recipientEntityIds == null)
// Write to server log (visible in telnet) {
Console.WriteLine($"Chat (from '{playerName}', entity id '{(_cInfo != null ? _cInfo.entityId.ToString() : "-1")}', to '{(_recipientEntityIds != null && _recipientEntityIds.Count > 0 ? "players" : "all")}'): '{_msg}'"); _recipientEntityIds = new List<int>();
}
// Block in-game chat display else
return false; {
_recipientEntityIds.Clear();
}
} }
return true;
} }
} }