mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-09-04 06:22:46 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b11734cd9b | ||
|
|
5c37c38dda | ||
|
|
260bfaa0ad | ||
|
|
1031a4dbd7 | ||
|
|
e28fe5ca05 | ||
|
|
90a9ee1aa9 | ||
|
|
9a069e80fb | ||
|
|
640c47b933 | ||
|
|
f5d65a9ad4 | ||
|
|
7ae8a97a0f | ||
|
|
ec1284e961 | ||
|
|
dc4bb1b554 | ||
|
|
cd90d7a563 |
3
.idea/codeStyles/Project.xml
generated
3
.idea/codeStyles/Project.xml
generated
@@ -1,8 +1,5 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<XML>
|
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
|
||||||
</XML>
|
|
||||||
<codeStyleSettings language="JSON">
|
<codeStyleSettings language="JSON">
|
||||||
<indentOptions>
|
<indentOptions>
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
|||||||
1
.idea/codeStyles/codeStyleConfig.xml
generated
1
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +1,6 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<state>
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
</state>
|
</state>
|
||||||
</component>
|
</component>
|
||||||
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -2,6 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/../node-steamcommunity Wiki/.idea/node-steamcommunity Wiki.iml" filepath="$PROJECT_DIR$/../node-steamcommunity Wiki/.idea/node-steamcommunity Wiki.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/steamcommunity.iml" filepath="$PROJECT_DIR$/.idea/steamcommunity.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/steamcommunity.iml" filepath="$PROJECT_DIR$/.idea/steamcommunity.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
1
.idea/steamcommunity.iml
generated
1
.idea/steamcommunity.iml
generated
@@ -5,5 +5,6 @@
|
|||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="node-steamcommunity Wiki" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../node-steamcommunity Wiki" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,6 +2,8 @@ const SteamCommunity = require('../index.js');
|
|||||||
|
|
||||||
const Helpers = require('./helpers.js');
|
const Helpers = require('./helpers.js');
|
||||||
|
|
||||||
|
const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore a previously removed steam package from your steam account.
|
* Restore a previously removed steam package from your steam account.
|
||||||
* @param {int|string} packageID
|
* @param {int|string} packageID
|
||||||
@@ -9,26 +11,14 @@ const Helpers = require('./helpers.js');
|
|||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://help.steampowered.com/wizard/AjaxDoPackageRestore",
|
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
|
||||||
"form": {
|
form: {
|
||||||
"packageid": packageID,
|
packageid: packageID,
|
||||||
"sessionid": this.getSessionID('https://help.steampowered.com'),
|
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
||||||
"wizard_ajax": 1
|
wizard_ajax: 1
|
||||||
},
|
},
|
||||||
"json": true
|
json: true
|
||||||
}, (err, res, body) => {
|
}, wizardAjaxHandler(callback));
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!body.success) {
|
|
||||||
callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,14 +28,27 @@ SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
|||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://help.steampowered.com/wizard/AjaxDoPackageRemove",
|
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
|
||||||
"form": {
|
form: {
|
||||||
"packageid": packageID,
|
packageid: packageID,
|
||||||
"sessionid": this.getSessionID('https://help.steampowered.com'),
|
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
||||||
"wizard_ajax": 1
|
wizard_ajax: 1
|
||||||
},
|
},
|
||||||
"json": true
|
json: true
|
||||||
}, (err, res, body) => {
|
}, wizardAjaxHandler(callback));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a handler for wizard ajax HTTP requests.
|
||||||
|
* @param {function} callback
|
||||||
|
* @returns {(function(*=, *, *): void)|*}
|
||||||
|
*/
|
||||||
|
function wizardAjaxHandler(callback) {
|
||||||
|
return (err, res, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
@@ -57,5 +60,5 @@ SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
});
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof html === 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
if (typeof html === 'string' && html.indexOf('g_steamID = false;') > -1 && html.indexOf('<title>Sign In</title>') > -1) {
|
||||||
err = new Error("Not Logged In");
|
err = new Error("Not Logged In");
|
||||||
callback(err);
|
callback(err);
|
||||||
this._notifySessionExpired(err);
|
this._notifySessionExpired(err);
|
||||||
|
|||||||
@@ -148,6 +148,124 @@ SteamCommunity.prototype.openBoosterPack = function(appid, assetid, callback) {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the booster pack catalog to see what booster packs you can create
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getBoosterPackCatalog = function(callback) {
|
||||||
|
this.httpRequestGet('https://steamcommunity.com/tradingcards/boostercreator/', (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let idx = body.indexOf('CBoosterCreatorPage.Init(');
|
||||||
|
if (idx == -1) {
|
||||||
|
callback(new Error('Malformed response'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lines = body.slice(idx).split('\n').map(l => l.trim());
|
||||||
|
|
||||||
|
for (let i = 1; i <= 4; i++) {
|
||||||
|
if (typeof lines[i] != 'string' || !lines[i].match(/,$/)) {
|
||||||
|
let err = new Error('Malformed response');
|
||||||
|
err.line = i;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lines[i] = lines[i].replace(/,$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
let boosterPackCatalog, totalGems, tradableGems, untradableGems;
|
||||||
|
try {
|
||||||
|
boosterPackCatalog = JSON.parse(lines[1]);
|
||||||
|
totalGems = parseInt(lines[2].match(/\d+/)[0], 10);
|
||||||
|
tradableGems = parseInt(lines[3].match(/\d+/)[0], 10);
|
||||||
|
untradableGems = parseInt(lines[4].match(/\d+/)[0], 10);
|
||||||
|
} catch (ex) {
|
||||||
|
let err = new Error('Malformed response');
|
||||||
|
err.inner = ex;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let keyedCatalog = {};
|
||||||
|
boosterPackCatalog.forEach((app) => {
|
||||||
|
app.price = parseInt(app.price, 10);
|
||||||
|
app.unavailable = app.unavailable || false;
|
||||||
|
app.availableAtTime = app.available_at_time || null;
|
||||||
|
|
||||||
|
if (typeof app.availableAtTime == 'string') {
|
||||||
|
app.availableAtTime = Helpers.decodeSteamTime(app.availableAtTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete app.available_at_time;
|
||||||
|
|
||||||
|
keyedCatalog[app.appid] = app;
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, {
|
||||||
|
totalGems,
|
||||||
|
tradableGems,
|
||||||
|
untradableGems,
|
||||||
|
catalog: keyedCatalog
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a booster pack using gems.
|
||||||
|
* @param {int} appid
|
||||||
|
* @param {boolean} [useUntradableGems=false]
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.createBoosterPack = function(appid, useUntradableGems, callback) {
|
||||||
|
if (typeof useUntradableGems == 'function') {
|
||||||
|
callback = useUntradableGems;
|
||||||
|
useUntradableGems = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
uri: 'https://steamcommunity.com/tradingcards/ajaxcreatebooster/',
|
||||||
|
form: {
|
||||||
|
sessionid: this.getSessionID(),
|
||||||
|
appid,
|
||||||
|
series: 1,
|
||||||
|
// tradability_preference can be a value 1-3
|
||||||
|
// 1: Prefer using tradable gems, but use untradable if necessary
|
||||||
|
// 2: Only use tradable gems
|
||||||
|
// 3: Prefer using untradable gems, but use tradable if necessary
|
||||||
|
tradability_preference: useUntradableGems ? 3 : 2
|
||||||
|
},
|
||||||
|
json: true,
|
||||||
|
checkHttpError: false
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.purchase_eresult && body.purchase_eresult != 1) {
|
||||||
|
callback(Helpers.eresultError(body.purchase_eresult));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can now check HTTP status codes
|
||||||
|
if (this._checkHttpError(err, res, callback, body)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, {
|
||||||
|
totalGems: parseInt(body.goo_amount, 10),
|
||||||
|
tradableGems: parseInt(body.tradable_goo_amount, 10),
|
||||||
|
untradableGems: parseInt(body.untradable_goo_amount, 10),
|
||||||
|
resultItem: body.purchase_result
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get details about a gift in your inventory.
|
* Get details about a gift in your inventory.
|
||||||
* @param {string} giftID
|
* @param {string} giftID
|
||||||
|
|||||||
@@ -240,14 +240,14 @@ SteamCommunity.prototype.getUserComments = function(userID, options, callback) {
|
|||||||
return {
|
return {
|
||||||
id: $elem.attr("id").split("_")[1],
|
id: $elem.attr("id").split("_")[1],
|
||||||
author: {
|
author: {
|
||||||
id: new SteamID("[U:1:" + $elem.find("[data-miniprofile]").data("miniprofile") + "]"),
|
steamID: new SteamID("[U:1:" + $elem.find("[data-miniprofile]").data("miniprofile") + "]"),
|
||||||
name: $elem.find("bdi").text(),
|
name: $elem.find("bdi").text(),
|
||||||
avatar: $elem.find(".playerAvatar img[src]").attr("src"),
|
avatar: $elem.find(".playerAvatar img[src]").attr("src"),
|
||||||
state: $elem.find(".playerAvatar").attr("class").split(" ").pop()
|
state: $elem.find(".playerAvatar").attr("class").split(" ").pop()
|
||||||
},
|
},
|
||||||
date: new Date($elem.find(".commentthread_comment_timestamp").data("timestamp") * 1000),
|
date: new Date($elem.find(".commentthread_comment_timestamp").data("timestamp") * 1000),
|
||||||
text: $commentContent.text(),
|
text: $commentContent.text().trim(),
|
||||||
html: $commentContent.html()
|
html: $commentContent.html().trim()
|
||||||
}
|
}
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "steamcommunity",
|
"name": "steamcommunity",
|
||||||
"version": "3.43.0",
|
"version": "3.44.2",
|
||||||
"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