mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-03 13:01:04 +01:00
c82554ad1a
Organize files Rewrite readme for new game IDs and command line Add command line access Replace some dependencies that required binaries with simpler alternatives Switch gbxremote back to upstream, Closes #2 Moved simple aliases into an alias file, rather than seperate files for each Patched nearly every protocol variant with tons of bug fixes Re-tested every combination of server and protocol types except nadeo Added alternative minecraft query check (minecraftping) Fixed mutant factions query Fixed valve gold not working at all Stripped colors more reliably from protocols that support colors Added a couple more fields to ut2004 and killing floor and more that I probably forgot. This shouldn't break compatibility too bad -- at the most, some game IDs may have changed.
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
var request = require('request');
|
|
|
|
module.exports = require('./protocols/core').extend({
|
|
init: function() {
|
|
this._super();
|
|
this.pretty = 'Build and Shoot';
|
|
this.options.port = 32886;
|
|
},
|
|
run: function(state) {
|
|
var self = this;
|
|
request({
|
|
uri: 'http://'+this.options.address+':'+this.options.port+'/',
|
|
timeout: 3000,
|
|
}, function(e,r,body) {
|
|
if(e) return self.error('HTTP error');
|
|
|
|
var m = body.match(/status server for (.*?)\r|\n/);
|
|
if(m) state.name = m[1];
|
|
|
|
var m = body.match(/Current uptime: (\d+)/);
|
|
if(m) state.raw.uptime = m[1];
|
|
|
|
var m = body.match(/currently running (.*?) by /);
|
|
if(m) state.map = m[1];
|
|
|
|
var m = body.match(/Current players: (\d+)\/(\d+)/);
|
|
if(m) {
|
|
state.raw.numplayers = m[1];
|
|
state.maxplayers = m[2];
|
|
}
|
|
|
|
var m = body.match(/class="playerlist"([^]+?)\/table/);
|
|
if(m) {
|
|
var table = m[1];
|
|
var pre = /<tr>[^]*<td>([^]*)<\/td>[^]*<td>([^]*)<\/td>[^]*<td>([^]*)<\/td>[^]*<td>([^]*)<\/td>/g;
|
|
while(pm = pre.exec(table)) {
|
|
if(pm[2] == 'Ping') continue;
|
|
state.players.push({
|
|
name: pm[1],
|
|
ping: pm[2],
|
|
team: pm[3],
|
|
score: pm[4]
|
|
});
|
|
}
|
|
}
|
|
/*
|
|
var m = this.options.address.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
if(m) {
|
|
var o1 = parseInt(m[1]);
|
|
var o2 = parseInt(m[2]);
|
|
var o3 = parseInt(m[3]);
|
|
var o4 = parseInt(m[4]);
|
|
var addr = o1+(o2<<8)+(o3<<16)+(o4<<24);
|
|
state.raw.url = 'aos://'+addr;
|
|
}
|
|
*/
|
|
self.finish(state);
|
|
});
|
|
}
|
|
});
|