forked from GitHub/dbot
currently playing and server info
This commit is contained in:
parent
70a2a77cc0
commit
dc0785fe2e
@ -59,6 +59,23 @@ var steam = function(dbot) {
|
||||
callback(true, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'getProfile': function(steamid, callback) {
|
||||
request.get(this.ApiRoot + 'ISteamUser/GetPlayerSummaries/v0002/', {
|
||||
'qs': {
|
||||
'key': this.config.api_key,
|
||||
'steamids': steamid,
|
||||
'format': 'json'
|
||||
},
|
||||
'json': true
|
||||
}, function(err, res, body) {
|
||||
if(_.has(body, 'response') && _.has(body.response, 'players')) {
|
||||
callback(null, body.response.players[0]);
|
||||
} else {
|
||||
callback(true, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -72,6 +89,19 @@ var steam = function(dbot) {
|
||||
}
|
||||
|
||||
this.api.getSteamID(snick, function(err, steamid) {
|
||||
this.api.getProfile(steamid, function(err, player) {
|
||||
if(!err) {
|
||||
if(_.has(player, 'gameextrainfo')) {
|
||||
var output = dbot.t('steam_currently_playing', {
|
||||
'user': user.currentNick,
|
||||
'game': player.gameextrainfo
|
||||
});
|
||||
if(_.has(player, 'gameserverip')) {
|
||||
var host = player.gameserverip.split(':');
|
||||
output += ' (Host: ' + host[0] + ' Port: ' + host[1] + ')';
|
||||
}
|
||||
event.reply(output);
|
||||
} else {
|
||||
this.api.getRecentlyPlayed(steamid, function(err, games) {
|
||||
if(!err) {
|
||||
if(games.total_count != 0) {
|
||||
@ -88,6 +118,11 @@ var steam = function(dbot) {
|
||||
event.reply('something went wrong');
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
event.reply('something went wrong');
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
@ -4,5 +4,8 @@
|
||||
},
|
||||
"steam_not_played": {
|
||||
"en": "{user} didn't play anything recently :'("
|
||||
},
|
||||
"steam_currently_playing": {
|
||||
"en": "{user} is currently playing {game}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user