mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 19:52:36 +01:00
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);
|
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,22 +89,40 @@ var steam = function(dbot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.api.getSteamID(snick, function(err, steamid) {
|
this.api.getSteamID(snick, function(err, steamid) {
|
||||||
this.api.getRecentlyPlayed(steamid, function(err, games) {
|
this.api.getProfile(steamid, function(err, player) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
if(games.total_count != 0) {
|
if(_.has(player, 'gameextrainfo')) {
|
||||||
event.reply(dbot.t('steam_last_played', {
|
var output = dbot.t('steam_currently_playing', {
|
||||||
'user': user.currentNick,
|
'user': user.currentNick,
|
||||||
'game': games.games[0].name
|
'game': player.gameextrainfo
|
||||||
}));
|
});
|
||||||
|
if(_.has(player, 'gameserverip')) {
|
||||||
|
var host = player.gameserverip.split(':');
|
||||||
|
output += ' (Host: ' + host[0] + ' Port: ' + host[1] + ')';
|
||||||
|
}
|
||||||
|
event.reply(output);
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('steam_not_played', {
|
this.api.getRecentlyPlayed(steamid, function(err, games) {
|
||||||
'user': user.currentNick
|
if(!err) {
|
||||||
}));
|
if(games.total_count != 0) {
|
||||||
|
event.reply(dbot.t('steam_last_played', {
|
||||||
|
'user': user.currentNick,
|
||||||
|
'game': games.games[0].name
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('steam_not_played', {
|
||||||
|
'user': user.currentNick
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('something went wrong');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.reply('something went wrong');
|
event.reply('something went wrong');
|
||||||
}
|
}
|
||||||
});
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,5 +4,8 @@
|
|||||||
},
|
},
|
||||||
"steam_not_played": {
|
"steam_not_played": {
|
||||||
"en": "{user} didn't play anything recently :'("
|
"en": "{user} didn't play anything recently :'("
|
||||||
|
},
|
||||||
|
"steam_currently_playing": {
|
||||||
|
"en": "{user} is currently playing {game}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user