From 5b5653c8db355514c3dec7e1b19f239442af766d Mon Sep 17 00:00:00 2001 From: Lucas <33839844+Lucas-Meijer@users.noreply.github.com> Date: Thu, 22 Aug 2024 01:51:02 +0200 Subject: [PATCH] Scavengers: Support HTML in hunts (#10414) --- server/chat-plugins/scavenger-games.ts | 6 +- server/chat-plugins/scavengers.ts | 138 +++++++++++++++++++------ 2 files changed, 109 insertions(+), 35 deletions(-) diff --git a/server/chat-plugins/scavenger-games.ts b/server/chat-plugins/scavenger-games.ts index 927ed3c75158..d5d118acd700 100644 --- a/server/chat-plugins/scavenger-games.ts +++ b/server/chat-plugins/scavenger-games.ts @@ -537,7 +537,7 @@ const TWISTS: {[k: string]: Twist} = { `${this.completed.length > sliceIndex ? `Consolation Prize: ${this.completed.slice(sliceIndex).map(e => `${Utils.escapeHTML(e.name)} [${e.time}]`).join(', ')}
` : ''}
` + `
Solution:
` + `${this.questions.map((q, i) => ( - `${i + 1}) ${Chat.formatText(q.hint)} [${Utils.escapeHTML(q.answer.join(' / '))}]
` + + `${i + 1}) ${this.formatOutput(q.hint)} [${Utils.escapeHTML(q.answer.join(' / '))}]
` + `
Mines: ${mines[i].map(({mine, users}) => Utils.escapeHTML(`${mine}: ${users.join(' / ') || '-'}`)).join('
')}
` )).join("
")}` + `
` @@ -781,11 +781,11 @@ const MODES: {[k: string]: GameMode | string} = { if (staffHost) staffHost.sendTo(this.room, `${targetUser.name} has received their first hint early.`); targetUser.sendTo( this.room, - `|raw|The first hint to the next hunt is: ${Chat.formatText(this.questions[0].hint)}` + `|raw|The first hint to the next hunt is:
${this.formatOutput(this.questions[0].hint)}
` ); targetUser.sendTo( this.room, - `|notify|Early Hint|The first hint to the next hunt is: ${Chat.formatText(this.questions[0].hint)}` + `|notify|Early Hint|The first hint to the next hunt is:
${this.formatOutput(this.questions[0].hint)}
` ); } }, (maxTime - time) * 1000 + 5000); diff --git a/server/chat-plugins/scavengers.ts b/server/chat-plugins/scavengers.ts index ece8db2d7861..86ce16b8f1c3 100644 --- a/server/chat-plugins/scavengers.ts +++ b/server/chat-plugins/scavengers.ts @@ -17,6 +17,7 @@ type GameTypes = 'official' | 'regular' | 'mini' | 'unrated' | 'practice' | 'rec export interface QueuedHunt { hosts: {id: string, name: string, noUpdate?: boolean}[]; questions: (string | string[])[]; + isHTML: boolean; staffHostId: string; staffHostName: string; gameType: GameTypes; @@ -226,19 +227,19 @@ function formatQueue(queue: QueuedHunt[] | undefined, viewer: User, room: Room, return Utils.html`[${q.join(' / ')}]
`; } else { q = q as string; - return Utils.escapeHTML(q); + return item.isHTML ? q : Utils.escapeHTML(q); } } ).join(" "); } else { questions = `[${item.questions.length / 2} hidden questions]`; } - return `${removeButton}${startButton} ${unratedText}${hosts}${queuedBy}${questions}`; + return `${removeButton}${startButton} ${unratedText}${hosts}${queuedBy}
${questions}
`; }).join(""); } else { buffer = `The scavenger queue is currently empty.`; } - let template = `
${showStaff ? buffer : buffer.replace(/.+?<\/button>/gi, '')}
ByQuestions
`; + let template = `
${showStaff ? buffer : buffer.replace(/.+?<\/button>/gi, '')}
ByQuestions
`; if (showStaff) { template += `
Auto Timer Duration: ${timerDuration} minutesAuto Dequeue: