steamutils 1.0.10 → 1.0.12
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 +28 -3
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -90,7 +90,8 @@ function SteamClient({
|
|
90
90
|
let gamename = null;
|
91
91
|
|
92
92
|
const events = {
|
93
|
-
loggedOn: []
|
93
|
+
loggedOn: [],
|
94
|
+
friendMessage: [],
|
94
95
|
}
|
95
96
|
|
96
97
|
const personasCache = []
|
@@ -112,8 +113,12 @@ function SteamClient({
|
|
112
113
|
}
|
113
114
|
}
|
114
115
|
if (!personas) {
|
115
|
-
|
116
|
-
|
116
|
+
try {
|
117
|
+
personas = (await steamClient.getPersonas(steamIDs))?.personas
|
118
|
+
} catch (e) {
|
119
|
+
}
|
120
|
+
}
|
121
|
+
if (personas) {
|
117
122
|
for (let sid64 in personas) {
|
118
123
|
personas[sid64].id = sid64
|
119
124
|
personas[sid64].avatar_hash = Buffer.from(personas[sid64].avatar_hash).toString("hex")
|
@@ -519,6 +524,26 @@ function SteamClient({
|
|
519
524
|
|
520
525
|
events.loggedOn.forEach(e => e?.invoke?.())
|
521
526
|
})
|
527
|
+
|
528
|
+
steamClient.on('friendMessage', async (user, message) => {
|
529
|
+
if ([`Invited you to play a game!`, `Đã mời bạn chơi một trò chơi!`].includes(message)) {
|
530
|
+
if(events.friendMessage.length){
|
531
|
+
const sid = user;
|
532
|
+
const personas = await getPersonas([sid]);
|
533
|
+
const player_name = personas[sid]?.player_name || ''
|
534
|
+
events.friendMessage.forEach(e => e?.({
|
535
|
+
player_name,
|
536
|
+
sid64: user.getSteamID64(),
|
537
|
+
}))
|
538
|
+
}
|
539
|
+
} else {
|
540
|
+
console.log('friendMessage', user.getSteamID64(), message);
|
541
|
+
events.friendMessage.forEach(e => e?.({
|
542
|
+
message,
|
543
|
+
sid64: user.getSteamID64(),
|
544
|
+
}))
|
545
|
+
}
|
546
|
+
});
|
522
547
|
}
|
523
548
|
|
524
549
|
function getPlayersProfile(accountid) {
|