steamutils 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/SteamClient.js +32 -9
- package/package.json +1 -1
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/SteamClient.js
CHANGED
@@ -99,6 +99,8 @@ function SteamClient({
|
|
99
99
|
friendTyping: [],
|
100
100
|
}
|
101
101
|
|
102
|
+
const intervals = []
|
103
|
+
|
102
104
|
function getAccountInfoName() {
|
103
105
|
return [steamClient?.accountInfo?.name, steamClient?._logOnDetails?.account_name].filter(Boolean).join(" - ")
|
104
106
|
}
|
@@ -199,7 +201,8 @@ function SteamClient({
|
|
199
201
|
|
200
202
|
function bindEvent() {
|
201
203
|
steamClient.on('disconnected', async (eresult, msg) => {
|
202
|
-
console.log('disconnected')
|
204
|
+
console.log('disconnected', eresult, msg)
|
205
|
+
intervals?.forEach(intervalID => clearInterval(intervalID))
|
203
206
|
})
|
204
207
|
steamClient.on('error', async (e) => {
|
205
208
|
let errorStr = ``
|
@@ -222,6 +225,7 @@ function SteamClient({
|
|
222
225
|
break
|
223
226
|
}
|
224
227
|
console.log('error', e?.message)
|
228
|
+
intervals?.forEach(intervalID => clearInterval(intervalID))
|
225
229
|
})
|
226
230
|
|
227
231
|
steamClient.on('webSession', (sessionID, cookies) => {
|
@@ -530,13 +534,13 @@ function SteamClient({
|
|
530
534
|
game_id: appid, game_extra_info: gamename
|
531
535
|
}], true);
|
532
536
|
} else {
|
533
|
-
steamClient.gamesPlayed(appid, true)
|
537
|
+
// steamClient.gamesPlayed(appid, true)
|
534
538
|
}
|
535
539
|
|
536
540
|
steamClient.setPersona(SteamUser.EPersonaState.LookingToPlay)
|
537
541
|
|
538
542
|
while (!steamClient.accountInfo) {
|
539
|
-
await sleep(
|
543
|
+
await sleep(1000)
|
540
544
|
}
|
541
545
|
|
542
546
|
console.log(`app ${appid} launched on account ${getAccountInfoName()}`)
|
@@ -694,10 +698,10 @@ function SteamClient({
|
|
694
698
|
}
|
695
699
|
|
696
700
|
async function autoRequestFreeLicense(log = false, max = 10) {
|
697
|
-
const steamUtils = new SteamUtils(
|
701
|
+
const steamUtils = new SteamUtils(getCookie())
|
698
702
|
|
699
703
|
const ownedAppsCount = log ? (await steamUtils.getDynamicStoreUserData()).rgOwnedApps.length : 0
|
700
|
-
|
704
|
+
let recommendedApps = _.shuffle((await steamUtils.getDynamicStoreUserData())?.rgRecommendedApps)
|
701
705
|
if (!recommendedApps.length) {
|
702
706
|
recommendedApps = (await axios.request({url: 'https://raw.githubusercontent.com/5x/easy-steam-free-packages/master/src/script/packages_db.json'}))?.data?.packages
|
703
707
|
}
|
@@ -727,6 +731,20 @@ function SteamClient({
|
|
727
731
|
}
|
728
732
|
}
|
729
733
|
|
734
|
+
function getCookie() {
|
735
|
+
return cookie || steamClient?.webSession?.cookies?.join?.(';')
|
736
|
+
}
|
737
|
+
|
738
|
+
async function playCSGO() {
|
739
|
+
try {
|
740
|
+
await steamClient.requestFreeLicense(appid)
|
741
|
+
await sleep(5000)
|
742
|
+
} catch (e) {
|
743
|
+
}
|
744
|
+
steamClient.gamesPlayed(appid, true)
|
745
|
+
steamClient.setPersona(SteamUser.EPersonaState.LookingToPlay)
|
746
|
+
}
|
747
|
+
|
730
748
|
return {
|
731
749
|
init,
|
732
750
|
partySearch,
|
@@ -736,9 +754,7 @@ function SteamClient({
|
|
736
754
|
getUsername() {
|
737
755
|
return username
|
738
756
|
},
|
739
|
-
getCookie
|
740
|
-
return cookie
|
741
|
-
},
|
757
|
+
getCookie,
|
742
758
|
getLogOnDetails() {
|
743
759
|
return steamClient?._logOnDetails
|
744
760
|
},
|
@@ -748,6 +764,9 @@ function SteamClient({
|
|
748
764
|
}
|
749
765
|
events[name].push(cb)
|
750
766
|
},
|
767
|
+
onEventLoggedOn(cb) {
|
768
|
+
events.loggedOn.push(cb)
|
769
|
+
},
|
751
770
|
setPersona(state, name) {
|
752
771
|
steamClient.setPersona(state, name)
|
753
772
|
},
|
@@ -761,7 +780,11 @@ function SteamClient({
|
|
761
780
|
},
|
762
781
|
getAccountInfoName,
|
763
782
|
getPlayersProfile,
|
764
|
-
autoRequestFreeLicense
|
783
|
+
autoRequestFreeLicense,
|
784
|
+
playCSGO,
|
785
|
+
setInterval(cb, timeout){
|
786
|
+
intervals.push(setInterval(cb, timeout))
|
787
|
+
}
|
765
788
|
}
|
766
789
|
}
|
767
790
|
|