2025-11-23 17:15:09 +00:00
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
2025-11-23 17:44:58 +00:00
|
|
|
using System.Collections.Generic;
|
2025-11-23 17:15:09 +00:00
|
|
|
|
|
|
|
|
public class BotCommandMod : IModApi
|
|
|
|
|
{
|
|
|
|
|
public void InitMod(Mod _modInstance)
|
|
|
|
|
{
|
2025-11-23 17:44:58 +00:00
|
|
|
Log.Out("[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:44:58 +00:00
|
|
|
Log.Out("[BotCommandMod] Loaded");
|
2025-11-23 17:15:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-23 17:44:58 +00:00
|
|
|
[HarmonyPatch(typeof(ConsoleCmdAbstract))]
|
|
|
|
|
[HarmonyPatch("getCommands")]
|
|
|
|
|
public class ChatInterceptPatch
|
2025-11-23 17:15:09 +00:00
|
|
|
{
|
2025-11-23 17:44:58 +00:00
|
|
|
static void Postfix(ref string __result)
|
2025-11-23 17:15:09 +00:00
|
|
|
{
|
2025-11-23 17:44:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(GameManager))]
|
|
|
|
|
[HarmonyPatch("ChatMessageServer")]
|
|
|
|
|
public class ChatMessagePatch
|
|
|
|
|
{
|
|
|
|
|
static bool Prefix(ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName, bool _localizeMain, List<int> _recipientEntityIds)
|
|
|
|
|
{
|
|
|
|
|
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";
|
|
|
|
|
Log.Out($"[Bot] {playerName}: {_msg}");
|
2025-11-23 17:15:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|