steamutils 1.1.89 → 1.1.91
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/index.js +84 -37
- package/package.json +1 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
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/index.js
CHANGED
@@ -1045,6 +1045,37 @@ class SteamUser {
|
|
1045
1045
|
}
|
1046
1046
|
}
|
1047
1047
|
|
1048
|
+
static async getUsersSummaryByWebApiKey(webApiKey, steamIds) {
|
1049
|
+
if (!Array.isArray(steamIds)) {
|
1050
|
+
steamIds = [steamIds]
|
1051
|
+
}
|
1052
|
+
let response = await request(`https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${webApiKey}&steamids=${steamIds.join(',')}`)
|
1053
|
+
return response?.data?.response?.players || []
|
1054
|
+
const resultExample = [{
|
1055
|
+
"steamid": "76561199040402348",
|
1056
|
+
"communityvisibilitystate": 3,
|
1057
|
+
"profilestate": 1,
|
1058
|
+
"personaname": "Na",
|
1059
|
+
"commentpermission": 1,
|
1060
|
+
"profileurl": "https://steamcommunity.com/id/natri99/",
|
1061
|
+
"avatar": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96d38b61ee0ba64.jpg",
|
1062
|
+
"avatarmedium": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f66d38b51ee0ba64_medium.jpg",
|
1063
|
+
"avatarfull": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96e38b51ee0ba64_full.jpg",
|
1064
|
+
"avatarhash": "834966fea6a0a8a3b7011db7f96d38b51ee0ba64",
|
1065
|
+
"lastlogoff": 1685298425,
|
1066
|
+
"personastate": 0,
|
1067
|
+
"primaryclanid": "103582791470373577",
|
1068
|
+
"timecreated": 1585473529,
|
1069
|
+
"personastateflags": 0
|
1070
|
+
}]
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
static async getUserFriendListByWebApiKey(webApiKey, steamId) {
|
1074
|
+
const response = await request(`http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=${webApiKey}&steamid=${steamId}&relationship=friend`);
|
1075
|
+
return response.data.friendslist.friends.map(({steamid}) => steamid) || []
|
1076
|
+
const resultExample = ["76561198112239954", "76561199239548264", "76561199446829671"]
|
1077
|
+
}
|
1078
|
+
|
1048
1079
|
static async QueryLocations () {
|
1049
1080
|
let response = await request(`https://steamcommunity.com//actions/QueryLocations/`)
|
1050
1081
|
return response?.data || []
|
@@ -1506,6 +1537,7 @@ class SteamUser {
|
|
1506
1537
|
let response = null
|
1507
1538
|
let retry = 10
|
1508
1539
|
let checkTooManyRequest = false
|
1540
|
+
|
1509
1541
|
while (--retry) {
|
1510
1542
|
const config = {
|
1511
1543
|
baseURL: SteamcommunityURL,
|
@@ -1535,50 +1567,65 @@ class SteamUser {
|
|
1535
1567
|
response = await axios.request(config)
|
1536
1568
|
|
1537
1569
|
this._cookies.setCookies(response.headers["set-cookie"])
|
1538
|
-
if (response.status === 302) {
|
1539
|
-
redirectURL = response.headers.location
|
1540
1570
|
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1571
|
+
switch (response.status) {
|
1572
|
+
case 302: {
|
1573
|
+
redirectURL = response.headers.location
|
1574
|
+
|
1575
|
+
if (redirectURL?.startsWith('https://steamcommunity.com/id/')) {
|
1576
|
+
const customURL = redirectURL.split('/')[4];
|
1577
|
+
if (customURL) {
|
1578
|
+
this._myProfile = `id/${customURL}`
|
1579
|
+
}
|
1580
|
+
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1581
|
+
console.error('Login first', this._steamid_user)
|
1582
|
+
return null
|
1545
1583
|
}
|
1546
|
-
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1547
|
-
console.error('Login first', this._steamid_user)
|
1548
|
-
return null
|
1549
|
-
}
|
1550
1584
|
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1585
|
+
console.log(`Redirect ${config.url} to ${redirectURL}`)
|
1586
|
+
break
|
1587
|
+
}
|
1588
|
+
case 200: {
|
1589
|
+
if (response.data && typeof response.data === 'string') {
|
1590
|
+
response._$ = function () {
|
1591
|
+
return cheerio.load(response.data
|
1592
|
+
.replaceAll(/[\t\n\r]/gi, '')
|
1593
|
+
.trim())
|
1594
|
+
}
|
1558
1595
|
}
|
1596
|
+
return response
|
1597
|
+
break
|
1559
1598
|
}
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
} else if (response.status === 401) {
|
1567
|
-
console.log('Unauthorized', config.url)
|
1568
|
-
if (params.method.toUpperCase() === 'POST') {
|
1569
|
-
config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
|
1570
|
-
retry = 1
|
1599
|
+
case 429: {
|
1600
|
+
console.log('Too Many Requests', config.url)
|
1601
|
+
tooManyRequestTimestamp = new Date().getTime()
|
1602
|
+
checkTooManyRequest = true
|
1603
|
+
await sleep(30000)
|
1604
|
+
break
|
1571
1605
|
}
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1606
|
+
case 401: {
|
1607
|
+
console.log('Unauthorized', config.url)
|
1608
|
+
if (params.method.toUpperCase() === 'POST') {
|
1609
|
+
config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
|
1610
|
+
retry = 1
|
1611
|
+
}
|
1612
|
+
break
|
1613
|
+
}
|
1614
|
+
case 400: {
|
1615
|
+
console.log('Error', response.status, config.url)
|
1616
|
+
if (params.method.toUpperCase() === 'POST') {
|
1617
|
+
config.headers['Content-Type'] = config.headers['content-type'] = 'application/x-www-form-urlencoded'
|
1618
|
+
retry = 1
|
1619
|
+
}
|
1620
|
+
break
|
1621
|
+
}
|
1622
|
+
case 500: {
|
1623
|
+
console.log(response.status, response.statusText, config.url, response.data)
|
1624
|
+
break
|
1625
|
+
}
|
1626
|
+
default: {
|
1627
|
+
console.log(response.status, config.url);
|
1577
1628
|
}
|
1578
|
-
} else if (response.status === 500) {
|
1579
|
-
console.log(response.status, response.statusText, config.url, response.data)
|
1580
|
-
} else {
|
1581
|
-
console.log(response.status, config.url);
|
1582
1629
|
}
|
1583
1630
|
}
|
1584
1631
|
return response
|
package/package.json
CHANGED