Merged SChat and IRC support.

This commit is contained in:
2022-10-19 01:24:13 +02:00
parent 4580e9129f
commit ad782a5126
9 changed files with 442 additions and 496 deletions

View File

@@ -196,9 +196,9 @@ function onCommand(args, context) {
}
function onMessage(message, context) {
const mash = mashes.get(context.room.id);
const mash = mashes.get(context.room?.id);
if (mash && context.user?.id !== config.user.id) {
if (mash && message.type === 'message' && context.user?.id !== config.user.id) {
play(message.body, context, true);
}
}

View File

@@ -22,7 +22,12 @@ function onCommand(args, context) {
const room = Object.values(context.bot.rooms).find((botRoom) => botRoom.name === roomName);
if (room) {
context.sendMessage(args.slice(1).join(' '), roomName, { label: false });
context.sendMessage(args.slice(1).join(' '), room.id, { label: false });
return;
}
if (context.message.recipient === config.user.username) {
context.sendMessage(args.join(' '), null, { type: 'message', label: false }, context.user.username);
}
return;

View File

@@ -60,7 +60,7 @@ async function playRound(context, round = 0) {
const question = game.questions[round];
context.sendMessage(`${style.bold(style.purple(`Question ${round + 1}/${game.questions.length}`))} ${style.gray(`(${question.category})`)}: ${question.question}`, context.room.id);
context.sendMessage(`${style.bold(style.purple(`Question ${round + 1}/${game.questions.length}`))} ${style.silver(`(${question.category})`)}: ${question.question}`, context.room.id);
context.logger.info(`Trivia asked "${question.question}" with answer: ${question.answer}`);
try {
@@ -192,7 +192,7 @@ function onCommand(args, context) {
}
async function onMessage(message, context) {
const game = games.get(context.room.id);
const game = games.get(context.room?.id);
if (!game || context.user?.id === config.user?.id) {
return;