diff --git a/package-lock.json b/package-lock.json index 91ed8b7..99a9445 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "bhttp": "^1.2.8", "bottleneck": "^2.19.5", "config": "^3.3.6", + "html-entities": "^2.3.2", "jsdom": "^18.1.0", "linkify-it": "^3.0.3", "simple-node-logger": "^21.8.12", @@ -1906,6 +1907,11 @@ "node": ">=12" } }, + "node_modules/html-entities": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz", + "integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ==" + }, "node_modules/http-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", @@ -5159,6 +5165,11 @@ "whatwg-encoding": "^2.0.0" } }, + "html-entities": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz", + "integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ==" + }, "http-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", diff --git a/package.json b/package.json index 3d0d16d..56c0071 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "bhttp": "^1.2.8", "bottleneck": "^2.19.5", "config": "^3.3.6", + "html-entities": "^2.3.2", "jsdom": "^18.1.0", "linkify-it": "^3.0.3", "simple-node-logger": "^21.8.12", diff --git a/src/games/trivia.js b/src/games/trivia.js index aec2a2a..5066aa4 100644 --- a/src/games/trivia.js +++ b/src/games/trivia.js @@ -2,6 +2,7 @@ const config = require('config'); const timers = require('timers/promises'); +const { decode } = require('html-entities'); const questions = require('../../assets/jeopardy.json'); const shuffle = require('../utils/shuffle'); @@ -171,7 +172,7 @@ async function onMessage(message, context) { const { answer } = game.questions[game.round]; - if (new RegExp(answer, 'i').test(message.body)) { + if (new RegExp(answer, 'i').test(decode(message.body))) { // resolve HTML entities, such as & to & game.answers.push({ user: context.user, answer: message.body,