steamutils 1.0.19 → 1.0.21
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 +25 -9
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -101,6 +101,7 @@ function SteamClient({
|
|
101
101
|
}
|
102
102
|
|
103
103
|
async function getPersonas(steamIDs) {
|
104
|
+
steamIDs = steamIDs.map(steamID => steamID instanceof SteamID ? steamID.getSteamID64() : steamID)
|
104
105
|
const notCachesteamIDs = steamIDs.filter(id => !PersonasCache.some(p => p.id == id))
|
105
106
|
const cachedPersonas = PersonasCache.filter(p => steamIDs.includes(p.id))
|
106
107
|
|
@@ -110,19 +111,19 @@ function SteamClient({
|
|
110
111
|
personas = (await steamClient.getPersonas(steamIDs))?.personas
|
111
112
|
} catch (e) {
|
112
113
|
}
|
113
|
-
if (!personas) {
|
114
|
+
if (!personas || !Object.keys(personas).length) {
|
114
115
|
try {
|
115
116
|
personas = (await steamClient.getPersonas(steamIDs))?.personas
|
116
117
|
} catch (e) {
|
117
118
|
}
|
118
119
|
}
|
119
|
-
if (!personas) {
|
120
|
+
if (!personas || !Object.keys(personas).length) {
|
120
121
|
try {
|
121
122
|
personas = (await steamClient.getPersonas(steamIDs))?.personas
|
122
123
|
} catch (e) {
|
123
124
|
}
|
124
125
|
}
|
125
|
-
if (personas) {
|
126
|
+
if (personas && Object.keys(personas).length) {
|
126
127
|
for (let sid64 in personas) {
|
127
128
|
personas[sid64].id = sid64
|
128
129
|
personas[sid64].avatar_hash = Buffer.from(personas[sid64].avatar_hash).toString("hex")
|
@@ -238,11 +239,13 @@ function SteamClient({
|
|
238
239
|
}
|
239
240
|
case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
|
240
241
|
const msg = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_Invite, payload);
|
241
|
-
const
|
242
|
-
|
243
|
-
const
|
244
|
-
|
245
|
-
|
242
|
+
const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
|
243
|
+
const personas = await getPersonas([sid64]);
|
244
|
+
const player_name = personas.find(p => p.id == sid64)?.player_name
|
245
|
+
if(player_name === undefined){
|
246
|
+
console.log(sid64, personas);
|
247
|
+
}
|
248
|
+
console.log(getAccountInfoName(), player_name, `https://steamcommunity.com/profiles/${sid64}`);
|
246
249
|
// joinLobby(msg.lobbyid, msg.accountid)
|
247
250
|
break
|
248
251
|
}
|
@@ -466,6 +469,11 @@ function SteamClient({
|
|
466
469
|
player_xp_bonus_flags: 0
|
467
470
|
}]
|
468
471
|
console.log(data);
|
472
|
+
|
473
|
+
const accountid = data?.[0]?.account_id
|
474
|
+
const cb = getPlayersProfileCallback[accountid]
|
475
|
+
delete getPlayersProfileCallback[accountid]
|
476
|
+
cb?.(data?.[0])
|
469
477
|
break
|
470
478
|
}
|
471
479
|
default:
|
@@ -565,11 +573,18 @@ function SteamClient({
|
|
565
573
|
steamClient.chat.sendFriendTyping(steamId, callback)
|
566
574
|
}
|
567
575
|
|
576
|
+
|
577
|
+
const getPlayersProfileCallback = {};
|
578
|
+
|
568
579
|
function getPlayersProfile(accountid) {
|
569
580
|
steamClient.sendToGC(730, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestPlayersProfile, {}, protoEncode(Protos.csgo.CMsgGCCStrike15_v2_ClientRequestPlayersProfile, {
|
570
581
|
account_id: accountid, // account_id: new SteamID('76561199184696945').accountid,
|
571
582
|
request_level: 32
|
572
583
|
}))
|
584
|
+
return new Promise(resolve => {
|
585
|
+
getPlayersProfileCallback[accountid] = resolve
|
586
|
+
setTimeout(resolve, 30000)
|
587
|
+
})
|
573
588
|
}
|
574
589
|
|
575
590
|
async function login() {
|
@@ -654,7 +669,8 @@ function SteamClient({
|
|
654
669
|
getSteamClient() {
|
655
670
|
return steamClient
|
656
671
|
},
|
657
|
-
getAccountInfoName
|
672
|
+
getAccountInfoName,
|
673
|
+
getPlayersProfile
|
658
674
|
}
|
659
675
|
}
|
660
676
|
|