steamutils 1.3.59 → 1.3.61

Sign up to get free protection for your applications and to get access to all the features.
package/SteamClient.js CHANGED
@@ -849,7 +849,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
849
849
  const result = protoDecode(Protos.csgo.CSOPersonaDataPublic, object_data);
850
850
  obj.PersonaDataPublic = result;
851
851
  const example = {
852
- player_level: 4,
852
+ player_level: 4, //CSGO_Profile_Rank
853
853
  commendation: {
854
854
  cmd_friendly: 149,
855
855
  cmd_teaching: 108,
@@ -2318,6 +2318,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2318
2318
  getCurrentLobby() {
2319
2319
  return currentLobby;
2320
2320
  },
2321
+ setGame(_games) {
2322
+ games = _games;
2323
+ },
2321
2324
  };
2322
2325
  }
2323
2326
 
@@ -31,14 +31,23 @@ import _ from "lodash";
31
31
  const __params = [${params}];
32
32
  if(__params.length === 1 && __params[0] === undefined){
33
33
  __params.length = 0
34
- }
34
+ }
35
+ let __cookies = this._cookies;
36
+ if (__cookies) {
37
+ if (!Array.isArray(__cookies)) {
38
+ __cookies = [__cookies];
39
+ }
40
+ __cookies = __cookies.map(function (cookie) {
41
+ return cookie.toString();
42
+ });
43
+ }
35
44
 
36
45
  try {
37
46
  const result = (
38
47
  await axios.post(getAppURL(), {
39
48
  method: "${methodName}",
40
49
  params: __params,
41
- cookies: this._cookies,
50
+ cookies: __cookies,
42
51
  is_static: ${!!is_static}
43
52
  })
44
53
  ).data?.result;
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: "https://steamcommunity.com/profiles/" + steamId,
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
- if ((memberSince = moment.utc(`November 3, 2016`, ["MMMM DD, YYYY", "MMMM D, YYYY", "MMMM DD", "MMMM D"], true)).isValid()) {
323
- memberSince = memberSince.valueOf();
324
- } else {
325
- memberSince = _profile.memberSince;
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.data) {
1522
+ if (!result?.data) {
1517
1523
  return;
1518
1524
  }
1519
1525
  let g_rgProfileData = JSON_parse(result.data.substringBetweenOrNull("g_rgProfileData = ", '"};') + '"}');
@@ -2091,8 +2097,8 @@ export default class SteamUser {
2091
2097
  if (result instanceof ResponseError) {
2092
2098
  return result;
2093
2099
  }
2094
- const sentInvites = SteamUser._parsePendingFriendList(result.data, "#search_results_sentinvites > div");
2095
- const receiveInvites = SteamUser._parsePendingFriendList(result.data, "#search_results > div");
2100
+ const sentInvites = SteamUser._parsePendingFriendList(result?.data, "#search_results_sentinvites > div");
2101
+ const receiveInvites = SteamUser._parsePendingFriendList(result?.data, "#search_results > div");
2096
2102
  return {
2097
2103
  sentInvites,
2098
2104
  receiveInvites,
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.59",
3
+ "version": "1.3.61",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",