mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Super epic commit 3
Move everything around Add another 50 or so games *** 'port' option should now be CONNECT port, not query port *** add reference for many missing games
This commit is contained in:
parent
8488cdcca9
commit
bc6b5c9225
64 changed files with 2071 additions and 430 deletions
35
protocols/terraria.js
Normal file
35
protocols/terraria.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
var request = require('request');
|
||||
|
||||
module.exports = require('./core').extend({
|
||||
run: function(state) {
|
||||
var self = this;
|
||||
request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status',
|
||||
timeout: 3000,
|
||||
qs: {
|
||||
players: 'true',
|
||||
token: this.options.token
|
||||
}
|
||||
}, function(e,r,body) {
|
||||
if(e) return self.fatal('HTTP error');
|
||||
var json;
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch(e) {
|
||||
return self.fatal('Invalid JSON');
|
||||
}
|
||||
|
||||
if(json.status != 200) return self.fatal('Invalid status');
|
||||
|
||||
json.players.forEach(function(one) {
|
||||
state.players.push({name:one.nickname,team:one.team});
|
||||
});
|
||||
|
||||
state.name = json.name;
|
||||
state.raw.port = json.port;
|
||||
state.raw.numplayers = json.playercount;
|
||||
|
||||
self.finish(state);
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue