-
Notifications
You must be signed in to change notification settings - Fork 0
/
njsbot.js
45 lines (34 loc) · 1.06 KB
/
njsbot.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
var Messages = require("./core/logger/Messages"),
// Configurations
config = require("./config.json"),
pack = require("./package.json");
// Functions
/**
* Función principal que inicia el bot.
* @access public
* @method startBot
* @return void
*/
function startBot(){
var messages = new Messages(process.env.LEVEL || config.level);
messages.greeting(pack.name, pack.version);
messages.debug("Loading dependencies...");
var Client = require("./core/xmpp/Client"),
Interpreter = require("./core/aiml/Interpreter"),
ClientIO = require("./core/xmpp/ClientIO");
messages.debug("Dependencies loaded.");
var client = new Client(config, process.env.PASSWORD).getClient(),
interpreter = new Interpreter(config).getInterpreter(),
clientio = new ClientIO();
var aiml = require(config.interpreter.ai);
messages.info("Loading "+aiml.name);
interpreter.loadAIMLFilesIntoArray(aiml.files);
client.on('online', function(){
clientio.online(config);
});
client.on('stanza', clientio.readStanza);
client.on('error', function(e) {
messages.error(e);
});
}
startBot();