mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 21:23:28 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08d14f19e6 | ||
|
|
cfed757eab | ||
|
|
63defbb643 | ||
|
|
6e20fbe299 | ||
|
|
59090242f9 | ||
|
|
00e82f7e79 | ||
|
|
7b901b147b | ||
|
|
0f7fc98ab5 | ||
|
|
2a12174a7c | ||
|
|
caa76ee84b | ||
|
|
bc8893fedd | ||
|
|
d3e90f6fd3 | ||
|
|
a61b50b7a2 | ||
|
|
39fe4a4106 | ||
|
|
0d991c2655 | ||
|
|
0a307de9b9 | ||
|
|
c0b8dcf3a2 | ||
|
|
dcf00b4ea1 | ||
|
|
ee0cc34512 | ||
|
|
4b8799ddd4 | ||
|
|
f02f85a2aa | ||
|
|
4948cbeac0 | ||
|
|
0fb2798424 |
@@ -1,6 +1,6 @@
|
||||
module.exports = CEconItem;
|
||||
|
||||
function CEconItem(item, description, contextID) {
|
||||
function CEconItem(item, description, contextID, assetProperties) {
|
||||
var thing;
|
||||
for (thing in item) {
|
||||
if (item.hasOwnProperty(thing)) {
|
||||
@@ -28,7 +28,7 @@ function CEconItem(item, description, contextID) {
|
||||
}
|
||||
|
||||
for (thing in description) {
|
||||
if (description.hasOwnProperty(thing)) {
|
||||
if (description.hasOwnProperty(thing) && !this.hasOwnProperty(thing)) {
|
||||
this[thing] = description[thing];
|
||||
}
|
||||
}
|
||||
@@ -68,10 +68,26 @@ function CEconItem(item, description, contextID) {
|
||||
|
||||
// Restore cache_expiration, if we can (for CS:GO items)
|
||||
if (this.appid == 730 && this.contextid == 2 && this.owner_descriptions) {
|
||||
let description = this.owner_descriptions.find(d => d.value && d.value.indexOf('Tradable/Marketable After ') == 0);
|
||||
let description = this.owner_descriptions.find((d) => d.value && d.value.indexOf("Tradable/Marketable After ") == 0);
|
||||
if (description) {
|
||||
let date = new Date(description.value.substring(26).replace(/[,()]/g, ''));
|
||||
if (date) {
|
||||
let date;
|
||||
const match = description.value.match(/(\d{1,2}) (\w+) @ (\d{1,2}:\d{2})(am|pm)/i);
|
||||
if (match) {
|
||||
// New day-first format, e.g. "Tradable/Marketable After 17 Jul @ 3:00am"
|
||||
const [, day, month, time, meridian] = match;
|
||||
const now = new Date();
|
||||
let year = now.getFullYear();
|
||||
date = new Date(`${day} ${month} ${year} ${time} ${meridian}`);
|
||||
|
||||
if (date.getTime() < now.getTime()) {
|
||||
date = new Date(`${day} ${month} ${year + 1} ${time} ${meridian}`);
|
||||
}
|
||||
} else {
|
||||
// Legacy month-first format, e.g. "Tradable/Marketable After Jul 11, 2025 (2:00:00)"
|
||||
date = new Date(description.value.substring("Tradable/Marketable After ".length).replace(/[,()]/g, ""));
|
||||
}
|
||||
|
||||
if (date && !isNaN(date.getTime())) {
|
||||
this.cache_expiration = date.toISOString();
|
||||
}
|
||||
}
|
||||
@@ -86,6 +102,11 @@ function CEconItem(item, description, contextID) {
|
||||
this.actions = [];
|
||||
}
|
||||
|
||||
// Assign asset_properties if provided
|
||||
if (assetProperties) {
|
||||
this.asset_properties = assetProperties;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
@@ -392,6 +392,22 @@ SteamCommunity.prototype.checkConfirmations = function() {
|
||||
}
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.acknowledgeTradeProtection = function(callback) {
|
||||
this.httpRequestPost({
|
||||
uri: 'https://steamcommunity.com//trade/new/acknowledge',
|
||||
form: {
|
||||
sessionid: this.getSessionID(),
|
||||
message: 1
|
||||
}
|
||||
}, (err, res, body) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
||||
callback && callback(null);
|
||||
}, 'steamcommunity');
|
||||
}
|
||||
|
||||
SteamCommunity.prototype._confirmationCheckerGetKey = function(tag, callback) {
|
||||
if(this._identitySecret) {
|
||||
if(tag == 'details') {
|
||||
|
||||
@@ -68,6 +68,10 @@ SteamCommunity.prototype._modernLogin = function(logOnDetails) {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
session.on('timeout', () => {
|
||||
reject(new Error('Login timed out'));
|
||||
});
|
||||
|
||||
try {
|
||||
let startResult = await session.startWithCredentials({
|
||||
accountName: logOnDetails.accountName,
|
||||
|
||||
@@ -590,7 +590,7 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
|
||||
},
|
||||
"qs": {
|
||||
"l": language, // Default language
|
||||
"count": 5000, // Max items per 'page'
|
||||
"count": 1000, // Max items per 'page'
|
||||
"start_assetid": start
|
||||
},
|
||||
"json": true
|
||||
@@ -647,12 +647,21 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
|
||||
return;
|
||||
}
|
||||
|
||||
// Build asset_properties lookup by assetid
|
||||
var assetPropertiesLookup = {};
|
||||
if (body.asset_properties) {
|
||||
for (var j = 0; j < body.asset_properties.length; j++) {
|
||||
assetPropertiesLookup[body.asset_properties[j].assetid] = body.asset_properties[j].asset_properties;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < body.assets.length; i++) {
|
||||
var description = getDescription(body.descriptions, body.assets[i].classid, body.assets[i].instanceid);
|
||||
|
||||
if (!tradableOnly || (description && description.tradable)) {
|
||||
body.assets[i].pos = pos++;
|
||||
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID));
|
||||
var assetProperties = assetPropertiesLookup[body.assets[i].assetid] || null;
|
||||
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID, assetProperties));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "steamcommunity",
|
||||
"version": "3.48.6",
|
||||
"version": "3.50.2",
|
||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||
"files": [
|
||||
"/classes",
|
||||
|
||||
Reference in New Issue
Block a user