steamutils 1.0.26 → 1.0.28

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 CHANGED
@@ -8,6 +8,7 @@ import axios from "axios";
8
8
  import helpers from "./helpers/protos.js";
9
9
  import {fileURLToPath} from "url";
10
10
  import path from "path";
11
+ import SteamUtils from "./index.js";
11
12
 
12
13
  const __filename = fileURLToPath(import.meta.url);
13
14
  const __dirname = path.dirname(__filename);
@@ -81,6 +82,7 @@ async function GetCurrentVersion(appid) {
81
82
  }
82
83
 
83
84
  const PersonasCache = []
85
+
84
86
  function SteamClient({
85
87
  username,
86
88
  password,
@@ -92,6 +94,7 @@ function SteamClient({
92
94
 
93
95
  const events = {
94
96
  loggedOn: [],
97
+ webSession: [],
95
98
  friendMessage: [],
96
99
  friendTyping: [],
97
100
  }
@@ -222,7 +225,9 @@ function SteamClient({
222
225
  })
223
226
 
224
227
  steamClient.on('webSession', (sessionID, cookies) => {
225
- // console.log('webSession', sessionID, cookies);
228
+ const webSession = {sessionID, cookies};
229
+ steamClient.webSession = webSession
230
+ events.webSession.forEach(e => e?.(webSession))
226
231
  })
227
232
 
228
233
  steamClient.on('receivedFromGC', async (appid, msgType, payload) => {
@@ -242,7 +247,7 @@ function SteamClient({
242
247
  const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
243
248
  const personas = await getPersonas([sid64]);
244
249
  const player_name = personas.find(p => p.id == sid64)?.player_name
245
- if(player_name === undefined){
250
+ if (player_name === undefined) {
246
251
  console.log(sid64, personas);
247
252
  }
248
253
  console.log(getAccountInfoName(), player_name, `https://steamcommunity.com/profiles/${sid64}`);
@@ -587,7 +592,7 @@ function SteamClient({
587
592
  })
588
593
  }
589
594
 
590
- async function getNewCookie(cookie){
595
+ async function getNewCookie(cookie) {
591
596
  let response = (await axios.request({
592
597
  url: 'https://store.steampowered.com/', headers: {
593
598
  cookie,
@@ -688,6 +693,37 @@ function SteamClient({
688
693
  }
689
694
  }
690
695
 
696
+ async function autoRequestFreeLicense(log = false, max = 10) {
697
+ const steamUtils = new SteamUtils(cookie)
698
+
699
+ const ownedAppsCount = log ? (await steamUtils.getDynamicStoreUserData()).rgOwnedApps.length : 0
700
+ const recommendedApps = _.shuffle((await steamUtils.getDynamicStoreUserData())?.rgRecommendedApps)
701
+ if (max) {
702
+ recommendedApps.length = Math.min(recommendedApps.length, max)
703
+ }
704
+ for (const recommendedApp of recommendedApps) {
705
+ if (Math.random() > 0.5) {
706
+ try {
707
+ await steamUtils.requestFreeLicense(recommendedApp)
708
+ } catch (e) {
709
+ }
710
+ } else {
711
+ try {
712
+ await steamClient.requestFreeLicense(recommendedApp)
713
+ } catch (e) {
714
+ console.log(e);
715
+ }
716
+ }
717
+ await sleep(2000)
718
+ }
719
+ if (log) {
720
+ await sleep(20000)
721
+ const ownedAppsCount2 = (await steamUtils.getDynamicStoreUserData()).rgOwnedApps.length
722
+ const increaseNumber = ownedAppsCount2 - ownedAppsCount;
723
+ console.log(getAccountInfoName(), `OwnedApps length ${ownedAppsCount2}, increase ${increaseNumber}`)
724
+ }
725
+ }
726
+
691
727
  return {
692
728
  init,
693
729
  partySearch,
@@ -721,7 +757,8 @@ function SteamClient({
721
757
  return steamClient
722
758
  },
723
759
  getAccountInfoName,
724
- getPlayersProfile
760
+ getPlayersProfile,
761
+ autoRequestFreeLicense
725
762
  }
726
763
  }
727
764
 
package/index.js CHANGED
@@ -1059,7 +1059,7 @@ class SteamUser {
1059
1059
  params = this._formatHttpRequest(params)
1060
1060
 
1061
1061
  if(!this._cookies) {
1062
- throw new Error('You jave not set cookie yet')
1062
+ throw new Error('You have not set cookie yet')
1063
1063
  }
1064
1064
 
1065
1065
  if(params.method.toUpperCase() === 'POST') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "dependencies": {
5
5
  "axios": "^1.3.4",
6
6
  "cheerio": "^1.0.0-rc.12",