steamutils 1.4.56 → 1.4.58
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +44 -22
- 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
|
-
|
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
|
-
|
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 {
|
394
|
-
* @param {
|
395
|
-
* @param {
|
396
|
-
* @param {
|
397
|
-
* @
|
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 = "
|
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:
|
419
|
+
ark: rank,
|
411
420
|
grps: [],
|
412
|
-
launcher: 0,
|
413
|
-
game_type: game_type
|
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(
|
2553
|
-
|
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(
|
2557
|
-
|
2558
|
-
|
2569
|
+
steamClient.onEvent(
|
2570
|
+
SteamClientEvents.csgoOnline,
|
2571
|
+
(ClientWelcome) => {
|
2572
|
+
doResolve({ playable: true });
|
2573
|
+
},
|
2574
|
+
true,
|
2575
|
+
);
|
2559
2576
|
|
2560
|
-
steamClient.onEvent(
|
2561
|
-
|
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
|
}
|