From acf60eeca0621a1667ef63aae295362b1b82709c Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 28 Oct 2022 00:22:00 +0200 Subject: [PATCH] Added Magic 8-Ball game. --- .editorconfig | 0 .eslintrc | 0 .gitignore | 0 .nvmrc | 0 README.md | 0 assets/curate-jeopardy.js | 0 assets/dictionary-to-mash.js | 0 assets/dictionary.json | 0 assets/jeopardy.json | 0 assets/mash-average.js | 0 assets/mash-words_short.json | 0 assets/trivia/questions_00 | 0 assets/trivia/questions_01 | 0 assets/trivia/questions_02 | 0 assets/trivia/questions_03 | 0 assets/trivia/questions_04 | 0 assets/trivia/questions_05 | 0 assets/trivia/questions_06 | 0 assets/trivia/questions_07 | 0 assets/trivia/questions_08 | 0 assets/trivia/questions_09 | 0 assets/trivia/questions_10 | 0 assets/trivia/questions_11 | 0 assets/trivia/questions_12 | 0 assets/trivia/questions_13 | 0 assets/trivia/questions_14 | 0 assets/trivia/questions_15 | 0 assets/trivia/questions_16 | 0 assets/trivia/questions_17 | 0 assets/trivia/questions_18 | 0 assets/trivia/questions_19 | 0 assets/trivia/questions_20 | 0 assets/trivia/questions_21 | 0 assets/trivia/questions_22 | 0 assets/trivia/questions_23 | 0 assets/trivia/questions_24 | 0 assets/trivia/questions_25 | 0 assets/trivia/questions_26 | 0 assets/trivia/questions_27 | 0 assets/trivia/questions_28 | 0 assets/trivia/questions_29 | 0 assets/trivia/questions_30 | 0 assets/trivia/questions_31 | 0 assets/trivia/questions_32 | 0 assets/trivia/questions_33 | 0 assets/trivia/questions_34 | 0 assets/trivia/questions_35 | 0 assets/trivia/questions_36 | 0 assets/trivia/questions_37 | 0 assets/trivia/questions_38 | 0 assets/trivia/questions_39 | 0 assets/trivia/questions_40 | 0 assets/trivia/questions_41 | 0 assets/trivia/questions_42 | 0 assets/trivia/questions_43 | 0 assets/trivia/questions_44 | 0 assets/trivia/questions_45 | 0 assets/trivia/questions_46 | 0 assets/trivia/questions_47 | 0 assets/trivia/questions_48 | 0 assets/trivia/questions_49 | 0 assets/trivia/questions_50 | 0 assets/trivia/questions_51 | 0 assets/trivia/questions_52 | 0 assets/trivia/questions_53 | 0 assets/trivia/questions_54 | 0 assets/trivia/questions_55 | 0 assets/trivia/questions_56 | 0 assets/trivia/questions_57 | 0 assets/trivia/questions_58 | 0 assets/trivia/questions_59 | 0 assets/trivia/questions_60 | 0 assets/trivia/questions_61 | 0 assets/trivia/questions_62 | 0 assets/trivia/questions_63 | 0 assets/trivia/questions_64 | 0 assets/trivia/questions_65 | 0 assets/trivia/questions_66 | 0 config/default.js | 7 ++- ecosystem.config.js | 0 package-lock.json | 11 ++++ package.json | 1 + src/app.js | 0 src/games/8ball.js | 102 +++++++++++++++++++++++++++++++ src/games/cursed.js | 0 src/games/dice.js | 0 src/games/duck.js | 0 src/games/help.js | 0 src/games/kill.js | 0 src/games/letters.js | 0 src/games/mash.js | 0 src/games/ping.js | 0 src/games/rock-paper-scissors.js | 0 src/games/say.js | 0 src/games/trivia.js | 0 src/games/uptime.js | 0 src/irc.js | 0 src/play.js | 6 +- src/schat.js | 0 src/utils/get-leaders.js | 0 src/utils/get-word-key.js | 0 src/utils/pick-random.js | 0 src/utils/shuffle.js | 0 src/utils/style.js | 2 +- 104 files changed, 124 insertions(+), 5 deletions(-) mode change 100644 => 100755 .editorconfig mode change 100644 => 100755 .eslintrc mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .nvmrc mode change 100644 => 100755 README.md mode change 100644 => 100755 assets/curate-jeopardy.js mode change 100644 => 100755 assets/dictionary-to-mash.js mode change 100644 => 100755 assets/dictionary.json mode change 100644 => 100755 assets/jeopardy.json mode change 100644 => 100755 assets/mash-average.js mode change 100644 => 100755 assets/mash-words_short.json mode change 100644 => 100755 assets/trivia/questions_00 mode change 100644 => 100755 assets/trivia/questions_01 mode change 100644 => 100755 assets/trivia/questions_02 mode change 100644 => 100755 assets/trivia/questions_03 mode change 100644 => 100755 assets/trivia/questions_04 mode change 100644 => 100755 assets/trivia/questions_05 mode change 100644 => 100755 assets/trivia/questions_06 mode change 100644 => 100755 assets/trivia/questions_07 mode change 100644 => 100755 assets/trivia/questions_08 mode change 100644 => 100755 assets/trivia/questions_09 mode change 100644 => 100755 assets/trivia/questions_10 mode change 100644 => 100755 assets/trivia/questions_11 mode change 100644 => 100755 assets/trivia/questions_12 mode change 100644 => 100755 assets/trivia/questions_13 mode change 100644 => 100755 assets/trivia/questions_14 mode change 100644 => 100755 assets/trivia/questions_15 mode change 100644 => 100755 assets/trivia/questions_16 mode change 100644 => 100755 assets/trivia/questions_17 mode change 100644 => 100755 assets/trivia/questions_18 mode change 100644 => 100755 assets/trivia/questions_19 mode change 100644 => 100755 assets/trivia/questions_20 mode change 100644 => 100755 assets/trivia/questions_21 mode change 100644 => 100755 assets/trivia/questions_22 mode change 100644 => 100755 assets/trivia/questions_23 mode change 100644 => 100755 assets/trivia/questions_24 mode change 100644 => 100755 assets/trivia/questions_25 mode change 100644 => 100755 assets/trivia/questions_26 mode change 100644 => 100755 assets/trivia/questions_27 mode change 100644 => 100755 assets/trivia/questions_28 mode change 100644 => 100755 assets/trivia/questions_29 mode change 100644 => 100755 assets/trivia/questions_30 mode change 100644 => 100755 assets/trivia/questions_31 mode change 100644 => 100755 assets/trivia/questions_32 mode change 100644 => 100755 assets/trivia/questions_33 mode change 100644 => 100755 assets/trivia/questions_34 mode change 100644 => 100755 assets/trivia/questions_35 mode change 100644 => 100755 assets/trivia/questions_36 mode change 100644 => 100755 assets/trivia/questions_37 mode change 100644 => 100755 assets/trivia/questions_38 mode change 100644 => 100755 assets/trivia/questions_39 mode change 100644 => 100755 assets/trivia/questions_40 mode change 100644 => 100755 assets/trivia/questions_41 mode change 100644 => 100755 assets/trivia/questions_42 mode change 100644 => 100755 assets/trivia/questions_43 mode change 100644 => 100755 assets/trivia/questions_44 mode change 100644 => 100755 assets/trivia/questions_45 mode change 100644 => 100755 assets/trivia/questions_46 mode change 100644 => 100755 assets/trivia/questions_47 mode change 100644 => 100755 assets/trivia/questions_48 mode change 100644 => 100755 assets/trivia/questions_49 mode change 100644 => 100755 assets/trivia/questions_50 mode change 100644 => 100755 assets/trivia/questions_51 mode change 100644 => 100755 assets/trivia/questions_52 mode change 100644 => 100755 assets/trivia/questions_53 mode change 100644 => 100755 assets/trivia/questions_54 mode change 100644 => 100755 assets/trivia/questions_55 mode change 100644 => 100755 assets/trivia/questions_56 mode change 100644 => 100755 assets/trivia/questions_57 mode change 100644 => 100755 assets/trivia/questions_58 mode change 100644 => 100755 assets/trivia/questions_59 mode change 100644 => 100755 assets/trivia/questions_60 mode change 100644 => 100755 assets/trivia/questions_61 mode change 100644 => 100755 assets/trivia/questions_62 mode change 100644 => 100755 assets/trivia/questions_63 mode change 100644 => 100755 assets/trivia/questions_64 mode change 100644 => 100755 assets/trivia/questions_65 mode change 100644 => 100755 assets/trivia/questions_66 mode change 100644 => 100755 config/default.js mode change 100644 => 100755 ecosystem.config.js mode change 100644 => 100755 package-lock.json mode change 100644 => 100755 package.json mode change 100644 => 100755 src/app.js create mode 100644 src/games/8ball.js mode change 100644 => 100755 src/games/cursed.js mode change 100644 => 100755 src/games/dice.js mode change 100644 => 100755 src/games/duck.js mode change 100644 => 100755 src/games/help.js mode change 100644 => 100755 src/games/kill.js mode change 100644 => 100755 src/games/letters.js mode change 100644 => 100755 src/games/mash.js mode change 100644 => 100755 src/games/ping.js mode change 100644 => 100755 src/games/rock-paper-scissors.js mode change 100644 => 100755 src/games/say.js mode change 100644 => 100755 src/games/trivia.js mode change 100644 => 100755 src/games/uptime.js mode change 100644 => 100755 src/irc.js mode change 100644 => 100755 src/play.js mode change 100644 => 100755 src/schat.js mode change 100644 => 100755 src/utils/get-leaders.js mode change 100644 => 100755 src/utils/get-word-key.js mode change 100644 => 100755 src/utils/pick-random.js mode change 100644 => 100755 src/utils/shuffle.js mode change 100644 => 100755 src/utils/style.js diff --git a/.editorconfig b/.editorconfig old mode 100644 new mode 100755 diff --git a/.eslintrc b/.eslintrc old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.nvmrc b/.nvmrc old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/assets/curate-jeopardy.js b/assets/curate-jeopardy.js old mode 100644 new mode 100755 diff --git a/assets/dictionary-to-mash.js b/assets/dictionary-to-mash.js old mode 100644 new mode 100755 diff --git a/assets/dictionary.json b/assets/dictionary.json old mode 100644 new mode 100755 diff --git a/assets/jeopardy.json b/assets/jeopardy.json old mode 100644 new mode 100755 diff --git a/assets/mash-average.js b/assets/mash-average.js old mode 100644 new mode 100755 diff --git a/assets/mash-words_short.json b/assets/mash-words_short.json old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_00 b/assets/trivia/questions_00 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_01 b/assets/trivia/questions_01 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_02 b/assets/trivia/questions_02 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_03 b/assets/trivia/questions_03 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_04 b/assets/trivia/questions_04 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_05 b/assets/trivia/questions_05 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_06 b/assets/trivia/questions_06 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_07 b/assets/trivia/questions_07 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_08 b/assets/trivia/questions_08 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_09 b/assets/trivia/questions_09 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_10 b/assets/trivia/questions_10 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_11 b/assets/trivia/questions_11 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_12 b/assets/trivia/questions_12 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_13 b/assets/trivia/questions_13 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_14 b/assets/trivia/questions_14 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_15 b/assets/trivia/questions_15 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_16 b/assets/trivia/questions_16 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_17 b/assets/trivia/questions_17 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_18 b/assets/trivia/questions_18 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_19 b/assets/trivia/questions_19 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_20 b/assets/trivia/questions_20 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_21 b/assets/trivia/questions_21 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_22 b/assets/trivia/questions_22 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_23 b/assets/trivia/questions_23 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_24 b/assets/trivia/questions_24 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_25 b/assets/trivia/questions_25 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_26 b/assets/trivia/questions_26 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_27 b/assets/trivia/questions_27 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_28 b/assets/trivia/questions_28 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_29 b/assets/trivia/questions_29 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_30 b/assets/trivia/questions_30 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_31 b/assets/trivia/questions_31 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_32 b/assets/trivia/questions_32 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_33 b/assets/trivia/questions_33 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_34 b/assets/trivia/questions_34 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_35 b/assets/trivia/questions_35 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_36 b/assets/trivia/questions_36 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_37 b/assets/trivia/questions_37 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_38 b/assets/trivia/questions_38 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_39 b/assets/trivia/questions_39 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_40 b/assets/trivia/questions_40 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_41 b/assets/trivia/questions_41 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_42 b/assets/trivia/questions_42 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_43 b/assets/trivia/questions_43 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_44 b/assets/trivia/questions_44 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_45 b/assets/trivia/questions_45 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_46 b/assets/trivia/questions_46 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_47 b/assets/trivia/questions_47 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_48 b/assets/trivia/questions_48 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_49 b/assets/trivia/questions_49 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_50 b/assets/trivia/questions_50 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_51 b/assets/trivia/questions_51 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_52 b/assets/trivia/questions_52 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_53 b/assets/trivia/questions_53 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_54 b/assets/trivia/questions_54 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_55 b/assets/trivia/questions_55 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_56 b/assets/trivia/questions_56 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_57 b/assets/trivia/questions_57 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_58 b/assets/trivia/questions_58 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_59 b/assets/trivia/questions_59 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_60 b/assets/trivia/questions_60 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_61 b/assets/trivia/questions_61 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_62 b/assets/trivia/questions_62 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_63 b/assets/trivia/questions_63 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_64 b/assets/trivia/questions_64 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_65 b/assets/trivia/questions_65 old mode 100644 new mode 100755 diff --git a/assets/trivia/questions_66 b/assets/trivia/questions_66 old mode 100644 new mode 100755 diff --git a/config/default.js b/config/default.js old mode 100644 new mode 100755 index 4b343ea..a193d5d --- a/config/default.js +++ b/config/default.js @@ -21,8 +21,13 @@ module.exports = { greeting: 'Hi, I am aisha, your game host!', usernamePrefix: '@', channels: ['GamesNight'], - games: ['mash', 'trivia', 'letters', 'duck', 'dice', 'rock-paper-scissors', 'ping', 'say', 'kill', 'uptime', 'help'], + games: ['mash', 'trivia', 'letters', 'duck', '8ball', 'dice', 'rock-paper-scissors', 'ping', 'say', 'kill', 'uptime', 'help'], schatColors: { + white: 'white', + blue: 'var(--message-40)', + navy: 'var(--message-41)', + }, + schatColorAliases: { red: 'red', orange: 'orange', yellow: 'yellow', diff --git a/ecosystem.config.js b/ecosystem.config.js old mode 100644 new mode 100755 diff --git a/package-lock.json b/package-lock.json old mode 100644 new mode 100755 index 9a9bd6c..469baab --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "jsdom": "^18.1.0", "linkify-it": "^3.0.3", "simple-node-logger": "^21.8.12", + "string-similarity": "^4.0.4", "tensify": "^0.0.4", "ws": "^8.2.3", "yargs": "^17.2.1" @@ -3250,6 +3251,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/string-similarity": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", + "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -6334,6 +6340,11 @@ "safe-buffer": "~5.1.0" } }, + "string-similarity": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", + "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 8c903e0..121337e --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "jsdom": "^18.1.0", "linkify-it": "^3.0.3", "simple-node-logger": "^21.8.12", + "string-similarity": "^4.0.4", "tensify": "^0.0.4", "ws": "^8.2.3", "yargs": "^17.2.1" diff --git a/src/app.js b/src/app.js old mode 100644 new mode 100755 diff --git a/src/games/8ball.js b/src/games/8ball.js new file mode 100644 index 0000000..a79566f --- /dev/null +++ b/src/games/8ball.js @@ -0,0 +1,102 @@ +'use strict'; + +const config = require('config'); +const crypto = require('crypto'); +const timers = require('timers/promises'); +const stringSimilarity = require('string-similarity'); + +const style = require('../utils/style'); + +const contemplations = [ + 'Hmmm...', + '🤔', + 'Let\'s see...', +]; + +const answers = { + positive: [ + 'It is certain', + 'It is decidedly so', + 'Without a doubt', + 'Yes definitely', + 'You may rely on it', + 'As I see it, yes', + 'Most likely', + 'Outlook good', + 'Yes', + 'Signs points to yes', + ], + inconclusive: [ + 'Reply hazy, try again', + 'Ask again later', + 'Better not tell you now', + 'Cannot predict now', + 'Concentrate and ask again', + ], + negative: [ + 'Don\'t count on it', + 'My reply is no', + 'My sources say no', + 'Outlook not so good', + 'Very doubtful', + ], +}; + +const questions = new Map(); + +function purgeQuestions() { + Array.from(questions.entries()).forEach(([question, { timestamp }]) => { + if (new Date() - timestamp > 5 * 60 * 1000) { // 5 minutes + questions.delete(question); + } + }); +} + +async function onCommand(args, context) { + const question = args.join(' '); + + if (!/\w+\s+\w+\?/.test(question)) { + context.sendMessage('Please ask me a question, any question...', context.room.id); + return; + } + + // attempt to give consistent answers between similar questions + const similarQuestion = questions.size > 0 + ? stringSimilarity.findBestMatch(question, Array.from(questions.keys())).bestMatch + : null; + + const answerType = similarQuestion?.rating > 0.5 + ? questions.get(similarQuestion.target).answerType + : Object.keys(answers)[crypto.randomInt(0, 3)]; + + const answer = answers[answerType][crypto.randomInt(0, answers[answerType].length)]; + + questions.set(question, { answerType, timestamp: new Date() }); + + context.sendMessage(`🎱 ${contemplations[crypto.randomInt(0, contemplations.length)]}`, context.room.id, { label: false }); + + await timers.setTimeout(Math.random() * 3000 + 1000); + + context.sendMessage(style.bgnavy(style.white(`◣ ${answer} ◢`)), context.room.id, { + label: false, + style: { + color: config.schatColors.white, + background: config.schatColors.navy, + }, + }); + + purgeQuestions(); +} + +function onMessage(message, context) { + const regex = new RegExp(`^${config.usernamePrefix}${config.user.username}:?\\s+\\w+\\s+\\w+.*\\?`, 'i'); + + if (regex.test(message.body)) { + onCommand([message.body.replaceAll(`${config.usernamePrefix}${config.user.username}:?`, '').trim()], context, false); + } +} + +module.exports = { + onCommand, + onMessage, +}; diff --git a/src/games/cursed.js b/src/games/cursed.js old mode 100644 new mode 100755 diff --git a/src/games/dice.js b/src/games/dice.js old mode 100644 new mode 100755 diff --git a/src/games/duck.js b/src/games/duck.js old mode 100644 new mode 100755 diff --git a/src/games/help.js b/src/games/help.js old mode 100644 new mode 100755 diff --git a/src/games/kill.js b/src/games/kill.js old mode 100644 new mode 100755 diff --git a/src/games/letters.js b/src/games/letters.js old mode 100644 new mode 100755 diff --git a/src/games/mash.js b/src/games/mash.js old mode 100644 new mode 100755 diff --git a/src/games/ping.js b/src/games/ping.js old mode 100644 new mode 100755 diff --git a/src/games/rock-paper-scissors.js b/src/games/rock-paper-scissors.js old mode 100644 new mode 100755 diff --git a/src/games/say.js b/src/games/say.js old mode 100644 new mode 100755 diff --git a/src/games/trivia.js b/src/games/trivia.js old mode 100644 new mode 100755 diff --git a/src/games/uptime.js b/src/games/uptime.js old mode 100644 new mode 100755 diff --git a/src/irc.js b/src/irc.js old mode 100644 new mode 100755 diff --git a/src/play.js b/src/play.js old mode 100644 new mode 100755 index 5d464c0..111d150 --- a/src/play.js +++ b/src/play.js @@ -117,9 +117,9 @@ async function getGames(bot, identifier) { bot.socket.transmit('message', { roomId, recipient, - type: recipient && options.type !== 'message' ? 'whisper' : 'message', + type: recipient && options?.type !== 'message' ? 'whisper' : 'message', body: curatedBody, - style: config.style, + style: { ...config.style, ...options?.style }, }); } }; @@ -235,7 +235,7 @@ function onMessage(message, bot, games) { } } - if (message.type === 'message') { + if (message.type === 'message' && user.username !== config.user.username) { Object.values(Object.fromEntries(Object.values(games).map((game) => [game.key, game]))).forEach((game) => game.onMessage?.(message, { ...game, bot, diff --git a/src/schat.js b/src/schat.js old mode 100644 new mode 100755 diff --git a/src/utils/get-leaders.js b/src/utils/get-leaders.js old mode 100644 new mode 100755 diff --git a/src/utils/get-word-key.js b/src/utils/get-word-key.js old mode 100644 new mode 100755 diff --git a/src/utils/pick-random.js b/src/utils/pick-random.js old mode 100644 new mode 100755 diff --git a/src/utils/shuffle.js b/src/utils/shuffle.js old mode 100644 new mode 100755 diff --git a/src/utils/style.js b/src/utils/style.js old mode 100644 new mode 100755 index ddf94b3..c63398b --- a/src/utils/style.js +++ b/src/utils/style.js @@ -50,7 +50,7 @@ module.exports = (() => { bold: schatBold, italic: schatItalic, code: schatCode, - ...Object.fromEntries(Object.entries(config.schatColors).map(([color, value]) => [color, (text) => schatColor(text, value)])), + ...Object.fromEntries(Object.entries(config.schatColorAliases).map(([color, value]) => [color, (text) => schatColor(text, value)])), }; const handler = {