From 335bd55a919feebce163c599b4341a0aa6764e0c Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 28 Oct 2022 03:17:09 +0200 Subject: [PATCH] Accepting punctuation as part of a 8ball question. --- src/games/8ball.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/games/8ball.js b/src/games/8ball.js index 53204b1..5ab64f0 100644 --- a/src/games/8ball.js +++ b/src/games/8ball.js @@ -56,7 +56,7 @@ function purgeQuestions() { async function onCommand(args, context) { const question = args.join(' '); - if (!/\w+\s+\w+\?/.test(question)) { + if (!/[\w\p{P}]+\s+[\w\p{P}]+\?/.test(question)) { context.sendMessage('Please ask me a question, any question...', context.room.id); return; } @@ -93,7 +93,7 @@ async function onCommand(args, context) { } function onMessage(message, context) { - const regex = new RegExp(`^${config.usernamePrefix}${config.user.username}:?\\s+\\w+\\s+\\w+.*\\?`, 'i'); + const regex = new RegExp(`^${config.usernamePrefix}${config.user.username}:?\\s+[\\w\\p{P}]+\\s+[\\w, \\p{P}]+.*\\?`, 'i'); if (regex.test(message.body)) { onCommand([message.body.replaceAll(`${config.usernamePrefix}${config.user.username}:?`, '').trim()], context, false);