Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum 1843a5b5b3 1.5.12 2021-11-15 21:55:44 +01:00
ThePendulum e5caa3a0fb Reading original body when available. 2021-11-15 21:55:42 +01:00
4 changed files with 7 additions and 6 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "schat2-clive",
"version": "1.5.11",
"version": "1.5.12",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "schat2-clive",
"version": "1.5.11",
"version": "1.5.12",
"license": "ISC",
"dependencies": {
"bhttp": "^1.2.8",

View File

@ -1,6 +1,6 @@
{
"name": "schat2-clive",
"version": "1.5.11",
"version": "1.5.12",
"description": "Game host for SChat 2-powered chat sites",
"main": "src/app.js",
"scripts": {

View File

@ -135,7 +135,8 @@ function onLeave(data, bot) {
}
function onMessage(message, bot, games) {
const [, command, subcommand] = message.body?.match(new RegExp(`^${config.prefix}(\\w+)(?:\\:(\\w+))?`)) || [];
const body = message.originalBody || message.body;
const [, command, subcommand] = body?.match(new RegExp(`^${config.prefix}(\\w+)(?:\\:(\\w+))?`)) || [];
const user = bot.users[message.userId] || message.user;
const room = bot.rooms[message.roomId];
@ -150,7 +151,7 @@ function onMessage(message, bot, games) {
}
if (command) {
const args = message.body.split(/\s+/).slice(1);
const args = body.split(/\s+/).slice(1);
const game = games[command];
if (game && game.onCommand) {

View File

@ -172,7 +172,7 @@ async function onMessage(message, context) {
const { answer } = game.questions[game.round];
if (new RegExp(answer, 'i').test(decode(message.body))) { // resolve HTML entities, such as & to &
if (new RegExp(answer, 'i').test(decode(message.originalBody || message.body))) { // resolve HTML entities in case original body is not available, such as & to &
game.answers.push({
user: context.user,
answer: message.body,