Compare commits

...

10 Commits

Author SHA1 Message Date
Alex Corn
d9b6b55efc 3.41.7 2020-09-23 18:11:33 -04:00
Alex Corn
0fc62d2966 Merge pull request #257 from timi-owo/master
Fixed 'language' was missing from the 'CSteamUser.getInventoryContents'
2020-09-23 17:46:59 -04:00
timi-owo
5daf5f712a Fixed param 'language' was missing when calling 'CSteamUser.getInventoryContents' method 2020-09-24 01:44:32 +08:00
Alex Corn
737aa9dc41 Added comment 2020-07-01 00:52:15 -04:00
Alex Corn
07fb26047b 3.41.6 2020-06-30 22:36:48 -04:00
Alex Corn
2f9b24c447 Only attempt to delete this.currency if it actually exists 2020-06-30 22:24:04 -04:00
Alex Corn
211c625da0 3.41.5 2020-06-26 03:45:17 -04:00
Alex Corn
2e61a6ed70 Fixed editProfile and profileSettings for Steam update 2020-06-26 03:44:58 -04:00
Alex Corn
f0a3cb27f8 Merge pull request #250 from itsjfx/open-booster-pack-patch
Add openBoosterPack
2020-05-28 22:30:35 -04:00
jfx
58516d4ed1 Add openBoosterPack 2020-05-23 16:24:20 +10:00
6 changed files with 108 additions and 55 deletions

View File

@@ -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>

View File

@@ -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() {

View File

@@ -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);
}; };
/** /**

View File

@@ -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

View File

@@ -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;

View File

@@ -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",