-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnodebot.js
63 lines (44 loc) · 1.36 KB
/
nodebot.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
// Nodebot.js
//
// Description: A helper robot that lives to serve
// Author: Nate Hunzaker
// -------------------------------------------------- //
// Licence: MIT
// -------------------------------------------------- //
//-- require application.js
//-- require nodebot.js
require('colors');
// Get the initial action
var command = process.argv.slice(2).join(" ").trim();
// -------------------------------------------------- //
Nodebot = new(require("events").EventEmitter)();
// short term memory
Nodebot.memory = {
tasks : [],
context : "nodebot"
};
// long term memory
Nodebot.lexicon = require("./brain/lexicon");
// The linguistics module
Nodebot.language = require("./brain/language");
// All actions the nodebot can take
Nodebot.actions = require("./actions");
// Adds the decision making module
Nodebot.analyze = require("./brain/analyze");
// Adds common interactions, such as say, growl, ask and request
require("./brain/interaction")(Nodebot);
// -------------------------------------------------- //
Nodebot.boot = function(server) {
if (server) {
var app = require("./server");
} else {
(command !== "") ? Nodebot.analyze(command) : Nodebot.request();
}
};
// Take the proper initial action
if (!module.parent) {
process.on("exit", function() {
console.log("");
});
Nodebot.boot(command === "-s");
}