2025-11-23 20:23:53 +01:00
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System;
|
2025-11-23 19:39:06 +00:00
|
|
|
using System.Collections.Generic;
|
2025-11-23 20:23:53 +01:00
|
|
|
|
|
|
|
|
public class CHRANIBotTNG : IModApi
|
|
|
|
|
{
|
|
|
|
|
public void InitMod(Mod _modInstance)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("[CHRANIBotTNG] Loading");
|
2025-11-23 19:39:06 +00:00
|
|
|
var harmony = new Harmony("com.chranibottng.mod");
|
|
|
|
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
|
|
|
|
Console.WriteLine("[CHRANIBotTNG] Loaded");
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-23 20:23:53 +01:00
|
|
|
|
2025-11-23 19:39:06 +00:00
|
|
|
[HarmonyPatch(typeof(GameManager), "ChatMessageServer")]
|
|
|
|
|
public class ChatMessagePatch
|
|
|
|
|
{
|
2025-11-23 19:50:39 +00:00
|
|
|
static bool Prefix(ClientInfo _cInfo, string _msg, List<int> _recipientEntityIds)
|
2025-11-23 19:39:06 +00:00
|
|
|
{
|
|
|
|
|
if (_msg != null && _msg.StartsWith("/bot "))
|
2025-11-23 20:23:53 +01:00
|
|
|
{
|
2025-11-23 19:39:06 +00:00
|
|
|
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
|
2025-11-23 19:50:39 +00:00
|
|
|
|
|
|
|
|
// Write to server log (visible in telnet)
|
|
|
|
|
Log.Out($"Chat (from '{playerName}', entity id '{(_cInfo != null ? _cInfo.entityId.ToString() : "-1")}', to '{(_recipientEntityIds != null && _recipientEntityIds.Count > 0 ? "players" : "all")}'): '{_msg}'");
|
|
|
|
|
|
|
|
|
|
// Block in-game chat display
|
2025-11-23 19:39:06 +00:00
|
|
|
return false;
|
2025-11-23 20:23:53 +01:00
|
|
|
}
|
2025-11-23 19:39:06 +00:00
|
|
|
return true;
|
2025-11-23 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}
|