-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathask-about-links-theory.js
More file actions
27 lines (25 loc) · 916 Bytes
/
ask-about-links-theory.js
File metadata and controls
27 lines (25 loc) · 916 Bytes
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
const { VK } = require('vk-io');
const { executeTrigger, getToken, second, ms } = require('./utils');
const { trigger } = require('./triggers/ask-about-links-theory');
const { handleOutgoingMessage, queue } = require('./outgoing-messages');
const token = getToken();
const vk = new VK({ token });
const maxGreetings = Number(process.argv[2]) || 0;
if (maxGreetings > 0) {
let finished = false;
executeTrigger(trigger, { vk, options: { maxGreetings } }).then(() => {
finished = true
}).catch((e) => {
finished = true;
console.error(e);
});
const messagesHandlerInterval = setInterval(handleOutgoingMessage, (1 * second) / ms);
const finalizerInterval = setInterval(() => {
if (finished && queue.length == 0) {
setTimeout(() => {
clearInterval(messagesHandlerInterval);
}, (10 * second) / ms);
clearInterval(finalizerInterval);
}
}, (1 * second) / ms);
}