From 3c760b0bd87649549536e5672d0bb090692a5120 Mon Sep 17 00:00:00 2001 From: HueByte Date: Mon, 23 Feb 2026 10:54:02 +0100 Subject: [PATCH] feat: improve IRC command handling with debug logging for incoming messages --- src/EchoHub.Server.Irc/IrcClientConnection.cs | 5 +++-- src/EchoHub.Server.Irc/IrcCommandHandler.cs | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/EchoHub.Server.Irc/IrcClientConnection.cs b/src/EchoHub.Server.Irc/IrcClientConnection.cs index bbce314..3b1b8e4 100644 --- a/src/EchoHub.Server.Irc/IrcClientConnection.cs +++ b/src/EchoHub.Server.Irc/IrcClientConnection.cs @@ -44,8 +44,9 @@ public sealed class IrcClientConnection : IAsyncDisposable public IrcClientConnection(TcpClient tcpClient, Stream stream) { _tcpClient = tcpClient; - _reader = new StreamReader(stream, Encoding.UTF8); - _writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true, NewLine = "\r\n" }; + var utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); + _reader = new StreamReader(stream, utf8NoBom); + _writer = new StreamWriter(stream, utf8NoBom) { AutoFlush = true, NewLine = "\r\n" }; } public async Task ReadLineAsync(CancellationToken ct) diff --git a/src/EchoHub.Server.Irc/IrcCommandHandler.cs b/src/EchoHub.Server.Irc/IrcCommandHandler.cs index f84a9f0..baf53e9 100644 --- a/src/EchoHub.Server.Irc/IrcCommandHandler.cs +++ b/src/EchoHub.Server.Irc/IrcCommandHandler.cs @@ -44,6 +44,8 @@ public sealed class IrcCommandHandler line = line.TrimEnd('\r', '\n'); if (string.IsNullOrWhiteSpace(line)) continue; + _logger.LogDebug("IRC < {Id}: {Line}", _conn.ConnectionId, line); + var msg = IrcMessage.Parse(line); try