-
Notifications
You must be signed in to change notification settings - Fork 0
/
@reddit-art-poster-consumer.js
63 lines (57 loc) · 1.97 KB
/
@reddit-art-poster-consumer.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
56
57
58
59
60
61
62
63
///==============================================================================
// ■ Reddit-Art-Poster-Consumer (reddit-art-poster-Consumer.js)
//------------------------------------------------------------------------------
// Consummation logic of the Reddit Art Poster bot.
//==============================================================================
const redditArtPoster = require("./bots/reddit-art-poster/")(
"./data/reddit-art-poster-tasklist.json"
);
///------------------------------------------------------------------------------
// ► Exports
//------------------------------------------------------------------------------
module.exports = {
get delay() {
return redditArtPoster.remainingDuration.asMilliseconds();
},
async run() {
// Start
this.log("Start:");
this.line();
// Log (1st)
redditArtPoster.log();
this.line();
// Fetch schedule references
const fetchedSchedRefsCount = await redditArtPoster.fetchSchedRefs({
force: true,
});
this.line();
this.log(
`${fetchedSchedRefsCount} / ${redditArtPoster.count} schedule references fetched.`
);
this.line();
// Log (2nd)
if (fetchedSchedRefsCount) {
redditArtPoster.log();
this.line();
}
// Execute tasks (Start posting)
const execTimout = dayjs.duration(10, "seconds");
this.log(`Execution ${chalk.cyan(execTimout.humanize(true))}...`);
this.line();
await sleep(execTimout.asMilliseconds());
const executedTasksCount = await redditArtPoster.execute();
this.line();
// End
this.log(
`${executedTasksCount} / ${redditArtPoster.count} tasks executed.`
);
this.line();
this.log("End.");
},
log() {
console.log("RedditArtPoster/Consumer", ...arguments);
},
line() {
console.line("►");
},
};