HypeLevels Posted June 11, 2022 Report Posted June 11, 2022 (edited) Hey! To avoid having to pay for a simple hour booster I decided to write my own, the issue is that the flow I am following wont work due to how errors are handled. To start off I am logging the user in and starting the games which works just fine, the issue is when a user joins a game on his own machine, LogInElsewhere is thrown and the steam connection is closed, making the playingState event not get triggered anymore. to avoid that I am listening to the error event and logging in the user again, which also won't work as I will get in a login loop that will eventually rate limit me. Another issue I had is with logging in multiple accounts, I have the accounts in JSON array format and using forEach, the expected behavior is get logged on the first and second account but what happens is that the first account gets logged in and the second one doesn't... Down below there is full code of my experiment. Any help is appreciated. const SteamUser = require('steam-user'); const inquirer = require('inquirer'); const accounts = require("./accounts.json") let promise = Promise.resolve() accounts.forEach(account => { promise = promise.then(function () { const user = new SteamUser() user.logOn({ accountName: account.username, password: account.password, rememberPassword: true }) user.on("steamGuard", function (domain, callback) { inquirer .prompt([ { name: "steamGuard", message: `Please input your steamGuard code for ${account.username}: `, type: 'input' } ]) .then((code) => { callback(code.steamGuard) }) }) user.on("playingState", function (blocked, playingApp) { if (blocked) console.log(`Started playing somewhere (blocked: ${blocked}) Awaiting until disconnect`) }) user.on("error", function (err) { console.log(`An error happened when trying to hour boost ${account.username}: ${err.message}`) }) user.on("loggedOn", function () { console.log(`Successfully logged on - ${account.username}`) user.setPersona(1) user.gamesPlayed(730) }) }) }) Edited June 11, 2022 by HypeLevels code change Quote
Dr. McKay Posted June 12, 2022 Report Posted June 12, 2022 You should probably move your gamesPlayed call to the playingState event, and only call it if blocked is false. Quote
HypeLevels Posted June 12, 2022 Author Report Posted June 12, 2022 That would simplify the code a lot, thanks! But I don’t see how that could help with handling errors, as soon as a game starts being played elsewhere my connection with steam closes and I don’t get the playingState event when the user closes the game 😕 perhaps setup some sort of from event that logs the user in each 10 minutes to check if he is done playing could work! The issue is when they have mobile steam guard, in that case remberPassword doesn’t seem to work making it prompt me for the steam guard code every time I reconnect (which isn’t nice as this is gonna run on a vps) Quote
Dr. McKay Posted June 12, 2022 Report Posted June 12, 2022 If you get an error event indicating you disconnected due to LoggedInElsewhere, just log back in. It won't cause any problems unless you try to launch a game again before you get a playingState notification indicating that you aren't blocked. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.