Reading original body when available.
This commit is contained in:
parent
7640fae9d8
commit
e5caa3a0fb
|
@ -135,7 +135,8 @@ function onLeave(data, bot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMessage(message, bot, games) {
|
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 user = bot.users[message.userId] || message.user;
|
||||||
const room = bot.rooms[message.roomId];
|
const room = bot.rooms[message.roomId];
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ function onMessage(message, bot, games) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
const args = message.body.split(/\s+/).slice(1);
|
const args = body.split(/\s+/).slice(1);
|
||||||
const game = games[command];
|
const game = games[command];
|
||||||
|
|
||||||
if (game && game.onCommand) {
|
if (game && game.onCommand) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ async function onMessage(message, context) {
|
||||||
|
|
||||||
const { answer } = game.questions[game.round];
|
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({
|
game.answers.push({
|
||||||
user: context.user,
|
user: context.user,
|
||||||
answer: message.body,
|
answer: message.body,
|
||||||
|
|
Loading…
Reference in New Issue