steamutils 1.0.27 → 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.
Files changed (2) hide show
  1. package/SteamClient.js +37 -3
  2. package/package.json +1 -1
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,
@@ -245,7 +247,7 @@ function SteamClient({
245
247
  const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
246
248
  const personas = await getPersonas([sid64]);
247
249
  const player_name = personas.find(p => p.id == sid64)?.player_name
248
- if(player_name === undefined){
250
+ if (player_name === undefined) {
249
251
  console.log(sid64, personas);
250
252
  }
251
253
  console.log(getAccountInfoName(), player_name, `https://steamcommunity.com/profiles/${sid64}`);
@@ -590,7 +592,7 @@ function SteamClient({
590
592
  })
591
593
  }
592
594
 
593
- async function getNewCookie(cookie){
595
+ async function getNewCookie(cookie) {
594
596
  let response = (await axios.request({
595
597
  url: 'https://store.steampowered.com/', headers: {
596
598
  cookie,
@@ -691,6 +693,37 @@ function SteamClient({
691
693
  }
692
694
  }
693
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
+
694
727
  return {
695
728
  init,
696
729
  partySearch,
@@ -724,7 +757,8 @@ function SteamClient({
724
757
  return steamClient
725
758
  },
726
759
  getAccountInfoName,
727
- getPlayersProfile
760
+ getPlayersProfile,
761
+ autoRequestFreeLicense
728
762
  }
729
763
  }
730
764
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "dependencies": {
5
5
  "axios": "^1.3.4",
6
6
  "cheerio": "^1.0.0-rc.12",