steamutils 1.3.41 → 1.3.43

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 +66 -8
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -97,7 +97,8 @@ function SteamClient({
97
97
  isInvisible = false,
98
98
  autoAcceptTradeRequest = false,
99
99
  autoReconnect = true,
100
- MAX_GAME_PLAY = 10
100
+ MAX_GAME_PLAY = 10,
101
+ games = null
101
102
  }) {
102
103
  const steamClient = new NodeSteamUser()
103
104
  let prime = null
@@ -367,6 +368,10 @@ function SteamClient({
367
368
  }
368
369
 
369
370
  async function gamePlay() {
371
+ if ((Array.isArray(games) && games.length) || (games && (typeof games === "number" || typeof games === "string"))) {
372
+ return gamesPlayed(games)
373
+ }
374
+
370
375
  let ownedApps = []
371
376
  for (let i = 0; i < 5; i++) {
372
377
  ownedApps = await getUserOwnedApps()
@@ -591,7 +596,7 @@ function SteamClient({
591
596
  return
592
597
  }
593
598
 
594
- if(!Array.isArray(steamIds)){
599
+ if (!Array.isArray(steamIds)) {
595
600
  steamIds = [steamIds]
596
601
  }
597
602
 
@@ -605,7 +610,7 @@ function SteamClient({
605
610
 
606
611
  for (const steamId of steamIds) {
607
612
  onInvite?.(lobbyID, steamId)
608
- await invite2Lobby(lobbyID, steamId)
613
+ await invite2Lobby(lobbyID, steamId)
609
614
  }
610
615
 
611
616
  return lobbyID
@@ -784,7 +789,7 @@ function SteamClient({
784
789
  errorStr = `Unknown: ${e.eresult}`
785
790
  break
786
791
  }
787
- log('error', e?.message)
792
+ log(`error [isLogOff: ${isLogOff}]`, e?.message)
788
793
  doClearIntervals()
789
794
  callEvent(events.error, {eresult: e.eresult, msg: e.message, error: errorStr})
790
795
  },
@@ -1954,9 +1959,15 @@ function SteamClient({
1954
1959
  }
1955
1960
 
1956
1961
  steamClient.gamesPlayed(apps);
1957
- await sleep(2000)
1958
- // steamClient.setPersona(NodeSteamUser.EPersonaState.Online)
1959
- await sendHello()
1962
+ const shouldHello = apps.some(app => parseInt(app) === 730);
1963
+ await sleep(1000)
1964
+ if (shouldHello) {
1965
+ await sendHello()
1966
+ }
1967
+ await sleep(1000)
1968
+ if (shouldHello) {
1969
+ await sendHello()
1970
+ }
1960
1971
  updateFakeGameScore()
1961
1972
 
1962
1973
  // await sleep(10000)
@@ -2256,7 +2267,7 @@ function SteamClient({
2256
2267
  },
2257
2268
  getUserOwnedApps,
2258
2269
  getPlayingAppIds,
2259
- getCurrentLobby(){
2270
+ getCurrentLobby() {
2260
2271
  return currentLobby
2261
2272
  }
2262
2273
  }
@@ -2267,3 +2278,50 @@ export default SteamClient
2267
2278
  export function increaseCSGO_VER() {
2268
2279
  return ++CSGO_VER
2269
2280
  }
2281
+
2282
+ SteamClient.isAccountPlayable = function isAccountPlayable(cookie, timeoutMs) {
2283
+ return new Promise((resolve) => {
2284
+ const timeout = setTimeout(() => {
2285
+ doResolve();
2286
+ }, timeoutMs || 30000);
2287
+
2288
+ const steamClient = new SteamClient({
2289
+ cookie,
2290
+ isFakeGameScore: false,
2291
+ isAutoPlay: true,
2292
+ isPartyRegister: false,
2293
+ isInvisible: false,
2294
+ MAX_GAME_PLAY: 10,
2295
+ games: 730,
2296
+ });
2297
+
2298
+ steamClient.onEvent("error", ({eresult, msg, error}) => {
2299
+ doResolve();
2300
+ });
2301
+
2302
+ steamClient.onEvent("csgoOnline", ClientWelcome => {
2303
+ doResolve(ClientWelcome);
2304
+ });
2305
+
2306
+ steamClient.onEvent("csgoClientHello", ClientHello => {
2307
+ doResolve(ClientHello);
2308
+ });
2309
+
2310
+ steamClient.onEvent("playingState", ({playing_blocked, playing_app}) => {
2311
+ if (playing_blocked) {
2312
+ doResolve();
2313
+ }
2314
+ },
2315
+ );
2316
+
2317
+ steamClient.init();
2318
+
2319
+ function doResolve(data) {
2320
+ clearTimeout(timeout);
2321
+ steamClient.doClearIntervals();
2322
+ steamClient.offAllEvent();
2323
+ steamClient.logOff();
2324
+ return resolve(!!data);
2325
+ }
2326
+ });
2327
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.41",
3
+ "version": "1.3.43",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.5",