steamutils 1.4.47 → 1.4.49

Sign up to get free protection for your applications and to get access to all the features.
package/SteamClient.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import NodeSteamUser from "steam-user";
2
2
  import _ from "lodash";
3
3
  import SteamID from "steamid";
4
- import FriendCode from "csgo-friendcode";
5
4
  import axios from "axios";
6
5
  import SteamUser from "./index.js";
7
6
  import { v4 as uuidv4 } from "uuid";
8
7
  import EFriendRelationship from "steam-user/enums/EFriendRelationship.js";
9
- import SteamCommunity from "steamcommunity";
10
8
  import moment from "moment-timezone";
11
9
  import { encode, encodeUids } from "./bufferHelpers.js";
12
10
  import { ESteamProto, SteamProto, SteamProtoType } from "./steamproto.js";
@@ -1154,23 +1152,26 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1154
1152
  // }
1155
1153
 
1156
1154
  const players = [];
1157
- for (const player of entries) {
1158
- try {
1159
- const prime = player.apr === 1 ? "PRIME" : "NON-PRIME";
1160
- const loc = LOCS[player.loc] || player.loc;
1161
- const steamId = SteamID.fromIndividualAccountID(player.id).getSteamID64();
1162
- const friendCode = FriendCode.encode(steamId);
1163
-
1164
- // if ((LOCS[player.loc] == 'VN' || !LOCS[player.loc])) {
1165
- players.push({
1166
- prime,
1167
- rank: RANKS[player.ark] !== undefined ? RANKS[player.ark] : player.ark,
1168
- loc,
1169
- steamId,
1170
- friendCode,
1171
- });
1172
- // }
1173
- } catch (e) {}
1155
+ if (entries.length) {
1156
+ const FriendCode = (await import("csgo-friendcode")).default;
1157
+ for (const player of entries) {
1158
+ try {
1159
+ const prime = player.apr === 1 ? "PRIME" : "NON-PRIME";
1160
+ const loc = LOCS[player.loc] || player.loc;
1161
+ const steamId = SteamID.fromIndividualAccountID(player.id).getSteamID64();
1162
+ const friendCode = FriendCode.encode(steamId);
1163
+
1164
+ // if ((LOCS[player.loc] == 'VN' || !LOCS[player.loc])) {
1165
+ players.push({
1166
+ prime,
1167
+ rank: RANKS[player.ark] !== undefined ? RANKS[player.ark] : player.ark,
1168
+ loc,
1169
+ steamId,
1170
+ friendCode,
1171
+ });
1172
+ // }
1173
+ } catch (e) {}
1174
+ }
1174
1175
  }
1175
1176
 
1176
1177
  callGCCallback("partySearch", players);
@@ -1298,7 +1299,16 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1298
1299
  async user(steamId, data) {
1299
1300
  callEvent(events.user, { steamId: steamId.getSteamID64(), data });
1300
1301
 
1301
- _cleanNodeSteamUserData();
1302
+ // cleanNodeSteamUserData
1303
+ for (const friendSteamId in steamClient.users) {
1304
+ steamClient.users[friendSteamId] = {};
1305
+ }
1306
+ if (_cleanNodeSteamUserTimeout) {
1307
+ clearTimeout(_cleanNodeSteamUserTimeout);
1308
+ }
1309
+ _cleanNodeSteamUserTimeout = setTimeout(function () {
1310
+ steamClient.users = {};
1311
+ }, 60000);
1302
1312
 
1303
1313
  const dataExample = {
1304
1314
  rich_presence: [
@@ -1392,9 +1402,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1392
1402
  }
1393
1403
  if (playing_blocked) {
1394
1404
  //true, false
1395
- log("Playing else where");
1405
+ log(`Playing else where ${playing_app ?? ""}`);
1406
+ } else {
1407
+ log(`playingState not blocked ${playing_app ?? ""}`);
1396
1408
  }
1397
- log("playingState", playing_blocked, playing_app);
1398
1409
  callEvent(events.playingState, { playing_blocked, playing_app });
1399
1410
  },
1400
1411
  async friendRelationship(sid, relationship, previousRelationship) {
@@ -2301,18 +2312,6 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2301
2312
  );
2302
2313
  }
2303
2314
 
2304
- function _cleanNodeSteamUserData() {
2305
- for (const friendSteamId in steamClient.users) {
2306
- steamClient.users[friendSteamId] = {};
2307
- }
2308
- if (_cleanNodeSteamUserTimeout) {
2309
- clearTimeout(_cleanNodeSteamUserTimeout);
2310
- }
2311
- setTimeout(function () {
2312
- steamClient.users = {};
2313
- }, 60000);
2314
- }
2315
-
2316
2315
  return {
2317
2316
  init,
2318
2317
  partySearch,
@@ -2443,6 +2442,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2443
2442
  onAnyEvent,
2444
2443
  async redeemGift(gid) {
2445
2444
  try {
2445
+ const SteamCommunity = (await import("steamcommunity")).default;
2446
2446
  const community = new SteamCommunity();
2447
2447
  let cookies = await getCookiesWait();
2448
2448
  community.setCookies(typeof cookies === "string" ? cookies.split(";") : cookies);
package/_steamproto.js CHANGED
@@ -22,6 +22,10 @@ export class SteamProto {
22
22
  return protobuf.encode(protobuf.create(obj)).finish();
23
23
  }
24
24
 
25
+ protoEncodeBase64(obj) {
26
+ return this.protoEncode(obj);
27
+ }
28
+
25
29
  protoDecode(obj) {
26
30
  const protobuf = this.toProto();
27
31
  return protobuf.toObject(protobuf.decode(obj), { defaults: true });