Skip to content

Instantly share code, notes, and snippets.

@quer
Last active June 16, 2022 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quer/9465780e03540ec7016b5745e40d177a to your computer and use it in GitHub Desktop.
Save quer/9465780e03540ec7016b5745e40d177a to your computer and use it in GitHub Desktop.
NodeJS steam Next fest - run all demo's on a account, will run 50 each hour. to sat in the limit, off "requestFreeLicense", just "npm i steam" and "npm i team-totp"
const Steam = require('steam');
const SteamTotp = require('steam-totp');
var fs = require('fs');
var steamClient = new Steam.SteamClient(),
steamUser = new Steam.SteamUser(steamClient),
steamFriends = new Steam.SteamFriends(steamClient);
steamClient.connect();
steamClient.on('connected', function() {
console.log("Connected to Steam.");
steamUser.logOn({
account_name: "xxx",
password: "xxx",
two_factor_code: "xxxx"
});
});
steamClient.on('logOnResponse', function onSteamLogOn(logonResp) {
//logger.log("logOnResponse");
log("logOnResponse" + logonResp.eresult);
if (logonResp.eresult == Steam.EResult.OK) {
log("logOnResponse OK");
steamFriends.setPersonaState(Steam.EPersonaState.Busy);
action();
}
});
steamClient.on('loggedOff', function onSteamLogOff(eresult) {
log("Logged off from Steam.");
});
steamClient.on('error', function onSteamError(error) {
log("Connection closed by server - " + error);
//steamClient.connect();
});
var runAtOnce = 50; // the max that can be active.
var offset = 0;
var currentPlace = offset;
var minBeforeStart = 0;
async function action() {
await timeout(minBeforeStart * 60000) // 1 min
var demoAppIdList = fs.readFileSync(__dirname+'/appList.txt', {encoding:'utf8', flag:'r'});
demoAppIdList = demoAppIdList.split("\n")
var demoAppblackList = fs.readFileSync(__dirname+'/blackList.txt', {encoding:'utf8', flag:'r'});
demoAppblackList = demoAppblackList.split("\n")
for (var i = demoAppIdList.length - 1; i >= 0; i--) {
const demoAppId = demoAppIdList[i];
if(demoAppblackList.indexOf(demoAppId) != -1){
demoAppIdList.splice(i, 1);
}
}
console.log(demoAppIdList);
var clustedeList = [];
var leftOff = demoAppIdList.length;
//build cluster
while (leftOff > 0) {
var subCluster = [];
var cluster = [];
for (let i = 0; i < runAtOnce; i++) {
if(demoAppIdList.length > 0){
if(cluster.length >= 30){
subCluster.push(cluster);
cluster = [];
}
var appidString = demoAppIdList.shift();
var appid = parseInt(appidString.trim(), 10);
cluster.push({"game_id": appid });
}else{
leftOff = 0;
}
}
subCluster.push(cluster);
leftOff -= runAtOnce;
clustedeList.push(subCluster);
}
//run
for (let i = 0; i < clustedeList.length; i++) {
const subCluster = clustedeList[i];
var aktivated = 0;
for (let ii = 0; ii < subCluster.length; ii++) {
for (let iii = 0; iii < subCluster[ii].length; iii++) {
const appItem = subCluster[ii][iii];
//will activate the missing games, to the user
steamUser.requestFreeLicense(appItem["game_id"]);
aktivated += 1;
currentPlace += 1;
}
}
log("aktivate: " + aktivated + " ")
for (let ii = 0; ii < subCluster.length; ii++) {
const cluster = subCluster[ii];
log((i + 1) +"/" + clustedeList.length + " ("+(ii + 1)+"/"+ subCluster.length +") running games : " + cluster.length);
await RunCluseredGames(cluster);
}
log('New offset Value: ' + currentPlace)
await timeoutLoop()
}
}
function timeoutLoop() {
return new Promise( async function (resolve) {
for (let i = 0; i < 14; i++) { // 70 min
log((i + 1) +"/14");
await timeout(300000) // 10 min
}
resolve();
});
}
function timeout(time) {
return new Promise(function (resolve) {
setTimeout(() => {
resolve();
}, time );
});
}
function RunCluseredGames(list) {
return new Promise(function (resolve) {
steamUser.gamesPlayed(list);
setTimeout(() => {
steamUser.gamesPlayed([]);
resolve();
}, 2000 );
});
}
/**
* Request licenses for one or more free-on-demand apps.
* @param {int[]} appIDs
*/
Steam.SteamUser.prototype.requestFreeLicense = function(appIDs) {
if (!Array.isArray(appIDs)) {
appIDs = [appIDs];
}
this._client.send({
msg: Steam.EMsg.ClientRequestFreeLicense,
proto: {}
}, new Steam.Internal.CMsgClientRequestFreeLicense({"appids": appIDs}).toBuffer());
};
function log(data) {
data = '[' + new Date().toUTCString() + '] ' + data;
console.log(data);
}
1974450
1961360
1961470
1985330
1658690
1966350
1919890
1650980
1805630
1966250
1714870
2020320
1771080
1913910
1923740
1970100
1960420
1997350
1952610
1400500
2000330
2011930
1952410
2001950
1992330
1960410
2020580
1591770
1642370
1987090
2008340
1326050
2020890
1313080
1405680
1325100
1642410
1210600
2023830
2013570
1431000
1995770
1277620
1976150
1418500
2001550
1993130
1960690
2000660
1986220
1990970
2009590
1658790
1602790
1588800
2018970
1704580
1875010
2004920
1938570
2052850
2018590
1926580
1879930
2020940
1657300
1661050
1402040
1478280
1999410
1662780
1402220
1652820
1935700
1975870
1490520
1951270
1967600
1992900
1442330
1661660
1961350
1952700
1288880
2014290
2019780
2051430
1798960
1915570
1940810
1947770
2008690
1881400
1775280
1977180
1979870
2052470
2010430
1978530
2018090
1990120
1299640
1689380
1669540
1546700
1414880
1628320
2001600
1514800
1454210
1982770
1931450
1310220
1655240
1699150
1622620
1310960
2023700
1205280
1316320
1979010
2016860
1445330
1962250
2020240
1313440
1761410
1595680
1983040
1986260
2004000
1954120
1666350
2019930
2020060
1606070
1659660
2017180
1629540
2015350
2022870
1768290
1852270
1998210
2051550
1711660
1306960
2052620
1325440
1536450
2013490
1519460
2006880
2005620
1934170
1666060
1966320
1982580
1985480
1608030
1410630
1660730
1289930
1891910
1958450
1532890
1995150
1658130
1535020
1598420
1538690
2000620
1823240
1765110
1544800
1660720
1651040
1728930
1601490
2022840
2023750
1977400
1992690
1999580
1947520
1768750
2002490
1856960
1953160
1971550
1991560
1644470
1960130
2053500
1304570
2017070
1328020
1427500
1501430
2001820
1363220
1489260
1609400
1997180
1326350
2019600
2055950
1408270
2012150
2013840
2001540
1949830
2054490
2023470
2015730
2017810
1996400
1812190
2014640
2010590
1971060
2051980
2021420
2018400
2053420
1792420
1835130
1865190
1967720
2052330
2024960
1960750
2021470
1933200
1982710
1955460
2006850
1980210
2004350
1986140
1521350
1402240
1587270
1663350
1989400
1993040
1983810
1619020
1217700
1983310
1914930
1316620
1320210
2003890
1776770
2012110
2019480
2024250
1968370
2011280
2015970
1066560
2009050
1728990
1935390
1193480
2018650
2022940
1648710
1642240
2017310
2018890
1703590
2012870
1999420
2006100
1991740
1999640
1976010
1750730
1866550
1799540
2021020
1953290
2020370
1864920
1942800
1908910
1970810
1623800
1673170
1566760
1668900
1402730
1401770
1538560
1542940
1488520
1746360
1429120
1164900
1845990
2018680
2018150
1978310
1982890
1995020
1269380
1997000
1568140
1316940
1443140
2020820
1935270
1980110
1937760
1957470
1971030
1974430
2015800
2024180
1578510
1970390
1947590
1961070
2022730
2052500
1972530
2012230
1988180
1964660
1984780
1995860
2013410
2020050
2017240
1913390
1933120
1996150
1298290
1540750
1381540
1907530
1915640
832440
1960940
2018750
1950100
1961900
1772290
1079080
1839720
1435490
2008520
1920350
1423850
1657370
2010190
1960390
2057050
1978270
1904110
1935010
2026780
1819910
1732200
1797920
1794080
1988450
1985280
1979250
2019430
1953480
2004560
2005840
1963380
2017710
2003780
1977020
1843210
2001450
1890150
1891200
1951770
1990640
1918910
2008190
2008660
1732040
2052930
1509490
2004310
2020720
2024200
1994580
1702520
2051610
1317520
1631550
2020900
1956080
2015590
1444960
1412920
1544870
1588990
1325810
2008970
1566650
2007090
1728790
1730200
2016870
2020760
1668370
1723670
1979780
1924750
2027770
2004150
1950260
2013260
2017280
1952070
2012810
2013930
2014730
1948610
2009060
2012980
1997100
2003290
2003980
2027990
2017390
1788550
1768760
1795590
2019030
1618670
1665410
1589960
1996110
1923260
2004470
1957290
1835900
2023660
1956540
2027980
1842420
1964160
2006980
2006780
1894180
1928170
1972430
2006240
1993020
2016930
1773610
1962300
1965500
1994340
1902000
1779140
1652590
1535890
1659850
1177570
1475720
1868690
2014250
1907160
1936340
2024060
2022320
1982400
2051860
2023870
1440000
1974140
1949070
1943320
1910640
2020440
1975880
2052980
1980970
670530
1992910
2015290
1964730
2027950
1973480
2021810
2053720
1591790
1574520
1897620
2017650
1926150
2021490
2025400
1796730
1893610
1923980
1799640
1976560
1970130
1867220
1992720
2020230
2017250
1989550
1892480
1987430
1978770
1907840
1909110
1408750
1862510
1542830
1440660
1399330
1654650
1937870
2019150
1952830
1964170
1914860
2019500
1948710
1318330
2015570
1941560
2012130
1999340
1952940
2008150
1994150
2020600
1996170
1660650
1652790
1643110
1950740
1898230
1823960
2013100
2018880
1984700
1891730
1987850
1995140
2050410
1990150
1988840
1989590
1985890
2013960
2021160
2027800
1861790
1963820
690230
1315790
1525340
1961700
1971860
1666580
2057530
1597380
1624650
1652470
2020300
1996480
1958030
2026680
1899510
1952660
1775910
1757070
1946500
2011050
1943100
1921420
2011380
1932930
1888400
1949530
1849180
1997760
1857820
2026200
1960960
2019900
1921410
1298810
1794260
2000080
2002910
1988220
1955430
1948320
2018800
2025430
2017470
2018200
1964910
2002960
2001490
1986110
2056660
2012860
2007340
2000410
1658380
2015980
1494880
1597620
1991730
2002750
2055340
2005940
1887210
1670400
1617810
1969090
2003480
2051950
1993250
2024000
2019450
1814760
2009710
2012480
2013560
1994250
2009810
1982780
1866940
1976340
1888250
1966760
1915390
1318900
1954700
1617250
2055520
2025940
2010090
1999440
2050500
1954730
1963100
1952600
1964550
2020290
2003120
1983440
1965810
2024540
1956010
1891050
1964390
1919660
1965510
2014710
1779820
1821240
2056140
1939030
1664330
1955660
2019890
1835300
2025010
1969270
1973340
1975200
2022240
1982570
1849030
1913340
2021450
1954140
2016920
1999480
2022430
2011660
2020740
1443860
1524600
1479410
1821470
1962340
2018470
2006150
1972700
2013980
2051260
1956870
2051810
1990950
1984280
2023410
1657940
2003720
2027080
1953260
2018390
1978120
2023040
1911480
1878860
1928720
1917250
1924260
1980370
1968090
2021400
1969580
2054550
1895510
2008540
1976790
1985730
1866520
1806390
1935650
1789610
1973120
1898800
2024020
1962620
2020200
2027020
697990
2013200
2018690
1988480
2054840
1945830
1936910
1999200
2052400
2052800
2055250
2018290
1840930
1970990
1516740
2016520
1877740
1910940
2013810
1871040
1989810
2026610
1956150
2021920
1942090
2022720
1981280
1947840
1959590
1965080
2053180
2053150
2025350
2056350
1996560
2020360
1647340
1925260
2009680
2001100
2022200
1988160
2001740
1935260
2015870
1984500
1893160
1972620
1960370
2050240
1967080
1996120
2026110
2008140
1596960
1949450
1978600
1539230
2007330
1969450
1946920
2004690
2013470
1846110
2051930
1979840
2056950
2011680
1977860
2012060
1963650
2026210
1951570
1997600
2027320
2022580
1969540
2026360
2020250
1979710
1975740
1790660
1868660
2055080
2057390
1977820
2015920
2006590
1948070
1997720
1911210
1975250
2020390
2003850
2011390
1958840
2053780
1901080
1975630
1871320
1977080
1969290
1898510
2012400
1929920
2010230
2014190
2010810
1954220
2055610
1987930
2015400
1976370
2017690
2009660
1966050
2059950
1858800
2020970
1936870
1990170
1958110
2027900
2054210
2018770
2013940
1993500
1897390
1971040
1979750
1913650
2000640
1904340
2013310
2053430
2027500
1542320
2026320
1964710
1946000
1970880
1970190
2057160
1807180
2005200
1903010
2012350
2020140
1956450
1870820
1969660
1891180
2055040
2053120
1859440
2026620
2050880
1977210
1983030
2023290
2017320
2055640
1988230
2012640
1975130
2016360
2025690
1806990
1966710
2014700
1932620
1900840
1998480
1996950
1920590
1973520
1986050
1952110
984700
2020280
1345460
1644570
2022660
1968900
2023570
1920220
1966510
1590350
1984100
2018180
2002040
2009870
1956900
2023100
2011090
1899860
1997820
2016630
1946800
2026220
2001390
1980960
2018710
1968070
2054630
1728070
1977650
2009910
1990750
2051800
1932090
2019120
1943900
1966790
1980640
1963770
2021890
2021150
2018630
1996960
2018620
1998080
2022340
1999690
2003250
1989830
2014450
1996860
1963700
1947830
1950010
1959320
2020620
2053550
1958480
1957950
2053480
1951360
1921800
1987180
2057480
2027640
1917690
2020410
1981150
1947760
1966990
2024850
2016150
1977790
2050610
1979770
1916030
1988420
2026600
1948270
1949430
2016340
2018170
1995200
2058080
2051070
2052440
2005450
2060030
2054960
1972210
1958080
2027620
1959270
1995610
1986090
1957050
1932510
1923370
1887390
2057140
2013450
2003820
1296380
1987740
1962830
1956970
1981990
1993690
1967730
2020350
1962280
1835990
1840680
1978410
1984970
2020810
1866270
1946910
1660830
2055900
1418080
1647370
1974180
1956780
868840
1894620
1447450
2015150
1949060
2011450
2051790
1046810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment