diff --git a/server/chat-plugins/helptickets.ts b/server/chat-plugins/helptickets.ts index 58f1a33edc..8c70174d8b 100644 --- a/server/chat-plugins/helptickets.ts +++ b/server/chat-plugins/helptickets.ts @@ -35,7 +35,9 @@ interface TextTicketInfo { input: string, context: string, pageId: string, user: User, reportTarget?: string ) => boolean | string[] | Promise; title: string; - getReviewDisplay: (ticket: TicketState & {text: [string, string]}, staff: User, conn: Connection) => string | void; + getReviewDisplay: ( + ticket: TicketState & {text: [string, string]}, staff: User, conn: Connection + ) => Promise | string | void; onSubmit?: (ticket: TicketState, text: [string, string], submitter: User, conn: Connection) => void; } @@ -713,6 +715,43 @@ const cheatingScenarios = [ ]; export const textTickets: {[k: string]: TextTicketInfo} = { + pmharassment: { + title: "Who's harassing you in PMs?", + checker(input) { + if (!Users.get(input)) { + return ['That user was not found.']; + } + return true; + }, + getReviewDisplay(ticket, staff, conn) { + let buf = ''; + const sharedBattles = getCommonBattles(ticket.userid, null, toID(ticket.text[0]), null, conn); + const replays = getBattleLinks(ticket.text[1]).concat(getBattleLinks(ticket.text[1])); + buf += `Reported user: ${ticket.text[0]}
`; + buf += `

Punish:
`; + const replayString = replays.concat(sharedBattles).map(u => `https://${Config.routes.replays}/${u}`).join(', '); + const proofString = `spoiler:PMs with ${ticket.userid}${replayString ? `, ${replayString}` : ''}`; + for (const [name, punishment] of [['Lock', 'lock'], ['Weeklock', 'weeklock'], ['Warn', 'warn']]) { + buf += `
`; + buf += `
`; + buf += `Optional reason: `; + buf += `

`; + } + buf += `

`; + if (sharedBattles.length) { + buf += `
Shared battles`; + buf += sharedBattles.map(url => `<<${url}>>`).join(', '); + buf += `
`; + } + if (replays.length) { + buf += `
Battle links`; + buf += replays.map(url => `<<${url}>>`).join(', '); + buf += `
`; + } + + return buf; + }, + }, inapname: { title: "What's the inappropriate username?", checker(input) { @@ -1157,7 +1196,7 @@ export const pages: Chat.PageTable = { buf += ``; return buf; }, - text(query, user, connection) { + async text(query, user, connection) { if (!user.named) return Rooms.RETRY_AFTER_LOGIN; this.title = this.tr`Queued Tickets`; this.checkCan('lock'); @@ -1188,7 +1227,7 @@ export const pages: Chat.PageTable = { } else if (ticket.claimed) { buf += `Claimed: ${ticket.claimed}
`; } - buf += ticketInfo.getReviewDisplay(ticket as TicketState & {text: [string, string]}, user, connection); + buf += await ticketInfo.getReviewDisplay(ticket as TicketState & {text: [string, string]}, user, connection); buf += `
`; buf += `
`; const [text, context] = ticket.text;