Add server chat tab and show all four players
This commit is contained in:
@@ -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 }];
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user