-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
37 lines (33 loc) · 880 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const debug = require('debug')('occupy-sarahah:index');
const Sarahah = require('./lib/sarahah');
const lerolero = require('lerolero');
let openPages = 0;
async function flood(profile, interval) {
debug(`starting flooder for profile ${profile} with interval ${interval}`);
setInterval(async () => {
if (openPages < 10) {
try {
openPages += 1;
await Sarahah.postMessage({
profile,
message: lerolero(),
});
} catch (err) {
console.log(err.message);
} finally {
openPages -= 1;
}
} else {
debug('too much open pages, not opening page for', profile);
}
}, interval || 5000);
}
/**
*
* @param {String[]} users
* @param {Number} interval
*/
module.exports = (users, interval) => {
Sarahah.initialize()
.then(() => users.forEach(user => flood(user, interval)));
};