steamutils 1.1.20 → 1.1.22
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +8 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -19,6 +19,7 @@ import * as cherrio from "cheerio";
|
|
19
19
|
|
20
20
|
const MAX_RETRY = 10
|
21
21
|
let requestTimestamp = 0
|
22
|
+
let tooManyRequestTimestamp = 0
|
22
23
|
export const MatchHistoryType = {
|
23
24
|
matchhistoryscrimmage: 'matchhistoryscrimmage',
|
24
25
|
matchhistorycompetitive: 'matchhistorycompetitive',
|
@@ -1507,10 +1508,13 @@ class SteamUser {
|
|
1507
1508
|
|
1508
1509
|
let now = 0
|
1509
1510
|
let diff = 0
|
1510
|
-
while ((diff = (now = new Date().getTime()) - requestTimestamp) <
|
1511
|
-
await sleep(diff +
|
1511
|
+
while ((diff = (now = new Date().getTime()) - requestTimestamp) < 500) {
|
1512
|
+
await sleep(diff + 10)
|
1512
1513
|
}
|
1513
|
-
|
1514
|
+
while ((diff = (now = new Date().getTime()) - tooManyRequestTimestamp) < 30000) {
|
1515
|
+
await sleep(diff + 10)
|
1516
|
+
}
|
1517
|
+
requestTimestamp = now
|
1514
1518
|
response = await axios.request(config)
|
1515
1519
|
|
1516
1520
|
this._cookies.setCookies(response.headers["set-cookie"])
|
@@ -1521,6 +1525,7 @@ class SteamUser {
|
|
1521
1525
|
break
|
1522
1526
|
} else if (response.status === 429) {
|
1523
1527
|
console.log('Too Many Requests')
|
1528
|
+
tooManyRequestTimestamp = new Date().getTime()
|
1524
1529
|
await sleep(30000)
|
1525
1530
|
break
|
1526
1531
|
} else if (response.status === 401) {
|