mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 13:13:28 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa8d897590 | ||
|
|
f7fe587312 | ||
|
|
08d14f19e6 | ||
|
|
cfed757eab | ||
|
|
63defbb643 | ||
|
|
6e20fbe299 | ||
|
|
59090242f9 | ||
|
|
00e82f7e79 | ||
|
|
7b901b147b | ||
|
|
0f7fc98ab5 | ||
|
|
2a12174a7c | ||
|
|
caa76ee84b | ||
|
|
bc8893fedd |
@@ -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)) {
|
||||
@@ -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) {
|
||||
|
||||
@@ -261,7 +261,10 @@ function request(community, url, key, time, tag, params, json, callback) {
|
||||
var req = {
|
||||
method: url == 'multiajaxop' ? 'POST' : 'GET',
|
||||
uri: 'https://steamcommunity.com/mobileconf/' + url,
|
||||
json: !!json
|
||||
json: !!json,
|
||||
headers: {
|
||||
'user-agent': 'okhttp/4.9.2'
|
||||
}
|
||||
};
|
||||
|
||||
if (req.method == 'GET') {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.49.0",
|
||||
"version": "3.50.3",
|
||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||
"files": [
|
||||
"/classes",
|
||||
|
||||
Reference in New Issue
Block a user