forked from logicx24/MarkovsInequality
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventloop.js
executable file
·30 lines (28 loc) · 927 Bytes
/
eventloop.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
var chatApp = require("facebook-chat-api");
var async = require("async");
var loginInfo = require("./login");
var functions = require("./functions");
chatApp({email: loginInfo.email, password: loginInfo.password}, function (err, api) {
if (err) {
console.log(err);
} else {
api.listen(function (err, message) {
if (err) {
console.error(err);
process.exit(-1);
}
else {
for (var f in functions) {
var func = functions[f];
var callback = function(){};
if (message.body.match(func.matchPattern)) {
func.action(api, message, callback);
}
else if (func['onMessage']) {
func.onMessage(api, message);
}
};
}
});
}
});