From 114555be6677e0e136743724ab8381f23a3d2748 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sat, 6 Nov 2021 02:14:33 +0100 Subject: [PATCH] Only adding users to known rooms. --- src/app.js | 5 ++--- src/games/trivia.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index 1b657fd..f1a18b5 100644 --- a/src/app.js +++ b/src/app.js @@ -116,9 +116,8 @@ function onRooms({ rooms, users }, bot) { /* eslint-disable no-param-reassign */ function onJoin(data, bot) { - bot.users[data.user.id] = data.user; - - if (!bot.rooms[data.roomId].includes(data.user.id)) { + if (bot.rooms[data.roomId] && !bot.rooms[data.roomId]?.includes(data.user.id)) { + bot.users[data.user.id] = data.user; bot.rooms[data.roomId].push(data.user.id); } } diff --git a/src/games/trivia.js b/src/games/trivia.js index dd022b6..54c515c 100644 --- a/src/games/trivia.js +++ b/src/games/trivia.js @@ -78,7 +78,7 @@ async function playRound(context, round = 0) { const scores = scoreRound(context, round); if (game.mode === 'first') { - context.sendMessage(`**${question.answer}** is the right answer after **${((new Date() - now) / 1000).toFixed(3)}s**! ${scores}`, context.room.id); + context.sendMessage(`**${question.answer}** is the right answer, played in **${((new Date() - now) / 1000).toFixed(3)}s**! ${scores}`, context.room.id); } if (game.mode === 'timeout') {