-
Notifications
You must be signed in to change notification settings - Fork 1
/
entry.mjs
40 lines (33 loc) · 859 Bytes
/
entry.mjs
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
38
39
40
import VK from './connect/vk';
import DB from './connect/db';
import Bot from './connect/telegraf';
const startScheduledGrubbing = (service, mins = 10) => {
const grubFromService = async () => {
try {
await service.scheduleWork();
const grub = () => {
setTimeout(async () => {
try {
await service.scheduleWork();
grub();
} catch (e) {
console.log('Ошибка', e);
}
}, 1000 * 60 * mins);
};
grub();
} catch (e) {
console.log('Ошибка', e);
}
};
grubFromService();
};
const init = async () => {
const db = new DB();
const dbInstance = await db.connect();
const bot = new Bot(db, dbInstance);
const vk = new VK(db, bot, dbInstance);
startScheduledGrubbing(vk);
startScheduledGrubbing(bot, 1);
};
init();