diff --git a/config/default.js b/config/default.js index f2027ae..ff60b01 100644 --- a/config/default.js +++ b/config/default.js @@ -12,6 +12,7 @@ module.exports = { port: 6697, reconnectDelay: 10, // seconds prefix: '~', + greeting: 'Hi, I am aisha, your game host!', usernamePrefix: '@', channels: ['##pendulum'], games: ['mash', 'trivia', 'duck', 'ping', 'say', 'kill'], diff --git a/src/games/say.js b/src/games/say.js index 271fe90..8cf7aa5 100644 --- a/src/games/say.js +++ b/src/games/say.js @@ -7,17 +7,28 @@ function onCommand(args, context) { return; } - const message = context.room ? args.join(' ') : args.slice(1).join(' '); - const roomName = args[0].replace(/#+/, ''); - const room = context.room || Object.values(context.bot.rooms).find((botRoom) => botRoom.name === roomName); - - console.log(message, roomName, room); - - if (!room) { + if (config.platform === 'irc' && /^#+/.test(args[0])) { + context.sendMessage(args.slice(1).join(' '), args[0], { label: false }); return; } - context.sendMessage(message, room.id, { label: false }); + if (config.platform === 'irc' && context.room.id === config.user.nick) { + // if the room ID is the bot's own nickname, it's a PM and we should reply to the sender + context.sendMessage(args.join(' '), context.user.id, { label: false }); + } + + if (config.platform === 'schat' && !context.room) { + const roomName = args[0].replace(/#+/, ''); + const room = Object.values(context.bot.rooms).find((botRoom) => botRoom.name === roomName); + + if (room) { + context.sendMessage(args.slice(1).join(' '), roomName, { label: false }); + } + + return; + } + + context.sendMessage(args.join(' '), context.room.id, { label: false }); } module.exports = { diff --git a/src/games/trivia.js b/src/games/trivia.js index 25dfae6..b4477d2 100644 --- a/src/games/trivia.js +++ b/src/games/trivia.js @@ -127,7 +127,7 @@ async function playRound(context, round = 0) { await timers.setTimeout(2000); - context.sendMessage(`That's the end of the game! Best players: ${getLeaders()}`, context.room.id); + context.sendMessage(`That's the end of the game! Best players: ${getLeaders(context)}`, context.room.id); games.delete(context.room.id); } diff --git a/src/irc.js b/src/irc.js index 3a0b2ec..1b1d4af 100644 --- a/src/irc.js +++ b/src/irc.js @@ -185,7 +185,10 @@ async function init() { logger.info(`Joining ${channel}`); client.join(channel, () => logger.info(`Joined ${channel}`)); - client.say(channel, `Hi, I am ${config.user.username}, your game host!`); + + if (config.greeting) { + client.say(channel, config.greeting); + } }); client.addListener('message', (from, to, body) => onMessage({