steamutils 1.3.1 → 1.3.3

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 +54 -19
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -92,7 +92,7 @@ function SteamClient({
92
92
  isAutoRequestFreeLicense = true,
93
93
  isFakeGameScore = true,
94
94
  isPartyRegister = true,
95
- autoPlay = false,
95
+ isAutoPlay = false,
96
96
  autoAcceptTradeRequest = false,
97
97
  autoReconnect = true,
98
98
  MAX_GAME_PLAY = 10
@@ -353,9 +353,9 @@ function SteamClient({
353
353
  } else {
354
354
  ownedApps = ownedApps.map(({appid}) => appid)
355
355
  ownedApps = _.shuffle(ownedApps)
356
- ownedApps.length = Math.min(ownedApps.length, MAX_GAME_PLAY)
357
- ownedApps = _.sortBy(ownedApps, app => app == 730 ? 1 : -1)
358
- gamesPlayed(ownedApps)
356
+ ownedApps.length = Math.min(ownedApps.length, MAX_GAME_PLAY - 1)
357
+ _.remove(ownedApps, app => app == 730)
358
+ gamesPlayed([...ownedApps, 730])
359
359
  }
360
360
  }
361
361
 
@@ -370,6 +370,15 @@ function SteamClient({
370
370
  }
371
371
 
372
372
 
373
+ async function updateAutoGamePlay() {
374
+ if (isAutoPlay) {
375
+ autoGamePlay()
376
+ } else {
377
+ offAutoGamePlay()
378
+ }
379
+ }
380
+
381
+
373
382
  /**
374
383
  * Get a list of lobbies (* = Unsure description could be wrong)
375
384
  * @param {Number} ver Game version we are searching for
@@ -980,14 +989,8 @@ function SteamClient({
980
989
  state = 'Online'
981
990
  await sendHello()
982
991
  callEvent(events.loggedOn, loggedOnResponse)
983
- if (isAutoRequestFreeLicense) {
984
- doSetInterval(function () {
985
- autoRequestFreeLicense(false, 50)
986
- }, [5 * 60000, 10 * 60000], 'autoRequestFreeLicense')
987
- }
988
- if (autoPlay) {
989
- autoGamePlay()
990
- }
992
+ updateAutoRequestFreeLicense()
993
+ updateAutoGamePlay()
991
994
  },
992
995
  async user(steamId, data) {
993
996
  callEvent(events.user, {steamId: steamId.getSteamID64(), data})
@@ -1434,6 +1437,7 @@ function SteamClient({
1434
1437
  }
1435
1438
 
1436
1439
  function _partyRegister(prime) {
1440
+ log("partyRegister", prime)
1437
1441
  lastTimePartyRegister = new Date().getTime()
1438
1442
  steamClient.sendToGC(730, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Register, {}, protoEncode(Protos.csgo.CMsgGCCStrike15_v2_Party_Register, {
1439
1443
  // id : 0,
@@ -1601,6 +1605,16 @@ function SteamClient({
1601
1605
  }
1602
1606
  }
1603
1607
 
1608
+ function updateAutoRequestFreeLicense() {
1609
+ if (isAutoRequestFreeLicense) {
1610
+ doSetInterval(function () {
1611
+ autoRequestFreeLicense(false, 50)
1612
+ }, [5 * 60000, 10 * 60000], 'autoRequestFreeLicense')
1613
+ } else {
1614
+ doClearInterval('autoRequestFreeLicense')
1615
+ }
1616
+ }
1617
+
1604
1618
  async function gamesPlayed(apps) {
1605
1619
  if (!Array.isArray(apps)) {
1606
1620
  apps = [apps]
@@ -1770,18 +1784,39 @@ function SteamClient({
1770
1784
  gamePlay,
1771
1785
  autoGamePlay,
1772
1786
  offAutoGamePlay,
1787
+ updateAutoGamePlay,
1773
1788
  getFriendsList,
1774
1789
  setIsPartyRegister(_isPartyRegister) {
1775
- isPartyRegister = _isPartyRegister
1776
- if (!_isPartyRegister) {
1777
- doClearInterval('autoPartyRegister')
1778
- } else {
1779
- sendHello()
1790
+ _isPartyRegister = !!_isPartyRegister
1791
+ if (isPartyRegister !== isPartyRegister) {
1792
+ isPartyRegister = _isPartyRegister
1793
+ if (!isPartyRegister) {
1794
+ doClearInterval('autoPartyRegister')
1795
+ } else {
1796
+ sendHello()
1797
+ }
1798
+ }
1799
+ },
1800
+ setAutoPlay(_isAutoPlay) {
1801
+ _isAutoPlay = !!_isAutoPlay
1802
+ if (isAutoPlay !== _isAutoPlay) {
1803
+ isAutoPlay = _isAutoPlay
1804
+ updateAutoGamePlay()
1780
1805
  }
1781
1806
  },
1782
1807
  setFakeGameScore(_isFakeGameScore) {
1783
- isFakeGameScore = _isFakeGameScore
1784
- updateFakeGameScore()
1808
+ _isFakeGameScore = !!_isFakeGameScore
1809
+ if (isFakeGameScore !== _isFakeGameScore) {
1810
+ isFakeGameScore = _isFakeGameScore
1811
+ updateFakeGameScore()
1812
+ }
1813
+ },
1814
+ setAutoRequestFreeLicense(_isAutoRequestFreeLicense) {
1815
+ _isAutoRequestFreeLicense = !!_isAutoRequestFreeLicense
1816
+ if (isAutoRequestFreeLicense !== _isAutoRequestFreeLicense) {
1817
+ isAutoRequestFreeLicense = _isAutoRequestFreeLicense
1818
+ updateAutoRequestFreeLicense()
1819
+ }
1785
1820
  },
1786
1821
  getState() {
1787
1822
  return state
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.01",
3
+ "version": "1.3.03",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.5.1",