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
12 changes: 10 additions & 2 deletions src/behaviors/unresponsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ const Behavior = require('../models/behavior');

module.exports = ({ responseTime, offsetTime }) => {
let currentTimeout;
let recognized = [];

const unresponsiveAction = () => {
const unresponsiveAction = (channel, username, botNick) => {
let secondsCounter = parseInt(Date.now()/(1000*1000)); // 1000 seconds
let userAndTime = username + secondsCounter; // remember people from the last 1000 seconds
if(!utils.contains(recognized, userAndTime)) greeted.push(userAndTime);
if (currentTimeout) {
clearTimeout(currentTimeout);
}
return new Promise((resolve, reject) => {
currentTimeout = setTimeout(() => {
currentTimeout = undefined;
resolve('Hi, looks like nobody\'s around just now. If you have a question, you can post it a https://publiclab.org/questions, or if you need help with a software issue, you can open an issue at https://github.com/publiclab/plots2/issues/new -- thanks!');
if(!utils.contains(recognized, userAndTime)) {
resolve('Hi, looks like nobody\'s around just now. If you have a question, you can post it a https://publiclab.org/questions, or if you need help with a software issue, you can open an issue at https://github.com/publiclab/plots2/issues/new -- thanks!');
} else {
resolve(''); // what to do here?
}
}, responseTime);

setTimeout(() => {
Expand Down