Adapted say module to IRC. Made greeting configurable. Fixed Trivia end-of-game leaderboard breaking.
This commit is contained in:
parent
4ce3f77c63
commit
809102f2fe
|
@ -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'],
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue