mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
Upgrade syntax of everything to more modern javascript
This commit is contained in:
parent
f8d903b982
commit
69288baebc
43 changed files with 1499 additions and 1521 deletions
|
|
@ -1,17 +1,14 @@
|
|||
var async = require('async');
|
||||
|
||||
module.exports = require('./core').extend({
|
||||
init: function() {
|
||||
this._super();
|
||||
class Mumble extends require('./core') {
|
||||
constructor() {
|
||||
super();
|
||||
this.options.tcpTimeout = 5000;
|
||||
},
|
||||
run: function(state) {
|
||||
var self = this;
|
||||
|
||||
this.tcpSend('json', function(buffer) {
|
||||
}
|
||||
|
||||
run(state) {
|
||||
this.tcpSend('json', (buffer) => {
|
||||
if(buffer.length < 10) return;
|
||||
var str = buffer.toString();
|
||||
var json;
|
||||
const str = buffer.toString();
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(str);
|
||||
} catch(e) {
|
||||
|
|
@ -21,24 +18,26 @@ module.exports = require('./core').extend({
|
|||
|
||||
state.raw = json;
|
||||
state.name = json.name;
|
||||
|
||||
var channelStack = [state.raw.root];
|
||||
|
||||
let channelStack = [state.raw.root];
|
||||
while(channelStack.length) {
|
||||
var channel = channelStack.shift();
|
||||
channel.description = self.cleanComment(channel.description);
|
||||
const channel = channelStack.shift();
|
||||
channel.description = this.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);
|
||||
for(const user of channel.users) {
|
||||
user.comment = this.cleanComment(user.comment);
|
||||
state.players.push(user);
|
||||
}
|
||||
}
|
||||
|
||||
self.finish(state);
|
||||
this.finish(state);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
cleanComment: function(str) {
|
||||
}
|
||||
|
||||
cleanComment(str) {
|
||||
return str.replace(/<.*>/g,'');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = Mumble;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue