Use Log.Out to write chat message to telnet-visible server log
This commit is contained in:
@@ -17,12 +17,16 @@ public class CHRANIBotTNG : IModApi
|
|||||||
[HarmonyPatch(typeof(GameManager), "ChatMessageServer")]
|
[HarmonyPatch(typeof(GameManager), "ChatMessageServer")]
|
||||||
public class ChatMessagePatch
|
public class ChatMessagePatch
|
||||||
{
|
{
|
||||||
static bool Prefix(ClientInfo _cInfo, string _msg)
|
static bool Prefix(ClientInfo _cInfo, string _msg, List<int> _recipientEntityIds)
|
||||||
{
|
{
|
||||||
if (_msg != null && _msg.StartsWith("/bot "))
|
if (_msg != null && _msg.StartsWith("/bot "))
|
||||||
{
|
{
|
||||||
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
|
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
|
||||||
Console.WriteLine($"[Bot] {playerName}: {_msg}");
|
|
||||||
|
// Write to server log (visible in telnet)
|
||||||
|
Log.Out($"Chat (from '{playerName}', entity id '{(_cInfo != null ? _cInfo.entityId.ToString() : "-1")}', to '{(_recipientEntityIds != null && _recipientEntityIds.Count > 0 ? "players" : "all")}'): '{_msg}'");
|
||||||
|
|
||||||
|
// Block in-game chat display
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user