Jump to content
McKay Development

Recommended Posts

Posted

hello everyone ! im trying to make bot which reading incoming offers data and outputing them in console but my code is not working i dont understand why 

when i run the code the output is cookies set then im sending the trade to bot account but nothing happends

 

const steamUser = require('steam-user')
const steamtotp = require('steam-totp')
 
const steamcommunity = require('steamcommunity')
const steamTradeofferManager = require('steam-tradeoffer-manager')
const config = require('./config')
 
const account = new steamUser()
 
const community = new steamcommunity()
 
const manager = new steamTradeofferManager({
    steam : account,
    community : community,
    language : 'en',
    pollInterval : 5000
})
 
const loginops = {
           //username
    accountName : config.account1.username,
          //password
    password : config.account1.password,
                                                                                    //shared secret
    twoFactorCode : steamtotp.generateAuthCode(config.account1.shared_secret)
}
 
account.logOn(loginops)
 
account.on('loggedOn', () => {
    account.setPersona(steamUser.EPersonaState.Online)
    account.gamesPlayed(730)
})
 
account.on('webSession', (sid,cookies) => {
    manager.setCookies(cookies, function(err) {
        if (err) {
            console.log(err);
            process.exit(1); // Fatal error
            return;
        }
 
        console.log("Cookies set");
    });
 
    community.setCookies(cookies);
   
})
manager.on('newOffer', function(offer) {
    console.log("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID());
    offer.accept(function(err, status) {
        if (err) {
            console.log("Unable to accept offer: " + err.message);
        } else {
            console.log("Offer accepted: " + status);
            if (status == "pending") {
                community.acceptConfirmationForObject("identitySecret", offer.id, function(err) {
                    if (err) {
                        console.log("Can't confirm trade offer: " + err.message);
                    } else {
                        console.log("Trade offer " + offer.id + " confirmed");
                    }
                });
            }
        }
    });
});
Posted

I'm assuming from your gamesPlayed(730) call that you're trading CS2 items. For steam-tradeoffer-manager to work as expected for trade offers containing CS2 items, you need to enable the useAccessToken constructor option.

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