Accepting punctuation as part of a 8ball question.

This commit is contained in:
Niels Simenon 2022-10-28 03:17:09 +02:00
parent dda9ba81ae
commit 335bd55a91
1 changed files with 2 additions and 2 deletions

View File

@ -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);