├── src ├── structures │ ├── Worker.js │ ├── Game.js │ └── Account.js ├── config │ ├── account2.js │ ├── account1.js │ └── global.js ├── idlers │ ├── gamePicker.js │ └── idlerHandler.js ├── utils │ ├── additional.js │ └── logger.js ├── outputs │ ├── terminal.js │ └── discord.js ├── index.js └── sharding │ ├── manager.js │ └── worker.js ├── package.json ├── LICENSE.md ├── .gitignore └── README.md /src/structures/Worker.js: -------------------------------------------------------------------------------- 1 | class Worker { 2 | constructor(id, config, cluster) { 3 | this.id = id; 4 | this.config = config; 5 | this.worker = cluster.workers[this.id]; 6 | } 7 | 8 | get name() { 9 | return `This is ${this.id || 'Unknown'}`; 10 | } 11 | } 12 | 13 | module.exports = Worker; 14 | -------------------------------------------------------------------------------- /src/config/account2.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | account: { 3 | username: 'username', // Steam username 4 | password: 'password', // Steam password 5 | statusInvisible: false, // If set to "true" friends won't see notification or you playing anything 6 | shared_secret: '' // Auto 2FA login 7 | } 8 | // This account is using the global config settings 9 | }; 10 | -------------------------------------------------------------------------------- /src/idlers/gamePicker.js: -------------------------------------------------------------------------------- 1 | const { selectRandomGame } = require('../utils/additional'); 2 | 3 | module.exports = (gameList, staticList, toIdle, idleLength) => { 4 | let gameToIdle = Array.isArray(staticList) ? staticList : []; 5 | while (gameToIdle.length < toIdle) { 6 | const selectedGame = selectRandomGame(gameList); 7 | if (!gameToIdle.includes(selectedGame.id)) { 8 | gameToIdle.push(selectedGame.id); 9 | selectedGame.update(idleLength); 10 | } 11 | } 12 | 13 | return gameToIdle; 14 | }; 15 | -------------------------------------------------------------------------------- /src/structures/Game.js: -------------------------------------------------------------------------------- 1 | const { changeMsToMin } = require('../utils/additional'); 2 | 3 | class Game { 4 | constructor(data) { 5 | this.id = data.appid; 6 | this.name = data.name; 7 | this.timePlayed = data.playtime_forever; 8 | 9 | this.idleCount = 0; 10 | this.idledFor = 0; 11 | } 12 | 13 | update(time) { 14 | const timeInMin = changeMsToMin(time); 15 | this.idleCount++; 16 | this.idledFor += timeInMin; 17 | this.timePlayed += timeInMin; 18 | } 19 | } 20 | 21 | module.exports = Game; 22 | -------------------------------------------------------------------------------- /src/utils/additional.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | getIdleDuration: () => { 3 | let random = Math.floor(Math.random() * 6) + 5; 4 | return (random *= 240000) + 600000; 5 | }, 6 | changeMinToMs: (min) => { 7 | return min * 60 * 1000; 8 | }, 9 | changeMsToMin: (ms) => { 10 | return ms / 1000 / 60; 11 | }, 12 | startTimeToHours: (timePassed) => { 13 | const sec = Math.floor(timePassed / 1000); 14 | const min = Math.floor(sec / 60); 15 | return (min / 60).toFixed(2); 16 | }, 17 | selectRandomGame: (gameList) => { 18 | let random = Math.floor(Math.random() * gameList.length); 19 | return gameList[random]; 20 | }, 21 | timeout: (time) => { 22 | return new Promise((resolve) => setTimeout(resolve, time)); 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /src/config/account1.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | account: { 3 | username: 'username', // Steam username 4 | password: 'password', // Steam password 5 | statusInvisible: false, // If "true" friends won't see notification or you playing anything 6 | shared_secret: '' // Auto 2FA login 7 | }, 8 | // Below settings are optional if they are supplied in the global config 9 | idlerSettings: { 10 | enabled: true, // Turn idler on or off 11 | parallelGameIdle: 32, // Amount of games playing at the same time (max is 32) 12 | idleTime: 0, // Number of min to idle for before switching games (0 means randomized number) 13 | alwaysIdleList: [], // Games that will always be idled, example: [730, 570, 440] 14 | skipBannedGames: false, // If "true" it won't idle games you're banned in (except if it's in "alwaysIdleList") 15 | skipFreeGames: false, // If "true" it won't idle free to play games (except if it's in "alwaysIdleList") 16 | blacklistGames: [] // List of games not to idle, example: [730, 570, 440] (except if it's in "alwaysIdleList") 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "steam-idler", 3 | "version": "2.1.0", 4 | "description": "This is a small steam idle bot made with steam-user.", 5 | "homepage": "https://github.com/ZixeSea/SteamIdler", 6 | "contributors": [ 7 | { 8 | "name": "ZixeSea", 9 | "url": "https://github.com/ZixeSea" 10 | }, 11 | { 12 | "name": "Danial", 13 | "url": "https://github.com/RedSparr0w" 14 | } 15 | ], 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/ZixeSea/SteamIdler.git" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/ZixeSea/SteamIdler/issues" 22 | }, 23 | "main": "./src/index.js", 24 | "scripts": { 25 | "start": "node ./src/index.js", 26 | "text": "node ./src/index.js" 27 | }, 28 | "engines": { 29 | "node": ">=14.0.0" 30 | }, 31 | "author": "ZixeSea", 32 | "license": "MIT", 33 | "dependencies": { 34 | "asciiart-logo": "^0.2.7", 35 | "colors": "^1.4.0", 36 | "console-table-printer": "^2.12.1", 37 | "steam-totp": "^2.1.2", 38 | "steam-user": "^5.2.0", 39 | "time-stamp": "^2.2.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ZixeSea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/config/global.js: -------------------------------------------------------------------------------- 1 | /* 2 | GLOBAL CONFIGURATION 3 | */ 4 | module.exports = { 5 | /* 6 | These settings are global and will affect any accounts that do not have the setting specified in their specific account config file 7 | Include any of these in the account specific config file to override these settings 8 | */ 9 | idlerSettings: { 10 | enabled: true, // Turn idler on or off 11 | parallelGameIdle: 32, // Amount of games playing at the same time (max is 32) 12 | idleTime: 0, // Number of min to idle for before switching games (0 means randomized number) 13 | alwaysIdleList: [], // Games that will always be idled, example: [730, 570, 440] 14 | skipBannedGames: false, // If "true" it won't idle games you're banned in (except if it's in "alwaysIdleList") 15 | skipFreeGames: false, // If "true" it won't idle free to play games (except if it's in "alwaysIdleList") 16 | blacklistGames: [] // List of games not to idle, example: [730, 570, 440] (except if it's in "alwaysIdleList") 17 | }, 18 | /* 19 | These settings are not account specific, but for the program itself 20 | */ 21 | discordWebhook: '' // Discord webhook to send stats to 22 | }; 23 | -------------------------------------------------------------------------------- /src/outputs/terminal.js: -------------------------------------------------------------------------------- 1 | const { Table } = require('console-table-printer'); 2 | const { startTimeToHours } = require('../utils/additional'); 3 | 4 | module.exports = (stats) => { 5 | const t1 = new Table({ 6 | title: 'List Of Running Steam Accounts | SteamIdler By ZixeSea', 7 | columns: [ 8 | { name: 'name', title: 'Username', alignment: 'left' }, 9 | { name: 'list', title: 'Games list', alignment: 'right' }, 10 | { name: 'time', title: 'Time idled', alignment: 'right' }, 11 | { name: 'games', title: 'Games idled', alignment: 'right' }, 12 | { name: 'rounds', title: 'Idle rounds', alignment: 'right' }, 13 | { name: 'status', title: 'Status', alignment: 'left' } 14 | ] 15 | }); 16 | 17 | stats.forEach((a) => { 18 | t1.addRow({ 19 | name: a.name, 20 | list: a.gamesCount, 21 | time: 22 | a.idleStartTime === NaN 23 | ? 'Unknown' 24 | : a.idleStatus !== 'Idling!' 25 | ? `${startTimeToHours(a.stoppedIdleTime)} H` 26 | : `${startTimeToHours(Date.now() - a.idleStartTime)} H`, 27 | games: a.gamesIdled, 28 | rounds: a.idleRounds, 29 | status: a.idleStatus 30 | }); 31 | }); 32 | 33 | console.clear(); 34 | t1.printTable(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/utils/logger.js: -------------------------------------------------------------------------------- 1 | const { Console } = require('console'); 2 | const colors = require('colors'); 3 | const timestamp = require('time-stamp'); 4 | 5 | const console = new Console({ 6 | stdout: process.stdout, 7 | stderr: process.stderr, 8 | colorMode: false 9 | }); 10 | 11 | colors.setTheme({ 12 | silly: 'rainbow', 13 | log: 'grey', 14 | verbose: 'cyan', 15 | prompt: 'grey', 16 | info: 'green', 17 | data: 'grey', 18 | help: 'cyan', 19 | warn: 'yellow', 20 | debug: 'cyan', 21 | error: 'red' 22 | }); 23 | 24 | class Logger { 25 | constructor() {} 26 | 27 | log(msg) { 28 | let message = colors.log(msg); 29 | console.log(`${addTime()} | ${message}`); 30 | } 31 | 32 | info(msg) { 33 | let message = colors.info(msg); 34 | console.info(`${addTime()} | ${message}`); 35 | } 36 | 37 | warn(msg) { 38 | let message = colors.warn(msg); 39 | console.warn(`${addTime()} | ${message}`); 40 | } 41 | 42 | error(msg) { 43 | let message = colors.error(msg); 44 | console.error(`${addTime()} | ${message}`); 45 | } 46 | 47 | data(msg) { 48 | let message = colors.data(msg); 49 | console.log(`${addTime()} | ${message}`); 50 | } 51 | 52 | debug(msg) { 53 | let message = colors.debug(msg); 54 | console.debug(`${addTime()} | ${message}`); 55 | } 56 | } 57 | 58 | module.exports = new Logger(); 59 | 60 | const addTime = () => { 61 | return `${timestamp(`YYYY/MM/DD HH:mm:ss`)}`; 62 | }; 63 | -------------------------------------------------------------------------------- /src/structures/Account.js: -------------------------------------------------------------------------------- 1 | const Game = require('./Game'); 2 | 3 | class Account { 4 | constructor(data) { 5 | this.name = data.name; 6 | this.gamesCount = 0; 7 | this.gameBans = []; 8 | 9 | this.games = []; 10 | 11 | this.idleRounds = 0; 12 | this.gamesIdled = 0; 13 | this.idleStartTime = NaN; 14 | this.stoppedIdleTime = NaN; 15 | this.idleStatus = data.status; 16 | this.idleMode = data.idleMode || 'None'; 17 | } 18 | 19 | update(data) { 20 | if (data.time) this.idleStartTime = data.time; 21 | if (data.status) this.idleStatus = data.status; 22 | if (data.idleMode) this.idleMode = data.idleMode; 23 | } 24 | 25 | setStoppedTime() { 26 | this.stoppedIdleTime = Date.now() - this.idleStartTime; 27 | } 28 | 29 | addRound(games) { 30 | this.idleRounds++; 31 | this.gamesIdled += games; 32 | } 33 | 34 | loadGames(gamesList, skipBannedGames, blacklistGames) { 35 | let excludeGamesList = []; 36 | if (skipBannedGames && Array.isArray(this.gameBans)) { 37 | excludeGamesList = this.gameBans; 38 | } 39 | 40 | if (Array.isArray(blacklistGames) && blacklistGames.length > 0) { 41 | excludeGamesList = [].concat(excludeGamesList, blacklistGames); 42 | } 43 | 44 | gamesList.forEach((g) => { 45 | if (!excludeGamesList.includes(g.appid)) { 46 | this.games.push(new Game(g)); 47 | } 48 | }); 49 | this.gamesCount = gamesList.length; 50 | } 51 | 52 | setBanned(gameIds) { 53 | this.gameBans = gameIds; 54 | } 55 | } 56 | 57 | module.exports = Account; 58 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const cluster = require('node:cluster'); 2 | const terminalOutput = require('./outputs/terminal'); 3 | const discordOutput = require('./outputs/discord'); 4 | const stats = new Map(); 5 | 6 | process.on('unhandledRejection', (err) => console.error(`Unhandled error: ${err.message}`, err.stack)); 7 | process.on('uncaughtException', (err) => console.error(`Uncatched error: ${err.message}`, err.stack)); 8 | 9 | if (cluster.isPrimary) { 10 | const startWorkers = async () => { 11 | const manager = await require('./sharding/manager'); 12 | for (const Worker of manager.values()) { 13 | Worker.worker.send({ name: 'login', config: Worker.config }); 14 | await new Promise((resolve, reject) => { 15 | cluster.on('message', function (worker, message) { 16 | if (worker.id === Worker.id && message.name === 'login') resolve(); 17 | if (message.name === 'stats') stats.set(worker, message.account); 18 | }); 19 | }); 20 | } 21 | 22 | // start outputs 23 | setInterval(() => { 24 | terminalOutput(stats); 25 | discordOutput(stats); 26 | }, 15000); 27 | }; 28 | 29 | const evn = require('../package.json'); 30 | const logo = require('asciiart-logo'); 31 | console.info( 32 | logo({ 33 | name: 'SteamIdler', 34 | font: 'Big', 35 | padding: 5, 36 | margin: 3 37 | }) 38 | .center('Light weight multi account steam idler') 39 | .emptyLine() 40 | .center(`Version: ${evn.version}`) 41 | .center(`Created by: ${evn.contributors[0].name}`) 42 | .render() 43 | ); 44 | 45 | startWorkers(); 46 | } else { 47 | require('./sharding/worker')(); 48 | } 49 | -------------------------------------------------------------------------------- /src/sharding/manager.js: -------------------------------------------------------------------------------- 1 | const logger = require('../utils/logger'); 2 | const cluster = require('node:cluster'); 3 | const { readdirSync } = require('node:fs'); 4 | const { join, resolve } = require('node:path'); 5 | const basePath = resolve(join(__dirname, '../')); 6 | const Worker = require('../structures/Worker'); 7 | const workers = new Map(); 8 | 9 | const reservedConfigFiles = ['global.js']; 10 | const configPath = join(basePath, '/config'); 11 | 12 | module.exports = new Promise((resolve, reject) => { 13 | // Skip any config filenames that are reserved 14 | let configList = readdirSync(configPath).filter( 15 | (file) => !reservedConfigFiles.includes(file) && file.endsWith('.js') 16 | ); 17 | 18 | // Load our global config if it exists 19 | let globalConfig = {}; 20 | try { 21 | globalConfig = require(join(configPath, 'global.js')); 22 | } catch (error) { 23 | logger.warn('Global config not found, consider creating one to apply global settings'); 24 | } 25 | 26 | for (const configFile of configList) { 27 | // Use our global config as a base and then override it with the account specific config 28 | const config = { ...globalConfig, ...require(join(configPath, configFile)) }; 29 | const worker = cluster.fork(); 30 | 31 | worker.once('online', async () => { 32 | logger.info(`Worker ${worker.id} for ${config.account.username} has been started`); 33 | workers.set(worker.id, new Worker(worker.id, config, cluster)); 34 | }); 35 | 36 | worker.on('disconnect', () => { 37 | logger.error(`Worker ${worker.id} for ${config.account.username} has died, stopped idling`); 38 | }); 39 | } 40 | 41 | const upChecker = setInterval(() => { 42 | if (configList.length === workers.size) { 43 | clearInterval(upChecker); 44 | resolve(workers); 45 | } 46 | }, 2500); 47 | }); 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | package-lock.json 106 | 107 | # Avoid uploading new config files 108 | config/ 109 | -------------------------------------------------------------------------------- /src/outputs/discord.js: -------------------------------------------------------------------------------- 1 | let discordWebhook; 2 | let discordMessageID = null; 3 | try { 4 | discordWebhook = require('../config/global').discordWebhook; 5 | } catch (e) { 6 | discordWebhook = null; 7 | } 8 | const discordColors = { 9 | online: parseInt('2ecc71', 16), 10 | offline: parseInt('95a5a6', 16), 11 | error: parseInt('e74c3c', 16) 12 | }; 13 | 14 | module.exports = (stats) => { 15 | // If none specified, return 16 | if (!discordWebhook) return; 17 | 18 | // Create our embeds 19 | output = { 20 | username: 'Steam Idler', 21 | embeds: [] 22 | }; 23 | stats.forEach((a) => { 24 | output.embeds.push({ 25 | // TODO: generate color based on status 26 | color: a.idleStatus !== 'Idling!' ? discordColors.error : discordColors.online, 27 | author: { 28 | name: a.displayName ?? a.name, 29 | url: `https://steamcommunity.com/profiles/${a.steamID}`, 30 | icon_url: a.avatar 31 | }, 32 | fields: [ 33 | { name: 'Status', value: a.idleStatus, inline: true }, 34 | { name: 'Games list', value: a.gamesCount, inline: true }, 35 | { name: 'Games idled', value: a.gamesIdled, inline: true }, 36 | { 37 | name: a.idleStatus !== 'Idling!' ? 'Idle stopped' : 'Idle started', 38 | value: 39 | a.idleStartTime === NaN 40 | ? 'Unknown' 41 | : a.idleStatus !== 'Idling!' 42 | ? `` 43 | : ``, 44 | inline: true 45 | }, 46 | { name: 'Idle mode', value: a.idleMode, inline: true }, 47 | { name: 'Idle rounds', value: a.idleRounds, inline: true } 48 | ], 49 | footer: { 50 | text: 'Last updated' 51 | }, 52 | timestamp: new Date().toISOString() 53 | }); 54 | }); 55 | 56 | // Send our request 57 | const uri = discordWebhook + (discordMessageID ? `/messages/${discordMessageID}` : '') + '?wait=true'; 58 | fetch(uri, { 59 | method: discordMessageID ? 'PATCH' : 'POST', 60 | body: JSON.stringify(output), 61 | headers: { 62 | 'Content-type': 'application/json; charset=UTF-8' 63 | } 64 | }) 65 | .then((response) => { 66 | return response.json(); 67 | }) 68 | .then((json) => { 69 | discordMessageID = json.id ?? discordMessageID; 70 | }) 71 | .catch((error) => { 72 | console.log(error); 73 | }); 74 | }; 75 | -------------------------------------------------------------------------------- /src/idlers/idlerHandler.js: -------------------------------------------------------------------------------- 1 | const gamePicker = require('./gamePicker'); 2 | const { getIdleDuration, changeMinToMs } = require('../utils/additional'); 3 | let gameSwitcher; 4 | 5 | const loadIdler = async (account, client, config) => { 6 | if (account.games.length < 1) { 7 | const gameListToIdle = await client.getUserOwnedApps(client.steamID, { 8 | includePlayedFreeGames: !config.idlerSettings.skipFreeGames 9 | }); 10 | account.loadGames(gameListToIdle.apps, config.idlerSettings.skipBannedGames, config.idlerSettings.blacklistGames); 11 | } 12 | 13 | startIdler(account, client, config); 14 | }; 15 | 16 | const startIdler = (account, client, config) => { 17 | if (config.idlerSettings.alwaysIdleList.length === config.idlerSettings.parallelGameIdle) { 18 | account.update({ time: Date.now(), status: 'Idling!', idleMode: 'Static' }); 19 | account.addRound(config.idlerSettings.alwaysIdleList.length); 20 | return client.gamesPlayed(config.idlerSettings.alwaysIdleList); 21 | } 22 | 23 | if (account.games.length <= config.idlerSettings.parallelGameIdle) { 24 | let listToIdle = []; 25 | account.games.forEach((g) => { 26 | listToIdle.push(g.id); 27 | }); 28 | 29 | account.update({ time: Date.now(), status: 'Idling!', idleMode: 'Static' }); 30 | account.addRound(listToIdle.length); 31 | return client.gamesPlayed(listToIdle); 32 | } 33 | 34 | startDynamicIdler(account, client, config); 35 | }; 36 | 37 | const startDynamicIdler = (account, client, config) => { 38 | const idleLength = 39 | config.idlerSettings.idleTime !== 0 ? changeMinToMs(config.idlerSettings.idleTime) : getIdleDuration(); 40 | const listToIdle = gamePicker( 41 | account.games, 42 | config.idlerSettings.alwaysIdleList, 43 | config.idlerSettings.parallelGameIdle, 44 | idleLength 45 | ); 46 | 47 | if (account.idleStatus !== 'Idling!') account.update({ time: Date.now(), status: 'Idling!' }); 48 | account.addRound(listToIdle.length); 49 | client.gamesPlayed(listToIdle); 50 | 51 | gameSwitcher = setTimeout(() => { 52 | startDynamicIdler(account, client, config); 53 | }, idleLength); 54 | }; 55 | 56 | const stopIdler = (account) => { 57 | account.setStoppedTime(); 58 | account.update({ status: 'Idle stopped', idleMode: 'None' }); 59 | clearTimeout(gameSwitcher); 60 | }; 61 | 62 | module.exports = { 63 | load: (account, client, config) => loadIdler(account, client, config), 64 | start: (account, client, config) => startIdler(account, client, config), 65 | stop: (account) => stopIdler(account) 66 | }; 67 | -------------------------------------------------------------------------------- /src/sharding/worker.js: -------------------------------------------------------------------------------- 1 | const logger = require('../utils/logger'); 2 | const SteamUser = require('steam-user'); 3 | const SteamTotp = require('steam-totp'); 4 | const Account = require('../structures/Account'); 5 | const client = new SteamUser({ renewRefreshTokens: true }); 6 | 7 | const { join, resolve } = require('node:path'); 8 | const basePath = resolve(join(__dirname, '../')); 9 | const configPath = join(basePath, '/config'); 10 | const { readFileSync, writeFileSync } = require('fs'); 11 | 12 | let idler; 13 | let statsPusher; 14 | let config = null; 15 | let account = null; 16 | 17 | module.exports = () => { 18 | process.on('message', function (message) { 19 | switch (message.name) { 20 | case 'login': 21 | config = message.config; 22 | account = new Account({ name: config.account.username, status: 'Preparing' }); 23 | process.send({ name: 'stats', account }); 24 | 25 | let logOnOptions = {}; 26 | try { 27 | const refreshToken = readFileSync(`${configPath}/${message.config.account.username}.txt`) 28 | .toString('utf8') 29 | .trim(); 30 | logOnOptions = { 31 | refreshToken, 32 | machineName: 'SteamIdler' 33 | }; 34 | } catch (errpr) { 35 | // The error doesn't matter, normal login callback 36 | logOnOptions = { 37 | accountName: message.config.account.username, 38 | password: message.config.account.password, 39 | machineName: 'SteamIdler', 40 | twoFactorCode: message.config.account.shared_secret 41 | ? SteamTotp.generateAuthCode(message.config.account.shared_secret) 42 | : undefined 43 | }; 44 | } 45 | 46 | client.logOn(logOnOptions); 47 | break; 48 | } 49 | }); 50 | 51 | client.on('loggedOn', async () => { 52 | logger.info(`Logged on to ${account.name}, preparing to idle`); 53 | account.steamID = client.steamID.getSteamID64(); 54 | const persona = (await client.getPersonas([account.steamID]))?.personas?.[account.steamID]; 55 | account.displayName = persona?.player_name || account.name; 56 | account.avatar = 57 | persona?.avatar_url_medium || 58 | 'https://avatars.cloudflare.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_medium.jpg'; 59 | await setTimeout(() => { 60 | return process.send({ name: 'login' }); 61 | }, 5000); 62 | client.setPersona( 63 | config.account.statusInvisible ? SteamUser.EPersonaState.Invisible : SteamUser.EPersonaState.Online 64 | ); 65 | 66 | if (!config.idlerSettings.enabled) { 67 | account.update({ status: 'Not idling', idleMode: 'None' }); 68 | process.send({ name: 'stats', account }); 69 | return logger.warn(`Idler is turned off for ${account.name}, it will be online without idling`); 70 | } 71 | 72 | if (config.idlerSettings.parallelGameIdle < 1) { 73 | logger.warn(`Changed parallelGameIdle to 1 for ${account.name}, original input was incorrect`); 74 | config.idlerSettings.parallelGameIdle = 1; 75 | } 76 | 77 | if (config.idlerSettings.parallelGameIdle > 32) { 78 | logger.warn(`Changed parallelGameIdle to 32 for ${account.name}, original input was incorrect`); 79 | config.idlerSettings.parallelGameIdle = 32; 80 | } 81 | 82 | if (config.idlerSettings.idleTime < 5 && config.idlerSettings.idleTime !== 0) { 83 | logger.warn(`Changed idleTime to 5 for ${account.name}, original input was too low`); 84 | config.idlerSettings.idleTime = 5; 85 | } 86 | 87 | if (config.idlerSettings.alwaysIdleList.length > 32) { 88 | logger.warn(`Removed overflowing games for ${account.name}, alwaysIdleList can't be more than 32 games`); 89 | config.idlerSettings.alwaysIdleList = config.idlerSettings.alwaysIdleList.slice(0, 32); 90 | } 91 | 92 | if (config.idlerSettings.alwaysIdleList.length > config.idlerSettings.parallelGameIdle) { 93 | logger.warn( 94 | `Changed parallelGameIdle to ${config.idlerSettings.alwaysIdleList.length} for ${account.name}, more games were listed in alwaysIdleList` 95 | ); 96 | config.idlerSettings.parallelGameIdle = config.idlerSettings.alwaysIdleList.length; 97 | } 98 | 99 | account.update({ idleMode: 'Dynamic' }); // Defaults to dynamic 100 | idler = require('../idlers/idlerHandler'); 101 | idler.load(account, client, config); 102 | 103 | process.send({ name: 'stats', account }); 104 | statsPusher = setInterval(() => { 105 | return process.send({ name: 'stats', account }); 106 | }, 20000); 107 | 108 | return logger.info(`The idler will now be started for ${account.name}`); 109 | }); 110 | 111 | client.on('vacBans', (bans, gameIds) => { 112 | account.setBanned(gameIds); 113 | logger.info( 114 | bans === 0 115 | ? `${account.name} doesn't have any game/vac bans` 116 | : `${account.name} has ${bans} game/vac ban(s) [${gameIds.join(', ')}]` 117 | ); 118 | }); 119 | 120 | client.on('refreshToken', (token) => { 121 | writeFileSync(`${configPath}/${config.account.username}.txt`, token); 122 | logger.info(`Got new refresh token for ${account.name}`); 123 | }); 124 | 125 | client.on('disconnected', (result, msg) => { 126 | if (idler) idler.stop(account); 127 | setTimeout(() => { 128 | clearInterval(statsPusher); 129 | }, 11000); 130 | account.update({ status: 'Disconnected' }); 131 | logger.error(`${account.name} has disconnected, with reason: ${msg}`); 132 | }); 133 | 134 | client.on('error', (err) => { 135 | if (idler) idler.stop(account); 136 | setTimeout(() => { 137 | clearInterval(statsPusher); 138 | }, 11000); 139 | if (err.message.includes('LoggedInElsewhere')) { 140 | account.update({ status: 'Session taken' }); 141 | return logger.error(`Session from ${account.name} got taken from another location`); 142 | } 143 | 144 | account.update({ status: 'Steam error' }); 145 | logger.error(`Steam error for ${account.name}: ${err.message}`); 146 | }); 147 | }; 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | STEAMIDLER V2 3 |

4 |

5 | Light weight multi account steam idler 6 |

7 |

8 | 9 | Discord sercver 10 | 11 | 12 | Steam user badge 13 | 14 | 15 | Version Badge 16 | 17 | 18 | Version Badge 19 | 20 |

21 | 22 | ## Contributors 23 | 24 | - **ZixeSea** - github: [ZixeSea](https://github.com/ZixeSea) 25 | - **Danial** - github: [RedSparr0w](https://github.com/RedSparr0w) 26 | 27 | ## The project 28 | 29 | This project has been created in _2019_ for me to easily run a **steam idler 24/7** in the background while using **almost no resources**. this project has been reworked in _2022_ adding a lot of new options like the "**staticIdler**" and "**dynamicIdler**" idlers. The only thing that was missing was **multi account support**. This has been added in the rewrite from _2023_ and now known as SteamIdler V2. 30 | 31 | ## Requirements 32 | 33 | - `git` command line ([Windows](https://git-scm.com/download/win)|[Linux](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)|[MacOS](https://git-scm.com/download/mac)) installed 34 | - `node` version 14.0.0 or higher ([get here](https://nodejs.org)) 35 | 36 | > If you have 2AF on for you steam account, you need to provide it while the program is starting. A message will appear about it. 37 | 38 | ## Download code 39 | 40 | Run the following command in a CMD/terminal at the location where you want to download it: 41 | 42 | ``` 43 | git clone https://github.com/ZixeSea/SteamIdler.git 44 | ``` 45 | 46 | > Remember to go in to the config folder and chnage/add a config file (for example: **`src/config/account1.js`**). The name of the config file doesn't matter but every account should have it's own config file. 47 | 48 | ## Dependencies 49 | 50 | - [steam-user](https://www.npmjs.com/package/steam-user) - Used to interface with Steam. 51 | - [asciiart-logo](https://www.npmjs.com/package/asciiart-logo) - Used to create a splash screen in the console. 52 | - [colors](https://www.npmjs.com/package/colors) - Used to color and style console output. 53 | - [console-table-printer](https://www.npmjs.com/package/console-table-printer) - Used to create a table in the console. 54 | - [time-stamp](https://www.npmjs.com/package/time-stamp) - Used to format timestamps. 55 | - [steam-totp](https://github.com/DoctorMcKay/node-steam-totp) - Used to generate Steam auth codes. 56 | 57 | ## License 58 | 59 | This project is licensed under the MIT License - see the [LICENSE](https://github.com/ZixeSea/SteamIdler/blob/master/LICENSE.md) file for details (deleting and/or modifying the license file after forking isn't allowed). 60 | 61 | --- 62 | 63 | # Table of contents 64 | 65 | 1. **[Prepare linux](#prepare-linux)** 66 | 1.1 [Update server](#update-server) 67 | 1.2 [Install node.js](#install-nodejs) 68 | 2. **[Prepare windows](#prepare-windows)** 69 | 2.1 [Get node.js](#get-nodejs) 70 | 3. **[Account config](#account-config)** 71 | 3.1 [Information](#information) 72 | 3.2 [Add config](#add-config) 73 | 4. **[Run idler](#run-idler)** 74 | 4.1 [Install dependencies](#install-dependencies) 75 | 4.2 [Start program](#start-program) 76 | 77 | --- 78 | 79 | # Prepare linux 80 | 81 | > Everything in this section is based on a host system running **Ubuntu 18.04/20.04/22.04**. Most if not all information can be used for other versions of Ubuntu (or dabian based distro's) as well, but it may require slight changes. 82 | 83 | ## Update server 84 | 85 | ``` 86 | sudo apt update && sudo apt upgrade -y 87 | ``` 88 | 89 | ## Install node.js 90 | 91 | ``` 92 | curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - 93 | sudo apt install -y nodejs 94 | 95 | sudo npm i npm@9.6.1 -g 96 | ``` 97 | 98 | > The versions mentioned above can be outdated, always check [(this page)](https://nodejs.org/en/) for the most recent LTS version of node.js and check [(this page)](https://github.com/npm/cli/tags) for the most recent version of NPM. Installing outdated versions can create problems or security risks. 99 | 100 | --- 101 | 102 | # Prepare windows 103 | 104 | > Everything in this section is based on a host system running **Windows 10/11**. Most if not all information can be used for other versions of Windows as well, but it may require slight changes. 105 | 106 | ## Get node.js 107 | 108 | Installing **Node.js** on windows is really easy, they have an installer for it and you can download it on their website (so it's simply clicking "next" and "ok"). 109 | 110 | **Download link:** https://nodejs.org/en 111 | 112 | --- 113 | 114 | # Account config 115 | 116 | ## Information 117 | 118 | You can find the config file(s) in the config folder (`src/config`), every account that should idle also needs it's own config file. The name of the config file doesn't matter. 119 | 120 | **- account (REQUIRED)**
121 | `username` | String | The username from the steam account
122 | `username` | String | The username from the steam account
123 | `statusInvisible` | Boolean | If "true" friends won't see notification or you playing anything
124 | `shared_secret` | String | Auto 2FA login
125 | 126 | **- idlerSettings**
127 | `enabled` | Boolean | Turn idler on or off
128 | `parallelGameIdle` | Number | Amount of games playing at the same time (max is 32)
129 | `idleTime` | Number | Number of min to idle for before switching games (0 means randomized number)
130 | `alwaysIdleList` | Array | Games that will always be idled, example: [730, 570, 440]
131 | `skipBannedGames` | Boolean | If "true" it won't idle games you're banned in (except if it's in "alwaysIdleList")
132 | `skipFreeGames` | Boolean | If "true" it won't idle free to play games (except if it's in "alwaysIdleList")
133 | `blacklistGames` | Array | List of games not to idle, example: [730, 570, 440] (except if it's in "alwaysIdleList")
134 | 135 | ## Add config 136 | 137 | If you want to add another account, created a new **.js** file (name doesn't matter) in the config folder (`src/config`) and copy this in the file. Don't forget the add the necessary account information and settings. 138 | 139 | ``` 140 | module.exports = { 141 | account: { 142 | username: 'username', 143 | password: 'password', 144 | statusInvisible: false, 145 | shared_secret: '' 146 | }, 147 | idlerSettings: { 148 | enabled: true, 149 | parallelGameIdle: 32, 150 | idleTime: 0, 151 | alwaysIdleList: [], 152 | skipBannedGames: false, 153 | skipFreeGames: false, 154 | blacklistGames: [] 155 | } 156 | }; 157 | ``` 158 | 159 | --- 160 | 161 | # Run idler 162 | 163 | ## Install dependencies 164 | 165 | The program needs to get the required dependencies to work (see [dependencies](#dependencies)), you do this with the command below. Keep in mind that you need to run this in the folder `SteamIdler` in a CMD/terminal. 166 | 167 | ``` 168 | npm i 169 | ``` 170 | 171 | ## Start program 172 | 173 | Starting/running the program is the same for linux and windows, you can use the default node.js start command listed here. Keep in mind that you need to run this in the folder `SteamIdler` in a CMD/terminal. 174 | 175 | ``` 176 | node . 177 | ``` 178 | 179 | --- 180 | --------------------------------------------------------------------------------