2025-11-23 17:15:09 +00:00
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
2025-11-23 17:49:59 +00:00
|
|
|
using System;
|
2025-11-23 17:15:09 +00:00
|
|
|
|
|
|
|
|
public class BotCommandMod : IModApi
|
|
|
|
|
{
|
|
|
|
|
public void InitMod(Mod _modInstance)
|
|
|
|
|
{
|
2025-11-23 17:49:59 +00:00
|
|
|
Console.WriteLine("[BotCommandMod] Loading");
|
2025-11-23 17:15:09 +00:00
|
|
|
var harmony = new Harmony("com.botcommand.mod");
|
|
|
|
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
2025-11-23 17:49:59 +00:00
|
|
|
Console.WriteLine("[BotCommandMod] Loaded");
|
2025-11-23 17:44:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-23 18:18:23 +00:00
|
|
|
[HarmonyPatch(typeof(GameManager), "ChatMessage")]
|
2025-11-23 17:44:58 +00:00
|
|
|
public class ChatMessagePatch
|
|
|
|
|
{
|
2025-11-23 18:18:23 +00:00
|
|
|
static bool Prefix(ClientInfo _cInfo, EChatType _type, string _msg, string _playerName)
|
2025-11-23 17:44:58 +00:00
|
|
|
{
|
|
|
|
|
if (_msg != null && _msg.StartsWith("/bot "))
|
2025-11-23 17:15:09 +00:00
|
|
|
{
|
2025-11-23 17:44:58 +00:00
|
|
|
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
|
2025-11-23 17:49:59 +00:00
|
|
|
Console.WriteLine($"[Bot] {playerName}: {_msg}");
|
2025-11-23 17:15:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|