diff --git a/server/chat-plugins/helptickets.ts b/server/chat-plugins/helptickets.ts
index 8e53094399..1fc208d324 100644
--- a/server/chat-plugins/helptickets.ts
+++ b/server/chat-plugins/helptickets.ts
@@ -401,6 +401,31 @@ export class HelpTicket extends Rooms.RoomGame {
void (room as GameRoom).uploadReplay(user, conn, "forpunishment");
}
}
+ static visualizeBattleLogs(rooms: string[]) {
+ const existingRooms = rooms.map(r => Rooms.get(r)).filter(r => r?.type !== 'chat');
+ if (existingRooms.length) {
+ const chatBuffer = existingRooms.map(room => {
+ // there is no reason this should happen (room && room.type check above in .filter).
+ // but typescript is stupid. so appeasement.
+ if (!room) return '';
+ const log = room.log.log.filter(l => l.startsWith('|c|'));
+ if (!log?.length) return '';
+ let innerBuf = `
${room.title}
`;
+ for (const line of log) {
+ const [,, username, message] = Utils.splitFirst(line, '|', 3);
+ innerBuf += Utils.html`
${username}: ${message}
`;
+ }
+ innerBuf += `
`;
+ return innerBuf;
+ }).filter(Boolean).join('');
+ if (chatBuffer) {
+ return (
+ `Battle chat logs:
` +
+ `${chatBuffer}
`
+ );
+ }
+ }
+ }
static getTextButton(ticket: TicketState & {text: [string, string]}) {
let buf = '';
const titleBuf = [...ticket.text[0].split('\n'), ...ticket.text[1].split('\n')].slice(0, 3);
@@ -743,9 +768,12 @@ export const textTickets: {[k: string]: TextTicketInfo} = {
}
buf += `
`;
if (sharedBattles.length) {
- buf += `Shared battles
`;
- buf += sharedBattles.map(url => Chat.formatText(`<<${url}>>`)).join(', ');
- buf += ` `;
+ const battleLogHTML = HelpTicket.visualizeBattleLogs(sharedBattles);
+ if (battleLogHTML) {
+ buf += `
`;
+ buf += battleLogHTML;
+ buf += `
`;
+ }
}
if (replays.length) {
buf += `Battle links
`;
@@ -830,28 +858,8 @@ export const textTickets: {[k: string]: TextTicketInfo} = {
}
buf += `Battle links: ${rooms.map(url => Chat.formatText(`<<${url}>>`)).join(', ')}
`;
buf += `
`;
- const existingRooms = rooms.map(r => Rooms.get(r)).filter(r => r?.type !== 'chat');
- if (existingRooms.length) {
- const chatBuffer = existingRooms.map(room => {
- // there is no reason this should happen (room && room.type check above in .filter).
- // but typescript is stupid. so appeasement.
- if (!room) return '';
- const log = room.log.log.filter(l => l.startsWith('|c|'));
- if (!log?.length) return '';
- let innerBuf = `${room.title}
`;
- for (const line of log) {
- const [,, username, message] = Utils.splitFirst(line, '|', 3);
- innerBuf += Utils.html`
${username}: ${message}
`;
- }
- innerBuf += `
`;
- return innerBuf;
- }).filter(Boolean).join('');
- if (chatBuffer) {
- buf += `Battle chat logs:
`;
- buf += chatBuffer;
- buf += `
`;
- }
- }
+ const battleLogHTML = HelpTicket.visualizeBattleLogs(rooms);
+ if (battleLogHTML) buf += battleLogHTML;
return buf;
},
},