Add FileInputBot for non-interactive debugging and fix NbtToString crash

FileInputBot (ChatBots/FileInputBot.cs):
- New ChatBot that monitors a text file (default: mcc_input.txt) for
  commands, enabling MCC control from Cursor Shell or any non-interactive
  environment where stdin is not available
- Activated by setting MCC_FILE_INPUT env var (e.g. MCC_FILE_INPUT=1)
- Polls every ~500ms for new lines appended to the file
- Lines starting with "/" are sent as server chat/commands
- Other lines are executed as MCC internal commands (same as console input)
- File path overridable via MCC_INPUT_FILE env var

McClient.cs:
- Load FileInputBot when MCC_FILE_INPUT environment variable is set

ChatParser.cs - NbtToString:
- Fix InvalidCastException when NBT "text" or nameless root tag values
  are Int32 instead of String (happens with 1.20.6 SystemChat packets
  containing numeric values in the chat component tree)
- Replace direct (string) casts with ?.ToString() ?? string.Empty

Made-with: Cursor
This commit is contained in:
BruceChen 2026-03-19 00:45:51 +08:00
parent 8eac21b4a4
commit 967f67190c
3 changed files with 110 additions and 6 deletions

View file

@ -425,8 +425,8 @@ namespace MinecraftClient
if (Config.ChatBot.ScriptScheduler.Enabled) { BotLoad(new ScriptScheduler()); }
if (Config.ChatBot.TelegramBridge.Enabled) { BotLoad(new TelegramBridge()); }
if (Config.ChatBot.ItemsCollector.Enabled) { BotLoad(new ItemsCollector()); }
//Add your ChatBot here by uncommenting and adapting
//BotLoad(new ChatBots.YourBot());
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MCC_FILE_INPUT")))
BotLoad(new FileInputBot());
}
/// <summary>