Une Poêle Posted May 28, 2016 Report Posted May 28, 2016 Hi, I tried to mess around with the module but didn't manage to get the bot to only accept empty tradeoffers.I want the bot to automatically accept items but never give any.I'd also like the bot to auto-accept these empty trades where it can receive these items but let the regular 1:1, 2:1 etc tradeoffers pending. So that I can accept or decline them manually.Thank you very much for the help ! Quote
Dr. McKay Posted May 28, 2016 Report Posted May 28, 2016 Check if itemsToGive.length is 0, and itemsToReceive.length is greater than 0. If both tests pass, then accept the offer. Make sure you check both, as both itemsToGive and itemsToReceive could be empty when the Steam econ server is acting up, even though you might be giving items in that offer. Quote
Une Poêle Posted May 29, 2016 Author Report Posted May 29, 2016 (edited) To be honest, I'm pretty new to coding and I managed to get this code which is running fine but I have no idea how to implement the options I mentionned above... var SteamCommunity = require('steamcommunity'); var SteamTotp = require("steam-totp"); var steam = new SteamCommunity(); var TradeOfferManager = require('steam-tradeoffer-manager'); var manager = new TradeOfferManager({ domain: 'charredgrass.github.io', //for api key uses language: 'en', pollInterval: 30000 }); var logOnOptions = { accountName: '*****', password: '*****', twoFactorCode: SteamTotp.generateAuthCode('*****') }; var identitySecret = '*****'; //logs in via browser steam.login(logOnOptions, function(err, sessionID, cookies, steamguard) { if (err) { console.log('There was an error logging in! Error details: ' + err.message); process.exit(1); //terminates program } else { console.log('Successfully logged in as ' + logOnOptions.accountName); steam.chatLogon(); manager.setCookies(cookies, function(err) { if (err) { console.log(err); process.exit(1); } }); } steam.startConfirmationChecker(10000, identitySecret); }); manager.on('newOffer', processTrade); function processTrade(offer) { console.log('New trade from ' + offer.partner); offer.accept(function(err) { if (offer.itemsToGive.length == 0 && offer.itemsToReceive.length > 0) { offer.accept() } if (err) { console.log('Error accepting offer: ' + err.message); } else { console.log('Successfully accepted an offer.'); } }) } Edited May 29, 2016 by Une Poêle 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.