steamutils 1.0.55 → 1.0.57
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 +42 -10
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -628,7 +628,6 @@ function SteamClient({
|
|
628
628
|
await sleep(1000)
|
629
629
|
}
|
630
630
|
|
631
|
-
log(`app ${appid} launched`)
|
632
631
|
await sendHello()
|
633
632
|
|
634
633
|
callEvent(events.loggedOn)
|
@@ -640,8 +639,28 @@ function SteamClient({
|
|
640
639
|
}
|
641
640
|
})
|
642
641
|
|
643
|
-
steamClient.on('friendMessage', async (
|
644
|
-
const
|
642
|
+
steamClient.chat.on('friendMessage', async (data) => {
|
643
|
+
const example = {
|
644
|
+
"steamid_friend": {
|
645
|
+
"universe": 1,
|
646
|
+
"type": 1,
|
647
|
+
"instance": 1,
|
648
|
+
"accountid": 1080136620
|
649
|
+
},
|
650
|
+
"chat_entry_type": 1,
|
651
|
+
"from_limited_account": false,
|
652
|
+
"message": "xxx",
|
653
|
+
"ordinal": 0,
|
654
|
+
"local_echo": false,
|
655
|
+
"message_no_bbcode": "xxx",
|
656
|
+
"low_priority": false,
|
657
|
+
"server_timestamp": "2023-05-14T09:26:25.000Z",
|
658
|
+
"message_bbcode_parsed": [
|
659
|
+
"xxx"
|
660
|
+
]
|
661
|
+
}
|
662
|
+
const timestamp = new Date(data.server_timestamp).getTime()
|
663
|
+
const sid64 = data.steamid_friend.getSteamID64();
|
645
664
|
const personas = await getPersonas([sid64]);
|
646
665
|
const player_name = personas[sid64]?.player_name || ''
|
647
666
|
log('friendMessage', sid64, message);
|
@@ -649,15 +668,17 @@ function SteamClient({
|
|
649
668
|
if ([`Inited you to play a game!`, `Đã mời bạn chơi một trò chơi!`].includes(message)) {
|
650
669
|
callEvent(events.friendMessage, {
|
651
670
|
player_name,
|
652
|
-
message,
|
671
|
+
message: data.message_no_bbcode,
|
653
672
|
invite: true,
|
654
673
|
sid64,
|
674
|
+
timestamp,
|
655
675
|
})
|
656
676
|
} else {
|
657
677
|
callEvent(events.friendMessage, {
|
658
|
-
message,
|
678
|
+
message: data.message_no_bbcode,
|
659
679
|
player_name,
|
660
680
|
sid64,
|
681
|
+
timestamp,
|
661
682
|
})
|
662
683
|
}
|
663
684
|
});
|
@@ -726,13 +747,24 @@ function SteamClient({
|
|
726
747
|
return cookie
|
727
748
|
}
|
728
749
|
|
729
|
-
|
730
750
|
async function loginWithCookie(cookie, tryNewCookie = false) {
|
731
|
-
|
732
|
-
|
733
|
-
|
751
|
+
let response;
|
752
|
+
for (let i = 0; i < 10; i++) {
|
753
|
+
try {
|
754
|
+
response = (await axios.request({
|
755
|
+
url: 'https://steamcommunity.com/chat/clientjstoken',
|
756
|
+
headers: {
|
757
|
+
cookie,
|
758
|
+
},
|
759
|
+
}));
|
760
|
+
} catch (e) {
|
761
|
+
await sleep(1000)
|
734
762
|
}
|
735
|
-
|
763
|
+
if (response) {
|
764
|
+
break;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
|
736
768
|
const result = response?.data
|
737
769
|
if (result?.logged_in) {
|
738
770
|
Object.assign(result, {
|