-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBotManager.js
More file actions
39 lines (34 loc) · 873 Bytes
/
BotManager.js
File metadata and controls
39 lines (34 loc) · 873 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
28
29
30
31
32
33
34
35
36
37
38
39
const Bot = require("./Bot");
const logger = require("./lib/logger");
module.exports = class BotManager {
bots = {};
/**
*
* @param {Object} botsConfig holds the configuration of all bots
*/
constructor(botsConfig) {
// for every bot
botsConfig.forEach(botConfig => {
// Save initialized bot in the bots map
let bot = new Bot(botConfig);
this.bots[bot.name] = bot;
});
logger.log(this, "bots initialized!");
}
/**
* Execute login for all bots
*/
allLogin() {
for (const botKey of Object.keys(this.bots)) {
this.bots[botKey].login();
}
}
/**
* Execute logout for all bots
*/
allLogout() {
for (const botKey of Object.keys(this.bots)) {
this.bots[botKey].logout();
}
}
}