mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-09-05 23:04:53 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac87fd3a40 | ||
|
|
c67e2e04f1 | ||
|
|
83eeb0f190 | ||
|
|
e09cf24fbf | ||
|
|
9d2b5ade67 | ||
|
|
be4e5c9449 | ||
|
|
5926197f23 | ||
|
|
2d86f81142 | ||
|
|
f37bff4a57 | ||
|
|
c700b7663b | ||
|
|
c26e548c64 | ||
|
|
658d8fb708 | ||
|
|
cd68841d1d | ||
|
|
5853968661 | ||
|
|
10d899f7a7 | ||
|
|
4e1453e702 | ||
|
|
f3cf2a4361 | ||
|
|
2890b70add | ||
|
|
1810727a2f | ||
|
|
3d566ed0fb |
@@ -40,6 +40,11 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
|||||||
customurl = match[1];
|
customurl = match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!result.profile.steamID64) {
|
||||||
|
callback(new Error("No valid response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
callback(null, new CSteamUser(self, result.profile, customurl));
|
callback(null, new CSteamUser(self, result.profile, customurl));
|
||||||
});
|
});
|
||||||
@@ -50,22 +55,26 @@ function CSteamUser(community, userData, customurl) {
|
|||||||
this._community = community;
|
this._community = community;
|
||||||
|
|
||||||
this.steamID = new SteamID(userData.steamID64[0]);
|
this.steamID = new SteamID(userData.steamID64[0]);
|
||||||
this.name = userData.steamID[0];
|
this.name = processItem('steamID');
|
||||||
this.onlineState = userData.onlineState[0];
|
this.onlineState = processItem('onlineState');
|
||||||
this.stateMessage = userData.stateMessage[0];
|
this.stateMessage = processItem('stateMessage');
|
||||||
this.privacyState = userData.privacyState[0];
|
this.privacyState = processItem('privacyState', 'uncreated');
|
||||||
this.visibilityState = userData.visibilityState[0];
|
this.visibilityState = processItem('visibilityState');
|
||||||
this.avatarHash = userData.avatarIcon[0].match(/([0-9a-f]+)\.[a-z]+$/)[1];
|
this.avatarHash = processItem('avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
|
||||||
this.vacBanned = !!userData.vacBanned[0];
|
if(this.avatarHash) {
|
||||||
this.tradeBanState = userData.tradeBanState[0];
|
this.avatarHash = this.avatarHash[1];
|
||||||
this.isLimitedAccount = !!userData.isLimitedAccount[0];
|
}
|
||||||
this.customURL = userData.customURL ? userData.customURL[0] : customurl;
|
|
||||||
|
this.vacBanned = !!processItem('vacBanned', false);
|
||||||
|
this.tradeBanState = processItem('tradeBanState', 'None');
|
||||||
|
this.isLimitedAccount = !!processItem('isLimitedAccount');
|
||||||
|
this.customURL = processItem('customURL', customurl);
|
||||||
|
|
||||||
if(this.visibilityState == 3) {
|
if(this.visibilityState == 3) {
|
||||||
this.memberSince = new Date(userData.memberSince[0].replace(/(\d{1,2})(st|nd|th)/, "$1"));
|
this.memberSince = new Date(processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1"));
|
||||||
this.location = userData.location[0] || null;
|
this.location = processItem('location');
|
||||||
this.realName = userData.realname[0] || null;
|
this.realName = processItem('realname');
|
||||||
this.summary = userData.summary[0] || null;
|
this.summary = processItem('summary');
|
||||||
} else {
|
} else {
|
||||||
this.memberSince = null;
|
this.memberSince = null;
|
||||||
this.location = null;
|
this.location = null;
|
||||||
@@ -88,6 +97,14 @@ function CSteamUser(community, userData, customurl) {
|
|||||||
return new SteamID(group.groupID64[0]);
|
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) {
|
CSteamUser.getAvatarURL = function(hash, size, protocol) {
|
||||||
@@ -140,5 +157,5 @@ CSteamUser.prototype.getInventoryContexts = function(callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
|
CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
|
||||||
this._community.getInventory(appID, contextID, tradableOnly, callback);
|
this._community.getUserInventory(this.steamID, appID, contextID, tradableOnly, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.request.post({
|
||||||
"uri": "https://steamcommunity.com/gid/" + this.steamID.toString() + "/eventEdit",
|
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
||||||
"form": form
|
"form": form
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(!callback) {
|
if(!callback) {
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'primaryGroup':
|
case 'primaryGroup':
|
||||||
if(typeof settings[i] === 'object' && settings[i].accountid) {
|
if(typeof settings[i] === 'object' && settings[i].getSteamID64) {
|
||||||
values.primary_group_steamid = settings[i].accountid;
|
values.primary_group_steamid = settings[i].getSteamID64();
|
||||||
} else {
|
} else {
|
||||||
values.primary_group_steamid = new SteamID(settings[i]).accountid;
|
values.primary_group_steamid = new SteamID(settings[i]).getSteamID64();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
|||||||
|
|
||||||
if(body.success) {
|
if(body.success) {
|
||||||
callback(null);
|
callback(null);
|
||||||
} else if(bpdy.error) {
|
} else if(body.error) {
|
||||||
callback(new Error(body.error));
|
callback(new Error(body.error));
|
||||||
} else {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -158,7 +158,7 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(body.match(/<h2>Access Denied<\/h2>/)) {
|
if(body.match(/<h2>Access Denied<\/h2>/)) {
|
||||||
return callback("Access Denied");
|
return callback(new Error("Access Denied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
|
var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "steamcommunity",
|
"name": "steamcommunity",
|
||||||
"version": "3.9.1",
|
"version": "3.9.9",
|
||||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||||
"keywords": ["steam", "steam community"],
|
"keywords": ["steam", "steam community"],
|
||||||
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
|
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
|
||||||
|
|||||||
Reference in New Issue
Block a user