mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-09-03 22:02:46 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9b6b55efc | ||
|
|
0fc62d2966 | ||
|
|
5daf5f712a | ||
|
|
737aa9dc41 | ||
|
|
07fb26047b | ||
|
|
2f9b24c447 | ||
|
|
211c625da0 | ||
|
|
2e61a6ed70 | ||
|
|
f0a3cb27f8 | ||
|
|
58516d4ed1 |
2
.idea/codeStyles/codeStyleConfig.xml
generated
2
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +1,5 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<state>
|
<state>
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
</state>
|
</state>
|
||||||
</component>
|
</component>
|
||||||
@@ -86,7 +86,11 @@ function CEconItem(item, description, contextID) {
|
|||||||
this.actions = [];
|
this.actions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this.currency;
|
// One wouldn't think that we need this if statement, but apparently v8 has a weird bug/quirk where deleting a
|
||||||
|
// property results in greatly increased memory usage. Because that makes sense.
|
||||||
|
if (this.currency) {
|
||||||
|
delete this.currency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEconItem.prototype.getImageURL = function() {
|
CEconItem.prototype.getImageURL = function() {
|
||||||
|
|||||||
@@ -183,10 +183,11 @@ CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, cal
|
|||||||
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
||||||
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
||||||
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
||||||
|
* @param {string} [language] - The language of item descriptions to return. Omit for default (which may either be English or your account's chosen language)
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, callback) {
|
CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, language, callback) {
|
||||||
this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, callback);
|
this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, language, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,6 +109,43 @@ SteamCommunity.prototype.turnItemIntoGems = function(appid, assetid, expectedGem
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a booster pack.
|
||||||
|
* @param {int} appid
|
||||||
|
* @param {int|string} assetid
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.openBoosterPack = function(appid, assetid, callback) {
|
||||||
|
this._myProfile({
|
||||||
|
"endpoint": "ajaxunpackbooster/",
|
||||||
|
"json": true,
|
||||||
|
"checkHttpError": false
|
||||||
|
}, {
|
||||||
|
"appid": appid,
|
||||||
|
"communityitemid": assetid,
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success && body.success != SteamCommunity.EResult.OK) {
|
||||||
|
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
|
||||||
|
err.eresult = err.code = body.success;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.rgItems) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, body.rgItems);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get details about a gift in your inventory.
|
* Get details about a gift in your inventory.
|
||||||
* @param {string} giftID
|
* @param {string} giftID
|
||||||
|
|||||||
@@ -34,31 +34,45 @@ SteamCommunity.prototype.setupProfile = function(callback) {
|
|||||||
|
|
||||||
SteamCommunity.prototype.editProfile = function(settings, callback) {
|
SteamCommunity.prototype.editProfile = function(settings, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._myProfile("edit", null, function(err, response, body) {
|
this._myProfile('edit/info', null, function(err, response, body) {
|
||||||
if(err || response.statusCode != 200) {
|
if (err || response.statusCode != 200) {
|
||||||
if(callback) {
|
if (callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error('HTTP error ' + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var form = $('#editForm');
|
var existingSettings = $('#profile_edit_config').data('profile-edit');
|
||||||
if(!form) {
|
if (!existingSettings || !existingSettings.strPersonaName) {
|
||||||
if(callback) {
|
if (callback) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error('Malformed response'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var values = {};
|
var values = {
|
||||||
form.serializeArray().forEach(function(item) {
|
sessionID: self.getSessionID(),
|
||||||
values[item.name] = item.value;
|
type: 'profileSave',
|
||||||
});
|
weblink_1_title: '',
|
||||||
|
weblink_1_url: '',
|
||||||
|
weblink_2_title: '',
|
||||||
|
weblink_2_url: '',
|
||||||
|
weblink_3_title: '',
|
||||||
|
weblink_3_url: '',
|
||||||
|
personaName: existingSettings.strPersonaName,
|
||||||
|
real_name: existingSettings.strRealName,
|
||||||
|
summary: existingSettings.strSummary,
|
||||||
|
country: existingSettings.LocationData.locCountryCode,
|
||||||
|
state: existingSettings.LocationData.locStateCode,
|
||||||
|
city: existingSettings.LocationData.locCityCode,
|
||||||
|
customURL: existingSettings.strCustomURL,
|
||||||
|
json: 1
|
||||||
|
};
|
||||||
|
|
||||||
for(var i in settings) {
|
for (var i in settings) {
|
||||||
if(!settings.hasOwnProperty(i)) {
|
if(!settings.hasOwnProperty(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -92,6 +106,8 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
values.customURL = settings[i];
|
values.customURL = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// These don't work right now
|
||||||
|
/*
|
||||||
case 'background':
|
case 'background':
|
||||||
// The assetid of our desired profile background
|
// The assetid of our desired profile background
|
||||||
values.profile_background = settings[i];
|
values.profile_background = settings[i];
|
||||||
@@ -110,60 +126,55 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
// TODO: profile showcases
|
// TODO: profile showcases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._myProfile("edit", values, function(err, response, body) {
|
self._myProfile('edit', values, function(err, response, body) {
|
||||||
if (settings.customURL) {
|
if (settings.customURL) {
|
||||||
delete self._profileURL;
|
delete self._profileURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode != 200) {
|
if (!callback) {
|
||||||
if(callback) {
|
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an error
|
if (err || response.statusCode != 200) {
|
||||||
var $ = Cheerio.load(body);
|
callback(err || new Error('HTTP error ' + response.statusCode));
|
||||||
var error = $('#errorText .formRowFields');
|
return;
|
||||||
if(error) {
|
|
||||||
error = error.text().trim();
|
|
||||||
if(error) {
|
|
||||||
if(callback) {
|
|
||||||
callback(new Error(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback) {
|
try {
|
||||||
|
var json = JSON.parse(body);
|
||||||
|
if (!json.success || json.success != 1) {
|
||||||
|
callback(new Error(json.errmsg || 'Request was not successful'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
|
} catch (ex) {
|
||||||
|
callback(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
||||||
this._myProfile("edit/settings", null, (err, response, body) => {
|
this._myProfile('edit/settings', null, (err, response, body) => {
|
||||||
if (err || response.statusCode != 200) {
|
if (err || response.statusCode != 200) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error('HTTP error ' + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var existingSettings = $('.ProfileReactRoot[data-privacysettings]').data('privacysettings');
|
var existingSettings = $('#profile_edit_config').data('profile-edit');
|
||||||
if (!existingSettings) {
|
if (!existingSettings || !existingSettings.Privacy) {
|
||||||
if(callback) {
|
if (callback) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error('Malformed response'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -171,8 +182,8 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
|||||||
|
|
||||||
// PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
|
// PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
|
||||||
// eCommentPermission
|
// eCommentPermission
|
||||||
var privacy = existingSettings.PrivacySettings;
|
var privacy = existingSettings.Privacy.PrivacySettings;
|
||||||
var commentPermission = existingSettings.eCommentPermission;
|
var commentPermission = existingSettings.Privacy.eCommentPermission;
|
||||||
|
|
||||||
for (var i in settings) {
|
for (var i in settings) {
|
||||||
if (!settings.hasOwnProperty(i)) {
|
if (!settings.hasOwnProperty(i)) {
|
||||||
@@ -211,18 +222,18 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._myProfile({
|
this._myProfile({
|
||||||
"method": "POST",
|
method: 'POST',
|
||||||
"endpoint": "ajaxsetprivacy/",
|
endpoint: 'ajaxsetprivacy/',
|
||||||
"json": true,
|
json: true,
|
||||||
"formData": { // it's multipart because lolvalve
|
formData: { // it's multipart because lolvalve
|
||||||
"sessionid": this.getSessionID(),
|
sessionid: this.getSessionID(),
|
||||||
"Privacy": JSON.stringify(privacy),
|
Privacy: JSON.stringify(privacy),
|
||||||
"eCommentPermission": commentPermission
|
eCommentPermission: commentPermission
|
||||||
}
|
}
|
||||||
}, null, function(err, response, body) {
|
}, null, function(err, response, body) {
|
||||||
if (err || response.statusCode != 200) {
|
if (err || response.statusCode != 200) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error('HTTP error ' + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -230,7 +241,7 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
|||||||
|
|
||||||
if (body.success != 1) {
|
if (body.success != 1) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(new Error(body.success ? "Error " + body.success : "Request was not successful"));
|
callback(new Error(body.success ? 'Error ' + body.success : 'Request was not successful'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "steamcommunity",
|
"name": "steamcommunity",
|
||||||
"version": "3.41.4",
|
"version": "3.41.7",
|
||||||
"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": [
|
"keywords": [
|
||||||
"steam",
|
"steam",
|
||||||
|
|||||||
Reference in New Issue
Block a user