steamutils 1.2.94 → 1.2.95
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 +57 -17
- package/index.js +5 -1
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -95,6 +95,7 @@ function SteamClient({
|
|
95
95
|
autoPlay = false,
|
96
96
|
autoAcceptTradeRequest = false,
|
97
97
|
autoReconnect = true,
|
98
|
+
MAX_GAME_PLAY = 10
|
98
99
|
}) {
|
99
100
|
const steamClient = new SteamUser()
|
100
101
|
let prime = null
|
@@ -106,6 +107,7 @@ function SteamClient({
|
|
106
107
|
let lastTimePartyRegister = 0
|
107
108
|
let lastTimePartySearch = 0
|
108
109
|
const appsPlayed = []
|
110
|
+
const ownedApps = []
|
109
111
|
|
110
112
|
const onAnyCallbacks = []
|
111
113
|
|
@@ -339,20 +341,22 @@ function SteamClient({
|
|
339
341
|
}
|
340
342
|
|
341
343
|
async function gamePlay() {
|
342
|
-
let ownedApps =
|
343
|
-
for (let i = 0; i <
|
344
|
-
|
345
|
-
|
346
|
-
await sleep(1000)
|
347
|
-
} else {
|
344
|
+
let ownedApps = []
|
345
|
+
for (let i = 0; i < 5; i++) {
|
346
|
+
ownedApps = await getUserOwnedApps()
|
347
|
+
if (ownedApps.length) {
|
348
348
|
break
|
349
349
|
}
|
350
350
|
}
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
351
|
+
if (!ownedApps.length) {
|
352
|
+
gamesPlayed(730)
|
353
|
+
} else {
|
354
|
+
ownedApps = ownedApps.map(({appid}) => appid)
|
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)
|
359
|
+
}
|
356
360
|
}
|
357
361
|
|
358
362
|
async function autoGamePlay() {
|
@@ -982,10 +986,7 @@ function SteamClient({
|
|
982
986
|
}, [5 * 60000, 10 * 60000], 'autoRequestFreeLicense')
|
983
987
|
}
|
984
988
|
if (autoPlay) {
|
985
|
-
|
986
|
-
onCookie(function () {
|
987
|
-
autoGamePlay()
|
988
|
-
})
|
989
|
+
autoGamePlay()
|
989
990
|
}
|
990
991
|
},
|
991
992
|
async user(steamId, data) {
|
@@ -1154,7 +1155,7 @@ function SteamClient({
|
|
1154
1155
|
SenderAddress,
|
1155
1156
|
SenderName
|
1156
1157
|
})
|
1157
|
-
}
|
1158
|
+
},
|
1158
1159
|
}
|
1159
1160
|
|
1160
1161
|
const _chatEvents = {
|
@@ -1667,6 +1668,44 @@ function SteamClient({
|
|
1667
1668
|
steamClient.sendToGC(730, 767, {}, Buffer.alloc(0))
|
1668
1669
|
}
|
1669
1670
|
|
1671
|
+
async function getUserOwnedApps(steamId) {
|
1672
|
+
steamId = (steamId ? new SteamID(steamId) : steamClient.steamID).getSteamID64()
|
1673
|
+
const isMe = steamId === steamClient.steamID.getSteamID64();
|
1674
|
+
if (isMe && ownedApps.length) {
|
1675
|
+
return ownedApps
|
1676
|
+
}
|
1677
|
+
const result = await steamClient.getUserOwnedApps(steamId)
|
1678
|
+
if (isMe && Array.isArray(result.apps)) {
|
1679
|
+
ownedApps.length = 0
|
1680
|
+
ownedApps.push(...result.apps)
|
1681
|
+
}
|
1682
|
+
return result.apps || []
|
1683
|
+
const resultExample = {
|
1684
|
+
app_count: 22,
|
1685
|
+
apps: [
|
1686
|
+
{
|
1687
|
+
content_descriptorids: [],
|
1688
|
+
appid: 208030,
|
1689
|
+
name: "Moon Breakers",
|
1690
|
+
playtime_2weeks: null,
|
1691
|
+
playtime_forever: 0,
|
1692
|
+
img_icon_url: "",
|
1693
|
+
has_community_visible_stats: null,
|
1694
|
+
playtime_windows_forever: 0,
|
1695
|
+
playtime_mac_forever: 0,
|
1696
|
+
playtime_linux_forever: 0,
|
1697
|
+
rtime_last_played: 0,
|
1698
|
+
capsule_filename: null,
|
1699
|
+
sort_as: null,
|
1700
|
+
has_workshop: null,
|
1701
|
+
has_market: null,
|
1702
|
+
has_dlc: null,
|
1703
|
+
has_leaderboards: null
|
1704
|
+
},
|
1705
|
+
]
|
1706
|
+
}
|
1707
|
+
}
|
1708
|
+
|
1670
1709
|
return {
|
1671
1710
|
init,
|
1672
1711
|
partySearch,
|
@@ -1822,7 +1861,8 @@ function SteamClient({
|
|
1822
1861
|
})
|
1823
1862
|
}
|
1824
1863
|
steamClient.uploadRichPresence(appid, richPresence)
|
1825
|
-
}
|
1864
|
+
},
|
1865
|
+
getUserOwnedApps
|
1826
1866
|
}
|
1827
1867
|
}
|
1828
1868
|
|
package/index.js
CHANGED
@@ -5849,7 +5849,11 @@ class SteamUser {
|
|
5849
5849
|
|
5850
5850
|
static parseTradeURL(tradeURL) {
|
5851
5851
|
try {
|
5852
|
-
|
5852
|
+
let search = new URL(tradeURL).search;
|
5853
|
+
if(search.startsWith("?")){
|
5854
|
+
search = search.substring(1)
|
5855
|
+
}
|
5856
|
+
const tradeURLParams = search.split('&').reduce((accumulator, currentValue, index) => ({
|
5853
5857
|
...accumulator, [currentValue.split('=')[0]]: currentValue.split('=')[1]
|
5854
5858
|
}), {})
|
5855
5859
|
|