steamutils 1.3.59 → 1.3.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +30 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -220,7 +220,7 @@ export default class SteamUser {
|
|
|
220
220
|
try {
|
|
221
221
|
const result = (
|
|
222
222
|
await request({
|
|
223
|
-
url:
|
|
223
|
+
url: `https://steamcommunity.com/profiles/${steamId}?l=english`,
|
|
224
224
|
headers: { ...(cookie && { cookie }) },
|
|
225
225
|
})
|
|
226
226
|
).data;
|
|
@@ -319,10 +319,13 @@ export default class SteamUser {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
let memberSince;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
const formats = ["MMMM DD, YYYY", "MMMM D, YYYY", "MMMM DD", "MMMM D"];
|
|
323
|
+
for (const format of formats) {
|
|
324
|
+
const memberSinceMoment = moment(_profile.memberSince, format, true);
|
|
325
|
+
if (memberSinceMoment.isValid()) {
|
|
326
|
+
memberSince = moment(_profile.memberSince, format, true).valueOf();
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
326
329
|
}
|
|
327
330
|
|
|
328
331
|
const avatarHash = SteamUser.GetAvatarHashFromMultipleURL([_profile.avatarIcon, _profile.avatarFull]);
|
|
@@ -1056,9 +1059,12 @@ export default class SteamUser {
|
|
|
1056
1059
|
.filter(Boolean);
|
|
1057
1060
|
if (!queryList.some((q) => q.toLowerCase().startsWith("sessionid".toLowerCase()))) {
|
|
1058
1061
|
queryList.push(`sessionid=${this.getSessionid()}`);
|
|
1059
|
-
const protocol = urlObject.protocol ? `${urlObject.protocol}//${urlObject.host}` : "";
|
|
1060
|
-
params.url = `${protocol}${urlObject.pathname}?${queryList.join("&")}`;
|
|
1061
1062
|
}
|
|
1063
|
+
if (!queryList.some((q) => q.toLowerCase().startsWith("l".toLowerCase()))) {
|
|
1064
|
+
queryList.push(`l=english`);
|
|
1065
|
+
}
|
|
1066
|
+
const protocol = urlObject.protocol ? `${urlObject.protocol}//${urlObject.host}` : "";
|
|
1067
|
+
params.url = `${protocol}${urlObject.pathname}?${queryList.join("&")}`;
|
|
1062
1068
|
|
|
1063
1069
|
if (!(params.headers instanceof Header)) {
|
|
1064
1070
|
params.headers = new Header(params.headers);
|
|
@@ -1513,7 +1519,7 @@ export default class SteamUser {
|
|
|
1513
1519
|
if (result instanceof ResponseError) {
|
|
1514
1520
|
return result;
|
|
1515
1521
|
}
|
|
1516
|
-
if (!result
|
|
1522
|
+
if (!result?.data) {
|
|
1517
1523
|
return;
|
|
1518
1524
|
}
|
|
1519
1525
|
let g_rgProfileData = JSON_parse(result.data.substringBetweenOrNull("g_rgProfileData = ", '"};') + '"}');
|
|
@@ -6384,6 +6390,22 @@ export default class SteamUser {
|
|
|
6384
6390
|
//example 13 June, 2023
|
|
6385
6391
|
return friendSince;
|
|
6386
6392
|
}
|
|
6393
|
+
|
|
6394
|
+
async getWalletBalance() {
|
|
6395
|
+
const result = await this._httpRequest(`my?l=english`);
|
|
6396
|
+
if (result instanceof ResponseError) {
|
|
6397
|
+
return result;
|
|
6398
|
+
}
|
|
6399
|
+
const html = result?.data;
|
|
6400
|
+
if (!html || typeof html !== "string") {
|
|
6401
|
+
return;
|
|
6402
|
+
}
|
|
6403
|
+
const $ = cheerio.load(html);
|
|
6404
|
+
const headerEl = $("#header_wallet_balance");
|
|
6405
|
+
try {
|
|
6406
|
+
return headerEl[0].children.map((el) => $(el).text().trim()).filter(Boolean);
|
|
6407
|
+
} catch (e) {}
|
|
6408
|
+
}
|
|
6387
6409
|
}
|
|
6388
6410
|
|
|
6389
6411
|
SteamUser.MAX_RETRY = 10;
|