This repository was archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandings.js
More file actions
36 lines (29 loc) · 1.37 KB
/
Copy pathstandings.js
File metadata and controls
36 lines (29 loc) · 1.37 KB
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
var request = require('request')
, xml2js = require('xml2js')
, _ = require('lodash')
exports.update = function(whitelist) {
if (process.env.NODE_ENV === 'test') return;
request(whitelist.url, function(error, response, body) {
if (!error && response.statusCode == 200) {
xml2js.parseString(body, function (parse_error, standings) {
if (!parse_error) {
whitelist.corporations = _.filter(standings.eveapi.result[0].rowset[0].row, function(s) {
return parseFloat(s.$.standing) >= whitelist.threshold;
});
whitelist.corporations = _.map(whitelist.corporations, function(e) { return e.$.contactID; });
whitelist.alliances = _.filter(standings.eveapi.result[0].rowset[1].row, function(s) {
return parseFloat(s.$.standing) >= whitelist.threshold;
});
whitelist.alliances = _.map(whitelist.alliances, function(e) { return e.$.contactID; });
console.log('Standings: ' + whitelist.alliances.length + ' alliances whitelisted.');
console.log('Standings: ' + whitelist.corporations.length + ' corporations whitelisted.');
} else {
console.log('Standings: Error parsing standings: ' + parser_error);
}
});
} else {
console.log('Standings: Error fetching standings: ' + error);
}
});
return;
};