Op1x3r Posted June 4, 2020 Report Posted June 4, 2020 Hello, I noticed that some offers are sometimes skipped (possibly due to steam lags or smthing like that) in the newOffer event. My bot sees those offers only when it re-logins. My question would be: Is there a way to tell the bot to check for pending offers and let manager.on('newOffer'); handle them every x seconds? I saw the getOffers function, that might work, but how do I make manager.on('newOffer') handle those offers? Quote
vrtgn Posted June 4, 2020 Report Posted June 4, 2020 (edited) // Get all active offers manager.getOffers(TradeOfferManager.EOfferFilter.ActiveOnly, (err, sent, received) => { // Loop through recieved trade offers and execute the processOffer function on each. if (received) { for (var i = 0; i < received.length; i++) { processOffer(received[i]); } } }); You could put the above in a setInterval. The processOffer function is the same thing that you do when you get the newOffer event. So if you have a large function like: manager.on('newOffer', offer => { // code }); You can change it to: manager.on('newOffer', offer => processOffer(offer)); function processOffer(offer) { // code } And so then you can process an offer from elsewhere. Edited June 4, 2020 by vrtgn Quote
Op1x3r Posted June 4, 2020 Author Report Posted June 4, 2020 (edited) 1 hour ago, vrtgn said: // Get all active offers manager.getOffers(TradeOfferManager.EOfferFilter.ActiveOnly, (err, sent, received) => { // Loop through recieved trade offers and execute the processOffer function on each. if (received) { for (var i = 0; i < received.length; i++) { processOffer(received[i]); } } }); You could put the above in a setInterval. The processOffer function is the same thing that you do when you get the newOffer event. So if you have a large function like: manager.on('newOffer', offer => { // code }); You can change it to: manager.on('newOffer', offer => processOffer(offer)); function processOffer(offer) { // code } And so then you can process an offer from elsewhere. What if my setInterval executes at the same time as newOffer? (Won't the duplication be a problem?) Edited June 4, 2020 by Op1x3r Quote
vrtgn Posted June 4, 2020 Report Posted June 4, 2020 I think so, you may be able to solve this with polldata. 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.