Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/behaviors/voice.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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
}
}
};

Expand Down