using System; using Server.Accounting; using Server.Commands; using Server.Mobiles; namespace Server.Custom { /// /// Exercises the in-game moderation-audit forwarding (BridgeModerationAudit) without a game /// client, so the CommandLogging.OnWrite patch and the admin.audit normalizer can be verified /// end-to-end from a stub sidecar. /// /// - Broadcast is a *genuine* trigger: CommandSystem.Handle runs [bcast, which raises /// EventSink.Command exactly as a staff keystroke would. /// - Ban/kick can't complete headlessly (they arm a target cursor with no client to click), /// so we call CommandLogging.WriteLine with the stock KickCommand line format — the same /// call that command makes at Commands.cs:1211, which is the point we tap. /// - A non-moderation log line confirms the normalizer ignores everything else. /// /// Test scaffolding. Never deployed. Gated behind Bridge.AuditProbeOnStart (absent in a /// shipped Bridge.cfg, so Config.Get returns false and it never runs in production). /// public static class BridgeAuditProbe { public static void Initialize() { if (Config.Get("Bridge.AuditProbeOnStart", false)) EventSink.ServerStarted += () => Timer.DelayCall(TimeSpan.FromSeconds(4.0), Run); } private static void Run() { try { var staffAcct = Accounting.Accounts.GetAccount("whitlocktech") as Account; var targetAcct = Accounting.Accounts.GetAccount("seed_010") as Account; var from = staffAcct == null ? null : staffAcct[0]; var target = targetAcct == null ? null : targetAcct[0]; if (from == null || target == null) { Console.WriteLine("[AuditProbe] need whitlocktech + seed_010 chars; seed the world first"); return; } Console.WriteLine("[AuditProbe] genuine broadcast via [bcast ..."); CommandSystem.Handle(from, CommandSystem.Prefix + "bcast in-game audit probe"); Console.WriteLine("[AuditProbe] simulating a resolved ban log line ..."); CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format(from), "banning", CommandLogging.Format(target)); Console.WriteLine("[AuditProbe] simulating a resolved kick log line ..."); CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format(from), "kicking", CommandLogging.Format(target)); Console.WriteLine("[AuditProbe] a non-moderation line (should be ignored) ..."); CommandLogging.WriteLine(from, "{0} {1} used command '{2}'", from.AccessLevel, CommandLogging.Format(from), "Go 1 1 0"); Console.WriteLine("[AuditProbe] done"); } catch (Exception ex) { Console.WriteLine("[AuditProbe] FAILED: " + ex); } } } }