Add server chat tab and show all four players

This commit is contained in:
2026-09-19 23:05:41 -04:00
parent 44b6415821
commit 070e7fe9f7
5 changed files with 155 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
export interface ChatMessage {
time: string;
guid: string;
slot: number;
player: string;
message: string;
}
function plainText(value: string): string {
return value.replace(/\^[0-9]/g, '').replace(/[\x00-\x1f\x7f]/g, '').trim();
}
/** Preserve log order: elapsed timestamps can reset between matches. */
export function parseGameChat(lines: readonly string[]): ChatMessage[] {
return lines.flatMap(line => {
const match = /^\s*(\d+:[0-5]\d)\s+say;([^;]+);(\d+);([^;]*);(.*)$/.exec(line);
if (!match) return [];
const message = plainText(match[5]);
if (!message) return [];
return [{ time: match[1], guid: match[2], slot: Number(match[3]),
player: plainText(match[4]) || 'Unknown player', message }];
});
}