Compare commits

..

2 Commits

Author SHA1 Message Date
Niels Simenon 2d48a18c16 1.19.2 2022-11-01 05:26:06 +01:00
Niels Simenon 007773f38c Fixed style bypass. 2022-11-01 05:26:04 +01:00
6 changed files with 18 additions and 19 deletions

View File

@ -54,6 +54,7 @@ module.exports = {
magenta: 'magenta', magenta: 'magenta',
pink: 'pink', pink: 'pink',
grey: 'shadow', grey: 'shadow',
silver: 'shadow',
}, },
trivia: { trivia: {
mode: 'first', // first or timeout mode: 'first', // first or timeout

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.19.1", "version": "1.19.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.19.1", "version": "1.19.2",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"bhttp": "^1.2.8", "bhttp": "^1.2.8",

View File

@ -1,6 +1,6 @@
{ {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.19.1", "version": "1.19.2",
"description": "Game host for SChat 2-powered chat sites", "description": "Game host for SChat 2-powered chat sites",
"main": "src/app.js", "main": "src/app.js",
"scripts": { "scripts": {

View File

@ -221,7 +221,7 @@ function onMessage(message, context) {
module.exports = { module.exports = {
name: 'Mash', name: 'Mash',
commands: ['mash', ...defineCommands, ...resolveCommands], commands: ['mash', 'wordmash', ...defineCommands, ...resolveCommands],
onCommand, onCommand,
onMessage, 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].`, 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].`,

View File

@ -49,7 +49,7 @@ async function playRound(context, round = 0) {
const question = game.questions[round]; 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}`); context.logger.info(`Trivia asked "${question.question}" with answer: ${question.answer}`);
try { try {

View File

@ -39,29 +39,19 @@ function shieldMethods(methods) {
const styleMethods = (() => { const styleMethods = (() => {
if (config.platform === 'irc') { if (config.platform === 'irc') {
return shieldMethods({ return {
...styles, ...styles,
code: bypass, code: bypass,
}); };
} }
if (config.platform === 'schat') { if (config.platform === 'schat') {
const methods = { return {
bold: schatBold, bold: schatBold,
italic: schatItalic, italic: schatItalic,
code: schatCode, code: schatCode,
...Object.fromEntries(Object.entries(config.schatColorAliases).map(([color, value]) => [color, (text) => schatColor(text, value)])), ...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; return null;
@ -74,4 +64,12 @@ const expandedMethods = {
answer: (value) => styleMethods.bold(styleMethods.yellow(value)), 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);