steamutils 1.0.7 → 1.0.9
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 +22 -2
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -356,7 +356,7 @@ function SteamClient({
|
|
356
356
|
.map(p => SteamID.fromIndividualAccountID(p.id).getSteamID64())
|
357
357
|
const personas = await getPersonas(steamIDs)
|
358
358
|
//{
|
359
|
-
// "id": "
|
359
|
+
// "id": "76561199265943339",
|
360
360
|
// "rich_presence": [],
|
361
361
|
// "persona_state": null,
|
362
362
|
// "game_played_app_id": null,
|
@@ -396,7 +396,7 @@ function SteamClient({
|
|
396
396
|
const prime = player.apr === 1 ? 'PRIME' : 'NON-PRIME'
|
397
397
|
const loc = LOCS[player.loc] || player.loc
|
398
398
|
const steamID = SteamID.fromIndividualAccountID(player.id).getSteamID64()
|
399
|
-
const persona = personas.find(p => p.id ==
|
399
|
+
const persona = personas.find(p => p.id == steamID)
|
400
400
|
const friendCode = FriendCode.encode(steamID)
|
401
401
|
|
402
402
|
if ((LOCS[player.loc] == 'VN' || !LOCS[player.loc])) {
|
@@ -564,6 +564,25 @@ function SteamClient({
|
|
564
564
|
}))
|
565
565
|
}
|
566
566
|
|
567
|
+
async function sendFriendMessage(steamId, message) {
|
568
|
+
const now = new Date().getTime()
|
569
|
+
while (new Date().getTime() - now < 5 * 60000) {//5 minutes
|
570
|
+
const result = await new Promise(resolve => {
|
571
|
+
steamClient.chat.sendFriendMessage(steamId, message, undefined, function (...arg) {
|
572
|
+
resolve(arg)
|
573
|
+
});
|
574
|
+
})
|
575
|
+
|
576
|
+
if (result?.[1]?.server_timestamp) {
|
577
|
+
return result?.[1]
|
578
|
+
} else if (result?.[0]?.message?.includes?.("RateLimitExceeded")) {
|
579
|
+
await sleep(5000)
|
580
|
+
} else {
|
581
|
+
return result
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
567
586
|
return {
|
568
587
|
init, partySearch, partyRegister, requestCoPlays, getPersonas, getUsername: function () {
|
569
588
|
return username
|
@@ -577,6 +596,7 @@ function SteamClient({
|
|
577
596
|
}, setGameName: function (name) {
|
578
597
|
gamename = name
|
579
598
|
},
|
599
|
+
sendFriendMessage,
|
580
600
|
}
|
581
601
|
}
|
582
602
|
|