mar71n Posted March 31, 2017 Report Posted March 31, 2017 To make interactions with bots and alts easier, I wanted to get an autoaccept-script going, that simply accepts everything where the itemstogive.length ==0. This is my code: manager.on('newOffer', function (offer) { accept(offer);});function accept(offer) { if (offer.itemsToGive.length == 0) { offer.accept(true, function (err) { console.log("offer.State: " + offer.state); if (err) { console.log("error: " + err); console.log("offer.State: " + offer.state); if (!(offer.state == 3 || offer.state == 6 || offer.state == 8)) { setTimeout(accept(offer), 3000); return; } } }); Sometimes just nothing happens, and the offer gets ignored completely. My guess is, that the trade-offer is buggy at the beginning (no items show on both sides), and that offer.itemstogive.length is undefined then, and my if is never true? Its quite hard to debug it for me, since this "error-case" isn't really reproduceable since it happens just very rarely. seang 1 Quote
Dr. McKay Posted March 31, 2017 Report Posted March 31, 2017 My guess is, that the trade-offer is buggy at the beginning (no items show on both sides), and that offer.itemstogive.length is undefined then, and my if is never true? That's certainly a possibility. Quote
TuriaGaa Posted March 31, 2017 Report Posted March 31, 2017 I have this function ignored on two accounts.With one account everything works fine I have this function ignored on two accounts Quote
mar71n Posted April 1, 2017 Author Report Posted April 1, 2017 That's certainly a possibility.After some testing, I figured out the following behavior today: My assumption is not the reason. When this problem happens, the callback of offer.accept never gets executed. And when it happens, all the upcoming offers don't get accepted aswell. I changed the code a bit, here it is: //new tradeoffermanager.on('newOffer', function (offer) { accept(offer); });function accept(offer) { console.log("Attempting to accept offer..."); console.log("Items to give Length: " + offer.itemsToGive.length); console.log("offer.state: " + offer.state); if (offer.itemsToGive.length == 0) { offer.accept(false, function (err) { console.log("offer.State: " + offer.state); if (err) { console.log("error: " + err); console.log("offer.State: " + offer.state); } if (!(offer.state == 3 || offer.state == 6 || offer.state == 8)) { console.log("recursive attempt..."); setTimeout(accept(offer), 3000); return; } console.log("\n"); }); } } everything gets printed all the time except the stuff that is contained inside the callback of offer.accept(...)(Not even the first line). My Question here is: Is my code just stupid / did I do a thinking error, or is it problematic when I am logged into that account from browser and phone at the same time and do things there aswell? Also, one thing that I forgot: When I restart that code in the console, It works fine again. Quote
mar71n Posted April 2, 2017 Author Report Posted April 2, 2017 would be really nice if someone could reply to this one, because I'm completely lost :[ Quote
seang Posted April 15, 2017 Report Posted April 15, 2017 I solved it. I forgot to add: client.on('webSession', function(sessionID, cookies) { manager.setCookies(cookies, function(err) { if (err) { console.log(err); process.exit(1); // Fatal error since we couldn't get our API key return; } console.log("Got API key: " + manager.apiKey); }); }); 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.