From 007773f38cee62f0b70d8bf889992795db7a3ee6 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Tue, 1 Nov 2022 05:26:04 +0100 Subject: [PATCH] Fixed style bypass. --- config/default.js | 1 + src/games/mash.js | 2 +- src/games/trivia.js | 2 +- src/utils/style.js | 26 ++++++++++++-------------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/config/default.js b/config/default.js index 6eb4720..a327f41 100755 --- a/config/default.js +++ b/config/default.js @@ -54,6 +54,7 @@ module.exports = { magenta: 'magenta', pink: 'pink', grey: 'shadow', + silver: 'shadow', }, trivia: { mode: 'first', // first or timeout diff --git a/src/games/mash.js b/src/games/mash.js index 3bd070e..0e10045 100755 --- a/src/games/mash.js +++ b/src/games/mash.js @@ -221,7 +221,7 @@ function onMessage(message, context) { module.exports = { name: 'Mash', - commands: ['mash', ...defineCommands, ...resolveCommands], + commands: ['mash', 'wordmash', ...defineCommands, ...resolveCommands], onCommand, onMessage, help: `Resolve the anagram. Get a new mash with ${config.prefix}mash [length], look up definitions with ${config.prefix}define [word], resolve an anagram (that's not currently in play) with ${config.prefix}solve [anagram].`, diff --git a/src/games/trivia.js b/src/games/trivia.js index 274b5a5..7cdaac0 100755 --- a/src/games/trivia.js +++ b/src/games/trivia.js @@ -49,7 +49,7 @@ async function playRound(context, round = 0) { const question = game.questions[round]; - context.sendMessage(`${style.bold(style.pink(`Question ${round + 1}/${game.questions.length}`))} ${style.silver(`(${question.category})`)}: ${question.question}`, context.room.id); + context.sendMessage(`${style.bold(style.pink(`Question ${round + 1}/${game.questions.length}`))} ${style.grey(`(${question.category})`)}: ${question.question}`, context.room.id); context.logger.info(`Trivia asked "${question.question}" with answer: ${question.answer}`); try { diff --git a/src/utils/style.js b/src/utils/style.js index 9af8ea4..6b0f37e 100755 --- a/src/utils/style.js +++ b/src/utils/style.js @@ -39,29 +39,19 @@ function shieldMethods(methods) { const styleMethods = (() => { if (config.platform === 'irc') { - return shieldMethods({ + return { ...styles, code: bypass, - }); + }; } if (config.platform === 'schat') { - const methods = { + return { bold: schatBold, italic: schatItalic, code: schatCode, ...Object.fromEntries(Object.entries(config.schatColorAliases).map(([color, value]) => [color, (text) => schatColor(text, value)])), }; - - const handler = { - get(target, prop) { - return target[prop] || bypass; - }, - }; - - const shieldedMethods = shieldMethods(methods); - - return new Proxy(shieldedMethods, handler); } return null; @@ -74,4 +64,12 @@ const expandedMethods = { answer: (value) => styleMethods.bold(styleMethods.yellow(value)), }; -module.exports = expandedMethods; +const handler = { + get(target, prop) { + return target[prop] || bypass; + }, +}; + +const shieldedMethods = shieldMethods(expandedMethods); + +module.exports = new Proxy(shieldedMethods, handler);