steamutils 1.2.26 → 1.2.28
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +6 -0
- package/index.js +4 -5
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -96,6 +96,7 @@ function SteamClient({
|
|
96
96
|
let isLogOff = false
|
97
97
|
let playingBlocked = null
|
98
98
|
const richPresence = {}
|
99
|
+
let sendMessageTimestamp = 0
|
99
100
|
|
100
101
|
const events = {
|
101
102
|
user: [],
|
@@ -1303,6 +1304,10 @@ function SteamClient({
|
|
1303
1304
|
}
|
1304
1305
|
|
1305
1306
|
async function sendFriendMessage(steamId, message) {
|
1307
|
+
while (sendMessageTimestamp && new Date().getTime() - sendMessageTimestamp < 1100){
|
1308
|
+
await sleep(500)
|
1309
|
+
}
|
1310
|
+
|
1306
1311
|
const now = new Date().getTime()
|
1307
1312
|
while (new Date().getTime() - now < 5 * 60000) {//5 minutes
|
1308
1313
|
const result = await new Promise(resolve => {
|
@@ -1312,6 +1317,7 @@ function SteamClient({
|
|
1312
1317
|
})
|
1313
1318
|
|
1314
1319
|
if (result?.[1]?.server_timestamp) {
|
1320
|
+
sendMessageTimestamp= new Date().getTime()
|
1315
1321
|
return result?.[1]
|
1316
1322
|
} else if (result?.[0]?.message?.includes?.("RateLimitExceeded")) {
|
1317
1323
|
await sleep(5000)
|
package/index.js
CHANGED
@@ -2435,7 +2435,8 @@ class SteamUser {
|
|
2435
2435
|
return await this.getFollowingPlayersList(steamID)
|
2436
2436
|
}
|
2437
2437
|
|
2438
|
-
_parsePendingFriendList(selector) {
|
2438
|
+
_parsePendingFriendList(html, selector) {
|
2439
|
+
const $ = cherrio.load(html || '')
|
2439
2440
|
const data = []
|
2440
2441
|
$(selector).each(function () {
|
2441
2442
|
const el = $(this)
|
@@ -2463,10 +2464,8 @@ class SteamUser {
|
|
2463
2464
|
async getPendingFriendList() {
|
2464
2465
|
const result = await this._httpRequest(`${this._myProfile}/friends/pending`)
|
2465
2466
|
if (!result?.data || typeof result._$ !== 'function') return null
|
2466
|
-
const
|
2467
|
-
|
2468
|
-
const sentInvites = this._parsePendingFriendList('#search_results_sentinvites > div')
|
2469
|
-
const receiveInvites = this._parsePendingFriendList('#search_results > div')
|
2467
|
+
const sentInvites = this._parsePendingFriendList(result.data, '#search_results_sentinvites > div')
|
2468
|
+
const receiveInvites = this._parsePendingFriendList(result.data, '#search_results > div')
|
2470
2469
|
return {
|
2471
2470
|
sentInvites,
|
2472
2471
|
receiveInvites,
|