Jump to content
McKay Development

Recommended Posts

I am having issues with making an auto-restart function.. I want to have it so it idles until I start playing steam games, and then continues afterwards.

I haven't been able to find anything related to this, hope you guys can help :)

 

This is my code:

console.log('Script was loaded successfully.');

const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const appid = require('appid');
const config = require('./config');

const client = new SteamUser();

console.log('Node.js packages were loaded successfully.');

const games = [4000];

console.log('game-choices were loaded successfully.');

const logInOptions = {
	accountName: config.username,
	password: config.password,
	twoFactorCode: SteamTotp.generateAuthCode(config.shared_secret)
};

console.log('credentials were loaded');

client.logOn(logInOptions);

function checkForPlaying() {
	client.gamesPlayed(games);
	client.on('playingState', function(blocked, playingApp) {
		console.log(blocked);
		if (blocked == true) {
			setTimeout(checkForPlaying, 5000);
		} else if (blocked == false) {
			client.setPersona(SteamUser.EPersonaState.Offline);
			client.gamesPlayed(games);
		}
	});
}

client.on('loggedOn', () => {
	client.setPersona(SteamUser.EPersonaState.Offline);
	client.gamesPlayed(games);
	console.log(' \n Logged on accoung: ' + config.username);
});

client.on('error', function(err) {
	if (err.eresult == '6') {
		console.log('ERROR');
		checkForPlaying();
	}
});

I would REALLY appreciate if you can help me, I have been trying for days now. This is my last hope :(

Edited by FuTTiiZ

Share this post


Link to post
Share on other sites

When error is emitted, that means you're logged off. You'll need to log on again.

I have tried loging in again, but when eror is emitted, it exits with status 0 and says crashed.

 

It also says I can’t login twice.

Edited by FuTTiiZ

Share this post


Link to post
Share on other sites

Try using process.nextTick(() => client.logOn(logInOptions)) when error is emitted. You're going to need to generate a new 2FA code, though.

I already have that set up, thanks for the answer, I’ll check it out now :)

Share this post


Link to post
Share on other sites

Try using process.nextTick(() => client.logOn(logInOptions)) when error is emitted. You're going to need to generate a new 2FA code, though

I have no idea what to do, can you help me out with the code?

Don't mind the danish console logs, it should still be easy to see it in the console.

console.log('Script blev loaded successfuldt.');

const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const appid = require('appid');
const config = require('./config');

const client = new SteamUser();

console.log('Node.js pakker blev loaded successfuldt.');

//const games = [10,20,30,40,50,60,70,80,100,130,211,218,220,240,280,300,320,340,360,380,400,420,440,500,550,620,730,745,1500,1510,1840,4000,6000,6020,6060,12100,12110,12120,12200,12210,32370,32440,32470,32510,39000,47800,107410,110800,208580,209650,209660,213670,218620,219150,219640,223470,223530,223710,224480,227920,227940,228980,230290,230410,231410,233450,233720,236870,238090,239140,243750,249130,250820,252490,252950,254430,265210,265930,268910,271590,274170,274190,291550,298110,304930,311210,312990,313160,313690,319630,322310,352400,353360,354140,356670,359550,363970,383080,397900,427730,429540,431960,438100,441870,460930,471610,476600,476620,488790,557810,567150,575900,578080,588430,616560,629520,656290,657200,674940,697640,712530,755790,786140,809960,822240,823130,842150,863550,863750,886040,890220,913520,914690,922320,929860,944380,952120,974950,978470,987820];
const games = [4000];

console.log('Spil-valg blev loaded successfuldt.');

const logInOptions = {
	accountName: config.username,
	password: config.password,
	twoFactorCode: SteamTotp.generateAuthCode(config.shared_secret)
};

console.log('Konto-oplysninger blev loaded fra config-filen.');

client.logOn(logInOptions);

client.setPersona(SteamUser.EPersonaState.Offline);
client.gamesPlayed(games);

function checkForPlaying() {
	client.on('playingState', function(blocked, playingApp) {
		console.log(blocked);
		if (blocked == true) {
			setTimeout(checkForPlaying, 5000);
		} else if (blocked == false) {
			client.setPersona(SteamUser.EPersonaState.Offline);
			client.gamesPlayed(games);
		}
	});
}

client.on('loggedOn', () => {
	client.setPersona(SteamUser.EPersonaState.Offline);
	client.gamesPlayed(games);
	console.log(' \n Logged ind på kontoen: ' + config.username);
});

client.on('error', function(err) {
	if (err.eresult == '6') {
		console.log('FEJL!');
		process.nextTick(() => checkForPlaying());
	}
});

Here is the console:

2019-03-09T10:59:43.909660+00:00 app[worker.1]: Script blev loaded successfuldt.
2019-03-09T10:59:46.642463+00:00 app[worker.1]: Node.js pakker blev loaded successfuldt.
2019-03-09T10:59:46.642775+00:00 app[worker.1]: Spil-valg blev loaded successfuldt.
2019-03-09T10:59:46.646221+00:00 app[worker.1]: Konto-oplysninger blev loaded fra config-filen.
2019-03-09T10:59:47.621919+00:00 app[worker.1]:  
2019-03-09T10:59:47.621930+00:00 app[worker.1]:  Logged ind på kontoen: futteboy2
2019-03-09T10:59:56.738752+00:00 heroku[worker.1]: State changed from up to crashed
2019-03-09T10:59:56.608422+00:00 app[worker.1]: Logged in elsewhere.
2019-03-09T10:59:56.718847+00:00 heroku[worker.1]: Process exited with status 0
Edited by FuTTiiZ

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...