steamutils 1.3.19 → 1.3.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/SteamClient.js +4 -0
  2. package/index.js +35 -39
  3. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -130,6 +130,7 @@ function SteamClient({
130
130
  friendsList: [],
131
131
  gifts: [],
132
132
  playingState: [],
133
+ emailInfo: [],
133
134
  }
134
135
 
135
136
  const gcCallback = {}
@@ -1186,6 +1187,9 @@ function SteamClient({
1186
1187
  SenderName
1187
1188
  })
1188
1189
  },
1190
+ async emailInfo(address, validated) {
1191
+ callEvent(events.emailInfo, {address, validated})
1192
+ },
1189
1193
  }
1190
1194
 
1191
1195
  const _chatEvents = {
package/index.js CHANGED
@@ -1657,7 +1657,7 @@ class SteamUser {
1657
1657
  },
1658
1658
  maxRedirects: 0,
1659
1659
  url: redirectURL || params.url,
1660
- httpsAgent: new https.Agent({ keepAlive: true }),//fix bug socket hangup axios
1660
+ httpsAgent: new https.Agent({keepAlive: true}),//fix bug socket hangup axios
1661
1661
  }
1662
1662
 
1663
1663
 
@@ -1809,10 +1809,15 @@ class SteamUser {
1809
1809
  },
1810
1810
  method: 'POST',
1811
1811
  })
1812
- return data?.success === 1 ? {
1813
- ...data.invite,
1814
- steamid_user: this.getSteamidUser(),
1815
- } : null
1812
+ if (data?.success === 1 && data.invite) {
1813
+ return {
1814
+ ...data.invite,
1815
+ invite_limit: parseInt(data.invite.invite_limit) || data.invite.invite_limit,
1816
+ invite_duration: parseInt(data.invite.invite_duration) || data.invite.invite_duration,
1817
+ steamid_user: this.getSteamidUser(),
1818
+ }
1819
+ }
1820
+ return null
1816
1821
 
1817
1822
  const resultExample = {
1818
1823
  success: 1,
@@ -1842,28 +1847,26 @@ class SteamUser {
1842
1847
  }
1843
1848
 
1844
1849
  async getCurrentQuickInviteTokens() {
1845
- return (await this._httpRequest(`invites/ajaxgetall?sessionid=${this._sessionid}`))?.data
1850
+ const result = (await this._httpRequest(`invites/ajaxgetall?sessionid=${this._sessionid}`))?.data
1851
+ result?.tokens?.forEach?.(function (token) {
1852
+ if (token?.invite_limit) {
1853
+ token.invite_limit = parseInt(token.invite_limit) || token.invite_limit
1854
+ }
1855
+ if (token?.invite_duration) {
1856
+ token.invite_duration = parseInt(token.invite_duration) || token.invite_duration
1857
+ }
1858
+ })
1859
+ return result
1860
+
1846
1861
  const successExample = {
1847
1862
  success: 1,
1848
1863
  tokens: [
1849
1864
  {
1850
1865
  invite_token: 'hrcchjjm',
1851
- invite_limit: '1',
1852
- invite_duration: '2591695',
1866
+ invite_limit: 1,
1867
+ invite_duration: 2591695,
1853
1868
  time_created: 1662777551,
1854
1869
  valid: 1,
1855
- }, {
1856
- invite_token: 'kwmppbvm',
1857
- invite_limit: '1',
1858
- invite_duration: '2591702',
1859
- time_created: 1662777558,
1860
- valid: 1,
1861
- }, {
1862
- invite_token: 'vpghcgjp',
1863
- invite_limit: '1',
1864
- invite_duration: '2584709',
1865
- time_created: 1662770565,
1866
- valid: 1,
1867
1870
  }],
1868
1871
  }
1869
1872
  }
@@ -2574,10 +2577,10 @@ class SteamUser {
2574
2577
  }
2575
2578
 
2576
2579
  _parseMatchHistory(html) {
2577
- return SteamUser._parseMatchHistory(html, this._miniprofile_user)
2580
+ return SteamUser._parseMatchHistory(html)
2578
2581
  }
2579
2582
 
2580
- static _parseMatchHistory(html, myMiniProfile) {
2583
+ static _parseMatchHistory(html) {
2581
2584
  const matches = []
2582
2585
  if (!html) {
2583
2586
  return matches
@@ -2638,8 +2641,8 @@ class SteamUser {
2638
2641
  }
2639
2642
  //historyTable should be array of 11 elements
2640
2643
  const scoreboard_score = historyTable[5]['Player Name'].split(':').map(c => parseInt(c.trim()))
2641
- const ctScore = scoreboard_score[0]
2642
- const tScore = scoreboard_score[1]
2644
+ const ctScore = parseInt(scoreboard_score[0])
2645
+ const tScore = parseInt(scoreboard_score[1])
2643
2646
  const winningTeam = ctScore > tScore ? 'ct' : (ctScore < tScore ? 't' : null)
2644
2647
  const players = []
2645
2648
 
@@ -2649,10 +2652,6 @@ class SteamUser {
2649
2652
  }
2650
2653
  const player = historyTable[i]
2651
2654
  player.team = i < 5 ? 'ct' : 't'
2652
- player.isWin = winningTeam === player.team
2653
- player.isTie = winningTeam === null
2654
- player.isLose = !player.isWin && !player.isTie
2655
- player.MatchWinLose = player.isWin ? MatchWinLose.Win : (player.isTie ? MatchWinLose.Tie : MatchWinLose.Lose)
2656
2655
 
2657
2656
  for (const key of ['Ping', 'K', 'A', 'D', 'Score']) {
2658
2657
  if (!isNaN(parseInt(player[key]))) {
@@ -2680,9 +2679,8 @@ class SteamUser {
2680
2679
  name: player['Player Name'].name,
2681
2680
  link: player['Player Name'].link,
2682
2681
  customURL: player['Player Name'].customURL,
2683
- steamID: SteamUser.miniprofile2SteamID64(player['Player Name'].miniprofile),
2682
+ steamId: SteamUser.miniprofile2SteamID64(player['Player Name'].miniprofile),
2684
2683
  miniprofile: player['Player Name'].miniprofile,
2685
- isMe: player['Player Name'].miniprofile === myMiniProfile,
2686
2684
  avatarHash: player['Player Name'].avatarHash,
2687
2685
  }
2688
2686
  delete _player['Player Name']
@@ -2690,12 +2688,6 @@ class SteamUser {
2690
2688
  players.push(_player)
2691
2689
  }
2692
2690
 
2693
- const myTeam = players.find(p => p.isMe)?.team
2694
- myTeam && players.forEach(p => {
2695
- p.isTeammate = p.team === myTeam && !p.isMe
2696
- p.teamScore = p.team === 'ct' ? ctScore : tScore
2697
- })
2698
-
2699
2691
  const matchIDs = [matchInfo.map, matchInfo.time, matchInfo.duration]
2700
2692
  const nonHashMatchID = matchIDs.join('').replaceAll(/[^a-zA-Z0-9]/gi, '')
2701
2693
  const matchID = sha256(nonHashMatchID).toString()
@@ -2704,6 +2696,7 @@ class SteamUser {
2704
2696
  id: matchID,
2705
2697
  matchInfo,
2706
2698
  players,
2699
+ scoreboard: [ctScore, tScore]
2707
2700
  })
2708
2701
  })
2709
2702
 
@@ -3451,7 +3444,7 @@ class SteamUser {
3451
3444
  currentList = data.FriendsAddedLibrary
3452
3445
  }
3453
3446
  } else if (el.hasClass('profile_friends')) {
3454
- el.find('.friendBlock.persona').each(function () {
3447
+ currentList && el.find('.friendBlock.persona').each(function () {
3455
3448
  const friendBlock = $(this)
3456
3449
  const miniprofile = parseInt(friendBlock.attr('data-miniprofile'))
3457
3450
  let onlineStatus = ''
@@ -5193,13 +5186,16 @@ class SteamUser {
5193
5186
  const steamId = this.getSteamidUser()
5194
5187
 
5195
5188
  do {
5189
+ const params = {
5190
+ l: "english",
5191
+ start_assetid: result.last_assetid
5192
+ }
5193
+ const url = `inventory/${this._steamid_user}/${appID}/2?${Object.keys(params).filter(k => params[k]).map(k => `${k}=${params[k]}`).join('&')}`;
5196
5194
  for (let i = 0; i < 10; i++) {
5197
- const url = `https://steamcommunity.com/inventory/${this._steamid_user}/${appID}/2?l=english${result?.last_assetid ? `&start_assetid=${result.last_assetid}` : ''}`;
5198
5195
  const _result = (await this._httpRequest(url))?.data
5199
5196
  if (!_result) {
5200
5197
  await sleep(5000)
5201
5198
  } else if (_result.success !== 1) {
5202
- console.error(url)
5203
5199
  console.error(_result)
5204
5200
  await sleep(5000)
5205
5201
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.19",
3
+ "version": "1.3.21",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.5",