Jump to content
McKay Development

Bot running 24/7 - Quick question


Frost Byte

Recommended Posts

Hello everyone!

 

Just a really quick question.

Let's say I want my bot to run 24/7. How can I make sure it won't stop at all?

 

I don't really mean like:

1. Keep your computer / bot running on your local machine 24/7.

2. Buy a VPS and run the bot on that machine.

Because that is quite obvious.

 

I mean like, the session not expiring. Is the following code enough to make sure that my steambot runs 24/7 on a Raspberry Pie for example?

client.on("webSession", function(steamID, cookies) {
logger.debug("Got web session");

setInterval(function() {
client.webLogOn();
}, 1000*60*60);

/* And some more stuff which need cookies */
});

Thanks for your help!

Edited by Frost Byte
Link to comment
Share on other sites

If I'm right, the setTimeout method only runs a function once after a specified amount of time, whereas setInterval runs a function every time after a specified amount of time. If my session expires, why would I want to run the webLogOn method only once with setTimeout? And if my session expires another time after the last one, will my bot then just stop working? Or is my reasoning completely wrong now?

 

Besides, I implemented the following code, to keep my session active:

// Re-login after a session expires
community.on("sessionExpired", function(err) {
	if (err) {
		logger.info("Session is still up");
	} else {
		logger.warn("Session expired, trying to re-login");
		client.webLogOn();
	}
});

Will this assure that my Steambot continues to run 24/7 on a Raspberry Pie which will be on 24/7 as well?

 

If not, could you be so kind to give a few suggestions to keep my bot running? It would be awesome to get it working!  :D

Link to comment
Share on other sites

Alright good to know!

 

Just a little quick question: Will the code the following code be enough to keep the bot running 24/7?

// Re-login after a session expires
community.on("sessionExpired", function(err) {
	if (err) {
		logger.info("Session is still up");
	} else {
		logger.warn("Session expired, trying to re-login");
		client.webLogOn();
	}
});

If not, could you give a suggestion to keep my bot running? That would be extremely helpful and much appreciated.

 

 As always, thanks for helping me out every time! You are awesome you know  ;)

Link to comment
Share on other sites

Ah, wonderful!

 

I was indeed in doubt whether the error from sessionExpired was actually the part that makes us aware that the session expired or whether it was a real error, which would mean that the session was actually still up. Well, that is sorted out now  :D.

 

If I'm right, this should do the trick now:

client.on("webSession", function(steamID, cookies) {
logger.debug("Got web session");

setInterval(function() {
client.webLogOn();
}, 1000*60*60);

/* And some more stuff which need cookies */
});

And at the end of the file:

// Re-login after a session expires
community.on("sessionExpired", function(err) {
	if (err) {
		logger.warn("Session expired, trying to re-login");
		client.webLogOn();
	}
});

You suggested the login interval, but do you actually mean the .setInterval or the .setTimeout method?

 

Thanks for your answer!

Link to comment
Share on other sites

I'm sorry, but I have no clue what you meant with your last sentence...

I need to keep track of the last time I called webLogOn, but after that you lost me  :wacko:

 

Do you mean that I can only use webLogOn if my session has expired and it doesn't work when my session is still running? And I shouldn't link it to the sessionExpired event, because that can be emitted at any frequency?

Link to comment
Share on other sites

You can use webLogOn at any time, but if you spam Steam then Valve is not likely to be happy.

 

You shouldn't create an interval inside of an event callback. Create it outside the callback, in the root level of the module (the part that has no indentation).

 

Keep track of the last time you called webLogOn (a timestamp) and don't call it if it was less than say a minute ago.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

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...