steamutils 1.4.56 → 1.4.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/SteamClient.js +44 -22
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -30,6 +30,7 @@ export const RANKS = {
30
30
  17: "Supreme Master First Class",
31
31
  18: "The Global Elite",
32
32
  };
33
+
33
34
  export const LOCS = {
34
35
  20054: "VN",
35
36
  23115: "KZ",
@@ -190,7 +191,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
190
191
  }
191
192
  }
192
193
 
193
- delete events[name];
194
+ events[name] = [];
194
195
  }
195
196
 
196
197
  function onAnyEvent(callback) {
@@ -207,7 +208,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
207
208
  delete event.timeout;
208
209
  }
209
210
  }
210
- delete events[name];
211
+ events[name] = [];
211
212
  }
212
213
  onAnyCallbacks.length = 0;
213
214
  }
@@ -390,15 +391,23 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
390
391
 
391
392
  /**
392
393
  * Get a list of lobbies (* = Unsure description could be wrong)
393
- * @param {Number} ver Game version we are searching for
394
- * @param {Boolean} apr Prime or not*
395
- * @param {Number} ark Rank multiplied by 10*
396
- * @param {Array.<Number>} grps *
397
- * @param {Number} launcher If we are using the China CSGO launcher or not*
398
- * @param {Number} game_type Game type, 8 Competitive, 10 Wingman
399
- * @returns {Promise.<Object>}
394
+ * @param {Boolean} prime
395
+ * @param {Number|String} rank
396
+ * @param {Competitive|Wingman|Premier} game_type
397
+ * @param {Number} timeout
398
+ * @returns {Promise.<Array>}
400
399
  */
401
- async function partySearch({ prime = false, game_type = "Competitive", rank = "Silver Elite", timeout = 5000 } = {}) {
400
+ async function partySearch({ prime = false, game_type = "Premier", rank, timeout = 5000 } = {}) {
401
+ const gameTypeMap = {
402
+ Competitive: 8,
403
+ Wingman: 10,
404
+ Premier: 11,
405
+ };
406
+
407
+ if (typeof rank === "string") {
408
+ rank = parseInt(Object.keys(RANKS).find((k) => RANKS[k] === rank)) * 10;
409
+ }
410
+
402
411
  const players = await new Promise((resolve) => {
403
412
  steamClient.sendToGC(
404
413
  AppID,
@@ -407,10 +416,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
407
416
  new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Search).protoEncode({
408
417
  ver: CSGO_VER,
409
418
  apr: prime ? 1 : 0,
410
- ark: parseInt(Object.keys(RANKS).find((k) => RANKS[k] === rank)) * 10,
419
+ ark: rank,
411
420
  grps: [],
412
- launcher: 0,
413
- game_type: game_type === "Competitive" ? 8 : 10,
421
+ launcher: 0, // If we are using the China CSGO launcher or not*
422
+ game_type: gameTypeMap[game_type],
414
423
  }),
415
424
  );
416
425
  lastTimePartySearch = Date.now();
@@ -2549,17 +2558,29 @@ SteamClient.isAccountPlayable = async function isAccountPlayable({ cookie, clien
2549
2558
  ...rest,
2550
2559
  });
2551
2560
 
2552
- steamClient.onEvent(SteamClientEvents.error, ({ eresult, msg, error }) => {
2553
- doResolve({ eresult, msg, error });
2554
- });
2561
+ steamClient.onEvent(
2562
+ SteamClientEvents.error,
2563
+ ({ eresult, msg, error }) => {
2564
+ doResolve({ eresult, msg, error });
2565
+ },
2566
+ true,
2567
+ );
2555
2568
 
2556
- steamClient.onEvent(SteamClientEvents.csgoOnline, (ClientWelcome) => {
2557
- doResolve({ playable: true });
2558
- });
2569
+ steamClient.onEvent(
2570
+ SteamClientEvents.csgoOnline,
2571
+ (ClientWelcome) => {
2572
+ doResolve({ playable: true });
2573
+ },
2574
+ true,
2575
+ );
2559
2576
 
2560
- steamClient.onEvent(SteamClientEvents.csgoClientHello, (ClientHello) => {
2561
- doResolve({ playable: true });
2562
- });
2577
+ steamClient.onEvent(
2578
+ SteamClientEvents.csgoClientHello,
2579
+ (ClientHello) => {
2580
+ doResolve({ playable: true });
2581
+ },
2582
+ true,
2583
+ );
2563
2584
 
2564
2585
  steamClient.onEvent(SteamClientEvents.playingState, ({ playing_blocked, playing_app }) => {
2565
2586
  if (playing_blocked) {
@@ -2607,6 +2628,7 @@ SteamClient.isAccountPlayable = async function isAccountPlayable({ cookie, clien
2607
2628
  steamClient.logOff();
2608
2629
  return resolve(data);
2609
2630
  } else {
2631
+ steamClient.offAllEvent();
2610
2632
  return resolve({ ...data, steamClient });
2611
2633
  }
2612
2634
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.56",
3
+ "version": "1.4.58",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",