-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (51 loc) · 1.81 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//==============================================================================
// ■ Auto-Poster (index.js)
//------------------------------------------------------------------------------
// Main entry point.
//==============================================================================
require("./utils/");
//------------------------------------------------------------------------------
// ● Bot-Consumers
//------------------------------------------------------------------------------
const BOT_CONSUMERS = [require("./@reddit-art-poster-consumer")];
//------------------------------------------------------------------------------
// ► Launch
//------------------------------------------------------------------------------
repeat(main, {
delay: iterationDelay,
delayArg: true,
immediate: true,
});
//------------------------------------------------------------------------------
// ● Iteration-Delay
//------------------------------------------------------------------------------
function iterationDelay() {
let duration = dayjs.duration(10, "hours");
for (const botConsumer of BOT_CONSUMERS) {
duration = duration.add(botConsumer.delay);
}
return duration.asMilliseconds();
}
//------------------------------------------------------------------------------
// ● Main
//------------------------------------------------------------------------------
async function main(delay) {
try {
console.clear();
console.header();
for (const botConsumer of BOT_CONSUMERS) {
await botConsumer.run();
console.line("=");
}
if (delay) {
const delayText = dayjs.duration(delay).humanize(true);
console.success(
"AutoPoster",
`Next iteration ${chalk.cyan(delayText)}... ✈`
);
console.line("=");
}
} catch (err) {
console.error(err);
}
}