Jump to content
McKay Development

Need help confirming sent trade request.


Recommended Posts

Hello I've been following the tutorial listed here. Its a great tutorial and everything works so far. However I am able to send a trade request, I am not however able to confirm mobile auth to actually send it. below is my code. please for the love of gaben help me.

 

 

var SteamUser = require('steam-user');
var client = new SteamUser();
var SteamTotp = require('steam-totp');

var SteamCommunity = require('steamcommunity');
var TradeOfferManager = require('steam-tradeoffer-manager');
var community = new SteamCommunity();
var manager = new TradeOfferManager({
    steam: client,
    community: community,
    language: 'en'
});



var logOnOptions = {
    accountName: 'sadface',
    password: 'sadface',
    twoFactorCode: SteamTotp.generateAuthCode('superTopSecretLoL')
};
 


client.logOn(logOnOptions);
client.on('loggedOn',function(){
    console.log('Logged into Steam');
    // online status
    client.setPersona(SteamUser.Steam.EPersonaState.Online);
    // set to appear to be playing tf2
    client.gamesPlayed(440);
   
});

 

 

client.on('webSession', function(sessionid, cookies){
console.log('websession being executed');
manager.setCookies(cookies);
community.setCookies(cookies);
community.startConfirmationChecker(10000, 'SuperTopSecretLoL');

sendOffer();

});

function sendOffer(){
    var partner = '76561198049686559';
    var appid = 440;
    var contextid = 2;

    var offer = manager.createOffer(partner);
    //load my inventory
    manager.loadInventory(appid, contextid, true, function(err, myInv){
        if (err) {
            console.log(err);
        } else {
            var myItem = myInv[Math.floor(Math.random() * myInv.length - 1)];
            offer.addMyItem(myItem);

            // loads partners inventory
            manager.loadUserInventory(partner, appid, contextid, true, function(err, theirInv){
                //console.log(countCurrency(theirInv));
                if (err) {
                    console.log(err);
                } else {
                    var theirItem = theirInv[Math.floor(Math.random() * theirInv.length - 1)];
                    // console.log(theirInv);
                    offer.addTheirItem(theirItem);
                    offer.setMessage(`Will you trade your ${theirItem.name} for my ${myItem.name}?`);
                    offer.send(function(err, status){
                        if (err) {
                            console.log(err);
                        } else {
                            console.log(`Sent offer. Status: ${status}.`);
                            community.checkConfirmations();
                        }
                    });
                }
            });
        }
    });
}

community.on('confKeyNeeded', function(tag, callback) {
    console.log('confKeyNeeded Called');
    var time = Math.floor(Date.now() / 1000);
    callback(null, time, SteamTotp.getConfirmationKey('superTopSecretLoL', time, tag));
});

 

Link to comment
Share on other sites

  • 2 weeks later...

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