mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 13:13:28 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10d899f7a7 | ||
|
|
4e1453e702 | ||
|
|
f3cf2a4361 | ||
|
|
2890b70add |
@@ -41,8 +41,9 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!result.profile.steamID64 || !result.profile.onlineState) {
|
||||
if(!result.profile.steamID64) {
|
||||
callback(new Error("No valid response"));
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, new CSteamUser(self, result.profile, customurl));
|
||||
@@ -54,22 +55,26 @@ function CSteamUser(community, userData, customurl) {
|
||||
this._community = community;
|
||||
|
||||
this.steamID = new SteamID(userData.steamID64[0]);
|
||||
this.name = userData.steamID[0];
|
||||
this.onlineState = userData.onlineState[0];
|
||||
this.stateMessage = userData.stateMessage[0];
|
||||
this.privacyState = userData.privacyState[0];
|
||||
this.visibilityState = userData.visibilityState[0];
|
||||
this.avatarHash = userData.avatarIcon[0].match(/([0-9a-f]+)\.[a-z]+$/)[1];
|
||||
this.vacBanned = !!userData.vacBanned[0];
|
||||
this.tradeBanState = userData.tradeBanState[0];
|
||||
this.isLimitedAccount = !!userData.isLimitedAccount[0];
|
||||
this.customURL = userData.customURL ? userData.customURL[0] : customurl;
|
||||
this.name = processItem(userData, 'steamID');
|
||||
this.onlineState = processItem(userData, 'onlineState');
|
||||
this.stateMessage = processItem(userData, 'stateMessage');
|
||||
this.privacyState = processItem(userData, 'privacyState', 'uncreated');
|
||||
this.visibilityState = processItem(userData, 'visibilityState');
|
||||
this.avatarHash = processItem(userData, 'avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
|
||||
if(this.avatarHash) {
|
||||
this.avatarHash = this.avatarHash[1];
|
||||
}
|
||||
|
||||
this.vacBanned = !!processItem(userData, 'vacBanned', false);
|
||||
this.tradeBanState = processItem(userData, 'tradeBanState', 'None');
|
||||
this.isLimitedAccount = !!processItem(userData, 'isLimitedAccount');
|
||||
this.customURL = processItem(userData, 'customURL', customurl);
|
||||
|
||||
if(this.visibilityState == 3) {
|
||||
this.memberSince = new Date(userData.memberSince[0].replace(/(\d{1,2})(st|nd|th)/, "$1"));
|
||||
this.location = userData.location[0] || null;
|
||||
this.realName = userData.realname[0] || null;
|
||||
this.summary = userData.summary[0] || null;
|
||||
this.memberSince = new Date(processItem(userData, 'memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1"));
|
||||
this.location = processItem(userData, 'location');
|
||||
this.realName = processItem(userData, 'realname');
|
||||
this.summary = processItem(userData, 'summary');
|
||||
} else {
|
||||
this.memberSince = null;
|
||||
this.location = null;
|
||||
@@ -92,6 +97,14 @@ function CSteamUser(community, userData, customurl) {
|
||||
return new SteamID(group.groupID64[0]);
|
||||
});
|
||||
}
|
||||
|
||||
function processItem(name, defaultVal) {
|
||||
if(!userData[name]) {
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
return userData[name][0];
|
||||
}
|
||||
}
|
||||
|
||||
CSteamUser.getAvatarURL = function(hash, size, protocol) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "steamcommunity",
|
||||
"version": "3.9.2",
|
||||
"version": "3.9.4",
|
||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||
"keywords": ["steam", "steam community"],
|
||||
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
|
||||
|
||||
Reference in New Issue
Block a user