diff --git a/server/chat-plugins/mafia.ts b/server/chat-plugins/mafia.ts index a3c137bf5cc3..3eb4018fac4b 100644 --- a/server/chat-plugins/mafia.ts +++ b/server/chat-plugins/mafia.ts @@ -4000,6 +4000,13 @@ export const commands: Chat.ChatCommands = { async listdata(target, room, user, connection, cmd, message) { if (!this.runBroadcast()) return false; + // Fix errors + // Fix searching on roles + // Fix random (do not pick empty) + + // Future: tags + // Future: or + // Determine non-search targets first, afterwards searching is done with the remainder let targets = target.split(',').map(x => x.trim()); @@ -4055,6 +4062,8 @@ export const commands: Chat.ChatCommands = { } let search = function (entries: any[], searchTarget) { + if(typeof(entries) == 'undefined') return entries; //Hotpatch + if (searchTarget.length == 0) return entries; const negation = searchTarget[0] == '!'; @@ -4064,7 +4073,7 @@ export const commands: Chat.ChatCommands = { if (searchType == `themes` && searchTarget.includes(`players`)) { const inequalities = ['<=', '>=', '=', '<', '>']; const inequality = inequalities.find(x => searchTarget.includes(x)); - if (!inequality) return this.errorReply(`Please provide a valid inequality for the players.`); + if (!inequality) return entries; // this.errorReply(`Please provide a valid inequality for the players.`); const players = searchTarget.split(inequality)[1].trim(); if (((players != null) && @@ -4074,7 +4083,7 @@ export const commands: Chat.ChatCommands = { else if (inequality == '<' || inequality == '<=') entries = entries.filter(([key, data]) => ([...Array(+players + (inequality == '<=' ? +1 : +0)).keys()]).some(playerCount => playerCount in (MafiaData[searchType][key]))); else if (inequality == '>' || inequality == '>=') entries = entries.filter(([key, data]) => ([...Array(30 - players).keys()].map(num => +num + +players + (inequality == '>=' ? +0 : +1))).some(playerCount => playerCount in (MafiaData[searchType][key]))); } else { - return this.errorReply(`Please ensure the amount of players is numeric.`); + return entries; // this.errorReply(`Please ensure the amount of players is numeric.`); } } else if ((searchType == `roles`) && toID(searchTarget) in MafiaData[`themes`]) { @@ -4136,9 +4145,12 @@ export const commands: Chat.ChatCommands = { if (!hidden) entries = entries.filter(([key, data]) => !MafiaData[searchType][key][`tags`].includes(`hidden`)); for (let i = 0; i < targets.length; i++) { - entries = targets[i].split('|').map(x => x.trim()).map(searchTerm => search(entries.slice(), searchTerm)).reduce((aggregate, result) => [...new Set([...aggregate, ...result])]); + entries = targets[i].split('|').map(x => x.trim()).map(searchTerm => search.call(this, entries.slice(), searchTerm)).reduce((aggregate, result) => [...new Set([...aggregate, ...result])]); } + console.log(typeof(entries)); + if(typeof(entries) == 'undefined') return; //Hotpatch + if (random) entries = shuffle(entries); if (number > 0) entries = entries.slice(0, number) diff --git a/server/chat-plugins/scavengers.ts b/server/chat-plugins/scavengers.ts index ece8db2d7861..51c9541b766b 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,7 +227,7 @@ 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(" "); @@ -238,7 +239,7 @@ function formatQueue(queue: QueuedHunt[] | undefined, viewer: User, room: Room, } else { buffer = `