Compare commits
No commits in common. "d4d736bb56903b057a8f125ad846e202c1f6842c" and "b161a2990975ee927411be8ebc8905faf4cfb585" have entirely different histories.
d4d736bb56
...
b161a29909
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.0",
|
"version": "1.6.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.0",
|
"version": "1.6.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bhttp": "^1.2.8",
|
"bhttp": "^1.2.8",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.0",
|
"version": "1.6.0",
|
||||||
"description": "Game host for SChat 2-powered chat sites",
|
"description": "Game host for SChat 2-powered chat sites",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -215,11 +215,9 @@ function getGames(bot) {
|
||||||
const games = config.games.reduce((acc, key) => {
|
const games = config.games.reduce((acc, key) => {
|
||||||
const game = require(`./games/${key.game || key}`); // eslint-disable-line global-require, import/no-dynamic-require
|
const game = require(`./games/${key.game || key}`); // eslint-disable-line global-require, import/no-dynamic-require
|
||||||
|
|
||||||
const sendMessage = (body, roomId, options, recipient) => {
|
const sendMessage = (body, roomId, options) => {
|
||||||
bot.socket.transmit('message', {
|
bot.socket.transmit('message', {
|
||||||
roomId,
|
roomId,
|
||||||
recipient,
|
|
||||||
type: recipient ? 'whisper' : 'message',
|
|
||||||
body: options?.label === false ? body : `[${game.name || key}] ${body}`,
|
body: options?.label === false ? body : `[${game.name || key}] ${body}`,
|
||||||
style: config.style,
|
style: config.style,
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,11 +8,6 @@ const questions = require('../../assets/jeopardy.json');
|
||||||
const shuffle = require('../utils/shuffle');
|
const shuffle = require('../utils/shuffle');
|
||||||
|
|
||||||
const settings = { ...config.trivia };
|
const settings = { ...config.trivia };
|
||||||
const help = {
|
|
||||||
mode: '\'first\' or \'timeout\'',
|
|
||||||
rounds: 'rounds per game as a number',
|
|
||||||
timeout: 'seconds as a number',
|
|
||||||
};
|
|
||||||
|
|
||||||
let game = null;
|
let game = null;
|
||||||
|
|
||||||
|
@ -90,7 +85,7 @@ async function playRound(context, round = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.mode === 'timeout') {
|
if (game.mode === 'timeout') {
|
||||||
context.sendMessage(`**STOP!** The correct answer is **${question.fullAnswer || question.answer}**. ${scores}`, context.room.id);
|
context.sendMessage(`**STOP!** The correct answer is **${question.answer}**. ${scores}`, context.room.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,20 +156,12 @@ function onCommand(args, context) {
|
||||||
context.sendMessage(`There is no game going on at the moment. Start one with ${config.prefix}trivia!`, context.room.id);
|
context.sendMessage(`There is no game going on at the moment. Start one with ${config.prefix}trivia!`, context.room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['help', 'commands'].includes(context.subcommand)) {
|
|
||||||
context.sendMessage(`Available subcommands for ${config.prefix}trivia are :stop, :mode, :rounds and :timeout`, context.room.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const subcommand = context.subcommand?.toLowerCase();
|
const subcommand = context.subcommand?.toLowerCase();
|
||||||
|
|
||||||
if (subcommand && settings[subcommand]) {
|
if (subcommand && settings[subcommand]) {
|
||||||
if (args[0]) {
|
settings[subcommand] = typeof settings[subcommand] === 'number' ? (Number(args[0]) || settings[subcommand]) : args[0];
|
||||||
settings[subcommand] = typeof settings[subcommand] === 'number' ? (Number(args[0]) || settings[subcommand]) : args[0];
|
|
||||||
|
|
||||||
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);
|
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);
|
||||||
} else if (help[subcommand]) {
|
|
||||||
context.sendMessage(`Please give ${help[subcommand]}`, context.room.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +170,7 @@ async function onMessage(message, context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { answer, fullAnswer } = game.questions[game.round];
|
const { answer } = game.questions[game.round];
|
||||||
|
|
||||||
if (new RegExp(answer, 'i').test(decode(message.originalBody || message.body))) { // resolve HTML entities in case original body is not available, 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({
|
||||||
|
@ -194,14 +181,6 @@ async function onMessage(message, context) {
|
||||||
if (settings.mode === 'first') {
|
if (settings.mode === 'first') {
|
||||||
game.ac.abort();
|
game.ac.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.mode === 'timeout') {
|
|
||||||
if (message.type === 'message') {
|
|
||||||
context.sendMessage(`**${fullAnswer || answer}** is the correct answer! You might want to **/whisper** the answer to me instead, so others can't leech off your impeccable knowledge. You will receive a point at the end of the round.`, context.room.id, null, context.user.username);
|
|
||||||
} else {
|
|
||||||
context.sendMessage(`**${fullAnswer || answer}** is the correct answer! You will receive a point at the end of the round.`, context.room.id, null, context.user.username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue