From 4a7fc2c3ecd6d507544f678826e4caf0e7efe8e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 19:39:06 +0000 Subject: [PATCH] Implement ChatMessageServer patch with correct signature Intercepts /bot messages and logs to console only --- Harmony/CHRANIBotTNG.cs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Harmony/CHRANIBotTNG.cs b/Harmony/CHRANIBotTNG.cs index d61cedc..693df61 100644 --- a/Harmony/CHRANIBotTNG.cs +++ b/Harmony/CHRANIBotTNG.cs @@ -1,26 +1,30 @@ using HarmonyLib; using System.Reflection; using System; -using System.Linq; +using System.Collections.Generic; public class CHRANIBotTNG : IModApi { public void InitMod(Mod _modInstance) { Console.WriteLine("[CHRANIBotTNG] Loading"); - - // List all GameManager methods containing "Chat" - var gmType = typeof(GameManager); - Console.WriteLine("[CHRANIBotTNG] GameManager methods with 'Chat':"); - foreach (var method in gmType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) - { - if (method.Name.Contains("Chat")) - { - var parameters = string.Join(", ", method.GetParameters().Select(p => p.ParameterType.Name + " " + p.Name)); - Console.WriteLine($" {method.Name}({parameters})"); - } - } - + var harmony = new Harmony("com.chranibottng.mod"); + harmony.PatchAll(Assembly.GetExecutingAssembly()); Console.WriteLine("[CHRANIBotTNG] Loaded"); } +} + +[HarmonyPatch(typeof(GameManager), "ChatMessageServer")] +public class ChatMessagePatch +{ + static bool Prefix(ClientInfo _cInfo, EChatType _chatType, int _senderEntityId, string _msg, List _recipientEntityIds, EMessageSender _msgSender, BbCodeSupportMode _bbMode) + { + if (_msg != null && _msg.StartsWith("/bot ")) + { + string playerName = _cInfo != null ? _cInfo.playerName : "Server"; + Console.WriteLine($"[Bot] {playerName}: {_msg}"); + return false; + } + return true; + } } \ No newline at end of file