Jump to content
McKay Development

Recommended Posts

Posted

Hi,

 

I am using node-steamcommunity to login and then pass the cookies to node-steam-tradeoffer-manager. Whenever session expires, I relogin and pass the cookies to tradeoffer manager:

community.on('sessionExpired', function(err) {
	community.login(logOnOptions,function(err,sessionID,cookies,steamguard) {
		if(err) {
			connectRetry-=1;
			if(connectRetry==0) {
				connectRetry=5;
				setTimeout(function(){logger.info("Couldn't reach server, will log in after 30 min");logIn();},1000*60*30); // try again after 30 minutes
			}
		}
		fs.writeFile(homeDir+'data/steamguard.txt', steamguard); 

		logger.info("Logged into Steam");
		connectRetry=5;
		
		//use steamcommunity cookies for tradeoffer-manager
		manager.setCookies(cookies, function(err) {
			if (err) {
				logger.error(err);
				process.exit(1); 
				return;
			}

			logger.info("Got API key: " + manager.apiKey);
		});
		
		community.chatLogon(); //Log on to the chat so that bot appears online
		community.startConfirmationChecker(10000,secrets.identity_secret); //poll every 10 seconds and confirm
	});
});

Sometimes I get the following error:

info: Logged into Steam
C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:212
        cookies.forEach(function(cookie) {
               ^

TypeError: Cannot read property 'forEach' of undefined
    at SteamCommunity.setCookies (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:212:9)
    at TradeOfferManager.setCookies (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steam-tradeoffer-manager\lib\index.js:80:18)
    at C:\MyData\education\NodeJsTutorial\steam-trade-bot\tradingBot.js:344:11
    at SteamCommunity.<anonymous> (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:128:5)
    at Request._callback (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\components\http.js:62:14)
    at Request.self.callback (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\node_modules\request\request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\node_modules\request\request.js:1067:10)
    at emitOne (events.js:82:20)

The error is coming on the line manager.setCookies(). Am I handling it in the wrong way or is this some bug?

 

Thanks & Regards,

Bheem

Posted (edited)

When you log in you won't have the cookies yet. It's emitted on a websession <-- this is for steam-user, not steamcommunity. This is how I did it with steam-user, I will look into steamcommunity and try to fix it for you :)

var SteamUser = require('steam-user');
var client = new SteamUser();
client.logOn(login);
client.on('webSession', function(sessionID, cookies) { 
    community.setCookies(cookies);
    manager.setCookies(cookies);
    community.startConfirmationChecker(10000, '*'); 
});

EDIT: Idk how to do it with steamcommunity. I would recommend logging in with steam-user and then setting the cookies for steamcommunity and steam-tradeoffer-manager like I did. Easiest thing for me. Good luck! :)

Edited by timgfx

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