steamutils 1.0.51 → 1.0.53
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/SteamClient.js +32 -26
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -88,10 +88,10 @@ function SteamClient({
|
|
88
88
|
username,
|
89
89
|
password,
|
90
90
|
cookie,
|
91
|
+
isAutoRequestFreeLicense = true
|
91
92
|
}) {
|
92
93
|
const steamClient = new SteamUser()
|
93
94
|
let prime = null
|
94
|
-
let gamename = null;
|
95
95
|
|
96
96
|
const events = {
|
97
97
|
loggedOn: [],
|
@@ -628,14 +628,6 @@ function SteamClient({
|
|
628
628
|
} catch (e) {
|
629
629
|
}
|
630
630
|
|
631
|
-
if (gamename) {
|
632
|
-
steamClient.gamesPlayed([{
|
633
|
-
game_id: appid, game_extra_info: gamename
|
634
|
-
}], true);
|
635
|
-
} else {
|
636
|
-
// steamClient.gamesPlayed(appid, true)
|
637
|
-
}
|
638
|
-
|
639
631
|
steamClient.setPersona(SteamUser.EPersonaState.LookingToPlay)
|
640
632
|
|
641
633
|
while (!steamClient.accountInfo) {
|
@@ -646,6 +638,12 @@ function SteamClient({
|
|
646
638
|
await sendHello()
|
647
639
|
|
648
640
|
callEvent(events.loggedOn)
|
641
|
+
|
642
|
+
if (isAutoRequestFreeLicense) {
|
643
|
+
doSetInterval(function () {
|
644
|
+
autoRequestFreeLicense(false, 50)
|
645
|
+
}, 60000, 'autoRequestFreeLicense')
|
646
|
+
}
|
649
647
|
})
|
650
648
|
|
651
649
|
steamClient.on('friendMessage', async (user, message) => {
|
@@ -819,32 +817,43 @@ function SteamClient({
|
|
819
817
|
async function autoRequestFreeLicense(shouldLog = false, max = 10) {
|
820
818
|
const steamUtils = new SteamUtils(getCookie())
|
821
819
|
|
822
|
-
const
|
820
|
+
const userData = await steamUtils.getDynamicStoreUserData()
|
821
|
+
if (!userData) return
|
822
|
+
const ownedApps = userData.rgOwnedApps || []
|
823
823
|
const ownedAppsCount = shouldLog ? (ownedApps?.length || 0) : 0
|
824
|
-
let recommendedApps = Math.random() > 0.5 ? _.shuffle(
|
824
|
+
let recommendedApps = Math.random() > 0.5 ? _.shuffle(userData.rgRecommendedApps || []) : []
|
825
825
|
if (!recommendedApps?.length) {
|
826
826
|
recommendedApps = (await axios.request({url: 'https://raw.githubusercontent.com/5x/easy-steam-free-packages/master/src/script/packages_db.json'}))?.data?.packages || []
|
827
827
|
}
|
828
828
|
_.remove(recommendedApps, app => ownedApps.includes(app))
|
829
|
-
|
829
|
+
recommendedApps = _.shuffle(recommendedApps)
|
830
830
|
if (max) {
|
831
831
|
recommendedApps.length = Math.min(recommendedApps.length, max)
|
832
832
|
}
|
833
|
-
for (const recommendedApp of recommendedApps) {
|
834
|
-
if (Math.random() > 0.5) {
|
835
833
|
try {
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
}
|
840
|
-
try {
|
841
|
-
await steamClient.requestFreeLicense(recommendedApp)
|
834
|
+
const response = await steamClient.requestFreeLicense(recommendedApps)
|
835
|
+
if (shouldLog) {
|
836
|
+
log(response)
|
837
|
+
}
|
842
838
|
} catch (e) {
|
843
839
|
log(e);
|
844
840
|
}
|
845
|
-
|
846
|
-
|
847
|
-
|
841
|
+
// if (Math.random() > 0.7) {
|
842
|
+
// for (const recommendedApp of recommendedApps) {
|
843
|
+
// try {
|
844
|
+
// await steamUtils.requestFreeLicense(recommendedApp)
|
845
|
+
// } catch (e) {
|
846
|
+
// }
|
847
|
+
// await sleep(2000)
|
848
|
+
// }
|
849
|
+
// } else {
|
850
|
+
// try {
|
851
|
+
// await steamClient.requestFreeLicense(recommendedApps)
|
852
|
+
// } catch (e) {
|
853
|
+
// log(e);
|
854
|
+
// }
|
855
|
+
// }
|
856
|
+
|
848
857
|
if (shouldLog) {
|
849
858
|
await sleep(20000)
|
850
859
|
const ownedAppsCount2 = (await steamUtils.getDynamicStoreUserData())?.rgOwnedApps?.length || 0
|
@@ -900,9 +909,6 @@ function SteamClient({
|
|
900
909
|
setPersona(state, name) {
|
901
910
|
steamClient.setPersona(state, name)
|
902
911
|
},
|
903
|
-
setGameName(name) {
|
904
|
-
gamename = name
|
905
|
-
},
|
906
912
|
sendFriendMessage,
|
907
913
|
sendFriendTyping,
|
908
914
|
getSteamClient() {
|