diff --git a/src/behaviors/voice.js b/src/behaviors/voice.js index 0b12dff..1a1dfc3 100644 --- a/src/behaviors/voice.js +++ b/src/behaviors/voice.js @@ -1,10 +1,14 @@ const MemoryBehavior = require('../models/memory-behavior'); +// Keep track of which users have already been greeted +const greetedUsers = new Set(); + module.exports = (client) => { // should run only on unrecognized users const voiceAction = (botNick, username) => { var matrix = false; if (username.match(/\[m\]/) !== null) matrix = true; // exempt matrix user + if (matrix) { //client.client.send('PRIVMSG', 'ChanServ', ""); client.client.send('MODE', '#publiclab', '+v', username); @@ -14,7 +18,14 @@ module.exports = (client) => { client.client.send('MODE', '#publiclab', '+q', username + '!*@*'); client.client.send('PRIVMSG', username, 'Welcome; because we have had some spam attacks, folks joining via IRC need to type "/msg plotsbot approve me" approved to chat. We are really sorry for the inconvenience but the spam got really awful!'); client.client.send('PRIVMSG', username, 'You may not be able to hear messages from other platforms; until this is fixed, see https://publiclab.org/chat to use a different chat system; apologies!'); - return username + ' just joined via IRC; welcome! They may not hear messages via Riot/Matrix/Gitter/Slack (we are working on this problem), so use https://chat.publiclab.org to respond.'; + + // Only greet new users once, when they send their first message + if (!greetedUsers.has(username)) { + greetedUsers.add(username); + return username + ' just joined via IRC; welcome! They may not hear messages via Riot/Matrix/Gitter/Slack (we are working on this problem), so use https://chat.publiclab.org to respond.'; + } else { + return null; // do nothing if already greeted + } } };