fix: relay raw IRC bytes instead of re-formatting messages
Preserve original server bytes in IRCMessage.raw and forward those to clients, avoiding parse/format round-trip that altered messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ class IRCMessage:
|
||||
params: list[str] = field(default_factory=list)
|
||||
prefix: str | None = None
|
||||
tags: dict[str, str | None] = field(default_factory=dict)
|
||||
raw: bytes | None = None
|
||||
|
||||
@property
|
||||
def trailing(self) -> str | None:
|
||||
@@ -78,7 +79,7 @@ def parse(data: bytes) -> IRCMessage:
|
||||
command = parts[0].upper()
|
||||
params = parts[1:]
|
||||
|
||||
return IRCMessage(command=command, params=params, prefix=prefix, tags=tags)
|
||||
return IRCMessage(command=command, params=params, prefix=prefix, tags=tags, raw=data + b"\r\n")
|
||||
|
||||
|
||||
def parse_prefix(prefix: str) -> tuple[str, str | None, str | None]:
|
||||
|
||||
@@ -104,9 +104,9 @@ class Router:
|
||||
if max_msgs > 0:
|
||||
await self.backlog.prune(network_name, keep=max_msgs)
|
||||
|
||||
# Forward to all attached clients
|
||||
# Forward to all attached clients (prefer raw bytes from server)
|
||||
clients = self.clients.get(network_name, [])
|
||||
data = msg.format()
|
||||
data = msg.raw if msg.raw else msg.format()
|
||||
for client in clients:
|
||||
try:
|
||||
client.write(data)
|
||||
|
||||
Reference in New Issue
Block a user