mar71n Posted January 18, 2017 Report Share Posted January 18, 2017 Hey, I've played around a little with the library you're offering us.However, my little application just gets stuck at some point, and I don't really get why. Code: manager.on('newOffer', function (offer) { var itemsToReceive = offer.itemsToReceive; var itemsToGive = offer.itemsToGive; if (itemsToGive.length >0) {} }else{ offer.accept(function (err) { if(err){ console.log("Unable to accept offer: "); } console.log("offer accepted "+itemsToReceive.length+" Keys received"); }); } } ); I'm loging in, setting cookie etc. following your examples.However this should accept any offer that it gets as long as its empty on my bots side. But after some time it just gets stuck and doesn't accept anymore.I can also press control + c in my terminal then, to exit the code where it got stuck at. And another question: How can I make a callback to do the offer.accept over and over again, until its done / gone? (steam has issues too often). Thank you for reading & thanks for your great work Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted January 18, 2017 Report Share Posted January 18, 2017 if (itemsToGive.length >0) {} }else{This looks like a syntax error to me. Quote Link to comment Share on other sites More sharing options...
mar71n Posted January 18, 2017 Author Report Share Posted January 18, 2017 you are right, I probably fucked up copying it somehow. Here is the entire code again, still with the same issues: var Steam = require('steam'); var request = require('request'); var SteamUser = require("steam-user"); var SteamCommunity = require("steamcommunity"); var SteamTotp = require("steam-totp"); var TradeOfferManager = require("steam-tradeoffer-manager"); var fs = require("fs"); var client = new SteamUser(); var friends = new Steam.SteamFriends(client.client); var manager = new TradeOfferManager({ "steam": client, "domain": "example.com", "language": "en" }); var net = require('net'); var community = new SteamCommunity(); var logOnOptions = { "accountName": "*********", "password": "*********", "twoFactorCode": SteamTotp.getAuthCode("*********") }; client.logOn(logOnOptions); client.on("loggedOn", function (details) { console.log("Logged on to Steam! With the SteamID of " + client.steamID.getSteam3RenderedID()); client.setPersona(SteamUser.Steam.EPersonaState.Online); }); client.on('webSession', function (sessionID, cookies) { manager.setCookies(cookies, function (err) { if (err) { process.exit(1); } console.log("Got API key: " + manager.apiKey); }); community.setCookies(cookies); }); //new tradeoffer manager.on('newOffer', function (offer) { if(offer.itemsToGive.length == 0 && offer.itemsToReceive.length > 0) { offer.accept(); console.log("offer accepted, "+offer.itemsToReceive.length+" new Items obtained!"); } }); Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted January 18, 2017 Report Share Posted January 18, 2017 Your session is probably expiring. You should call webLogOn every hour or so to refresh it, and also when sessionExpired is emitted on the SteamCommunity instance. Quote Link to comment Share on other sites More sharing options...
mar71n Posted January 19, 2017 Author Report Share Posted January 19, 2017 I guess you mean something like this? var task = cron.schedule('0 * * * *', function() { client.webLogOn(); } Quote Link to comment Share on other sites More sharing options...
mar71n Posted January 19, 2017 Author Report Share Posted January 19, 2017 (edited) it doesn't change the behavior at all. for some reason something blocks the program completely. only control + c changes that. and then the program works as expected again until the next block occurs. Also: it doesn'T matter if I get tradeoffers or not, just after a certain time this happens. (not even too much time, like a few minutes) Edited January 19, 2017 by mar71n Quote Link to comment Share on other sites More sharing options...
mar71n Posted January 22, 2017 Author Report Share Posted January 22, 2017 In case anyone cares: My problem came from node.js. Updating and updating all dependencies fixed it. Quote Link to comment Share on other sites More sharing options...
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.