Jump to content
McKay Development

How to accept empty tradeoffers ?


Recommended Posts

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 !

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Une Poêle
Link to comment
Share on other sites

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