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
44
protocols/mumble.js
Normal file
44
protocols/mumble.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
var async = require('async');
|
||||
|
||||
module.exports = require('./core').extend({
|
||||
init: function() {
|
||||
this._super();
|
||||
this.options.tcpTimeout = 5000;
|
||||
},
|
||||
run: function(state) {
|
||||
var self = this;
|
||||
|
||||
this.tcpSend('json', function(buffer) {
|
||||
if(buffer.length < 10) return;
|
||||
var str = buffer.toString();
|
||||
var json;
|
||||
try {
|
||||
json = JSON.parse(str);
|
||||
} catch(e) {
|
||||
// probably not all here yet
|
||||
return;
|
||||
}
|
||||
|
||||
state.raw = json;
|
||||
state.name = json.name;
|
||||
|
||||
var channelStack = [state.raw.root];
|
||||
while(channelStack.length) {
|
||||
var channel = channelStack.shift();
|
||||
channel.description = self.cleanComment(channel.description);
|
||||
channelStack = channelStack.concat(channel.channels);
|
||||
for(var i = 0; i < channel.users.length; i++) {
|
||||
var user = channel.users[i];
|
||||
user.comment = self.cleanComment(user.comment);
|
||||
state.players.push(user);
|
||||
}
|
||||
}
|
||||
|
||||
self.finish(state);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
cleanComment: function(str) {
|
||||
return str.replace(/<.*>/g,'');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue