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 19:17:37 +00:00
|
|
|
[HarmonyPatch(typeof(ChatCommandManager), "ProcessCommand")]
|
|
|
|
|
public class ChatCommandPatch
|
2025-11-23 17:44:58 +00:00
|
|
|
{
|
2025-11-23 19:17:37 +00:00
|
|
|
static bool Prefix(ChatCommandManager __instance, string _chatText, ClientInfo _cInfo)
|
2025-11-23 17:44:58 +00:00
|
|
|
{
|
2025-11-23 19:17:37 +00:00
|
|
|
if (_chatText != null && _chatText.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 19:17:37 +00:00
|
|
|
Console.WriteLine($"[Bot] {playerName}: {_chatText}");
|
2025-11-23 17:15:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-23 19:17:37 +00:00
|
|
|
|