Add basic bot command mod
- Intercepts chat messages starting with /bot - Logs them to telnet only - Prevents display in game chat
This commit is contained in:
28
Harmony/BotCommandPatch.cs
Normal file
28
Harmony/BotCommandPatch.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
public class BotCommandMod : IModApi
|
||||||
|
{
|
||||||
|
public void InitMod(Mod _modInstance)
|
||||||
|
{
|
||||||
|
Log.Out("[BotCommandMod] Loading");
|
||||||
|
var harmony = new Harmony("com.botcommand.mod");
|
||||||
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||||
|
Log.Out("[BotCommandMod] Loaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(ChatCommandManager))]
|
||||||
|
[HarmonyPatch("ExecuteCommand")]
|
||||||
|
public class ChatCommandPatch
|
||||||
|
{
|
||||||
|
static bool Prefix(string _command, ClientInfo _cInfo)
|
||||||
|
{
|
||||||
|
if (_command != null && _command.StartsWith("/bot "))
|
||||||
|
{
|
||||||
|
Log.Out($"[Bot] {(_cInfo != null ? _cInfo.playerName : "Server")}: {_command}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
ModInfo.xml
Normal file
9
ModInfo.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xml>
|
||||||
|
<ModInfo>
|
||||||
|
<Name value="BotCommandMod"/>
|
||||||
|
<Description value="Intercepts chat messages starting with /bot and logs them to telnet only"/>
|
||||||
|
<Author value="Claude"/>
|
||||||
|
<Version value="1.0.0"/>
|
||||||
|
</ModInfo>
|
||||||
|
</xml>
|
||||||
Reference in New Issue
Block a user