steamutils 1.0.8 → 1.0.10

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.
Files changed (2) hide show
  1. package/SteamClient.js +25 -4
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -228,11 +228,12 @@ function SteamClient({
228
228
  break
229
229
  }
230
230
  case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
231
- let msg = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_Invite, payload)
232
- let sid = SteamID.fromIndividualAccountID(msg.accountid);
231
+ const msg = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_Invite, payload);
232
+ const sid = SteamID.fromIndividualAccountID(msg.accountid);
233
233
  // console.log(msg)
234
- let personas = await getPersonas([sid])
235
- console.log(personas?.[sid]?.player_name, `https://steamcommunity.com/profiles/${sid.getSteamID64()}`);
234
+ const personas = await getPersonas([sid]);
235
+ const sID64 = sid.getSteamID64();
236
+ console.log(personas.find(p => p.id == sID64)?.player_name, `https://steamcommunity.com/profiles/${sID64}`);
236
237
  // joinLobby(msg.lobbyid, msg.accountid)
237
238
  break
238
239
  }
@@ -564,6 +565,25 @@ function SteamClient({
564
565
  }))
565
566
  }
566
567
 
568
+ async function sendFriendMessage(steamId, message) {
569
+ const now = new Date().getTime()
570
+ while (new Date().getTime() - now < 5 * 60000) {//5 minutes
571
+ const result = await new Promise(resolve => {
572
+ steamClient.chat.sendFriendMessage(steamId, message, undefined, function (...arg) {
573
+ resolve(arg)
574
+ });
575
+ })
576
+
577
+ if (result?.[1]?.server_timestamp) {
578
+ return result?.[1]
579
+ } else if (result?.[0]?.message?.includes?.("RateLimitExceeded")) {
580
+ await sleep(5000)
581
+ } else {
582
+ return result
583
+ }
584
+ }
585
+ }
586
+
567
587
  return {
568
588
  init, partySearch, partyRegister, requestCoPlays, getPersonas, getUsername: function () {
569
589
  return username
@@ -577,6 +597,7 @@ function SteamClient({
577
597
  }, setGameName: function (name) {
578
598
  gamename = name
579
599
  },
600
+ sendFriendMessage,
580
601
  }
581
602
  }
582
603
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "dependencies": {
5
5
  "axios": "^1.3.4",
6
6
  "cheerio": "^1.0.0-rc.12",