Jump to content
McKay Development

steamcommunity.getConfirmations method only comes up with confirmations when sending trade offers from computer instead of node script


Recommended Posts

Posted

Hey all!,

 

I have pasted my whole script below but please only pay attention to the confirmMobile(userSteamId, callback) function because it is the function that isn't working for me. 

 

My main problem (as the title suggests) is that the getConfirmations method only picks up trade offers that I have sent through steamcommunity. Any trade offers that I send through node do not come up. 

 

If there is anything that I did wrong please tell me as I have no idea what is wrong with the confirmMobile(userSteamId, callback) function.

 

Any help is greatly appreciated!!

var SteamTradeOffers = require('steam-tradeoffers');
var SteamCommunity = require('steamcommunity');
var SteamTotp = require('steam-totp');


var offers = new SteamTradeOffers();
var community = new SteamCommunity();




function confirmMobile(userSteamId, callback)  { //This function is called after the trade offer is sent, please look at this function
var unixTime = SteamTotp.time(); 
var confirmationKey = SteamTotp.getConfirmationKey("IDENTITYSECRET", unixTime, "conf");


community.getConfirmations(unixTime, confirmationKey, (err, confirmations) =>  {
if (err)  {
callback(err);
}
else {
console.log(confirmations);
callback(null);
}
}); 
}




function runBot(userSteamId, skinArray, callback)  { // This function makes a trade offer,
console.log(typeof userSteamId);
  if (!userSteamId || !skinArray)  {
    callback(new Error("500error"));
  }
  else if (skinArray.length === 0)  {
    callback(new Error("500error"))
  }
  else {
    var sendSkinArray = [];
    console.log("Skin array 8is: " + skinArray);
    for (var i = 0;i<skinArray.length;i++)  {
      sendSkinArray.push({
        appid: 730,
        contextid: 2,
        amount: 1,
        assetid: String(skinArray[i])
      });
      if (i === (skinArray.length -1))  {
        offers.makeOffer({
          partnerSteamId: userSteamId,  
          itemsFromMe: sendSkinArray,
          itemsFromThem: [],
          message: "Hey! This is the CSGO ACORN bot"
        },(err, response)  => {
          if (err)  { //If cookies have expired, then get new cookies from steamcommunity.com
            community.login({
              "accountName":"USERNAME",
              "password":"PASSWORD",
              "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
            },(loginError, sessionID, cookies, steamguard) => {
              if (loginError)  {
                console.log("err when trying to log inHELLOWO");
                callback(new Error("500error"));
              }
              else {
                community.loggedIn((communityError, loggedIn) => {
                  if (communityError)  {
                    console.log("err2 was: " + communityError);
                    callback(new Error("loginFailed"));
                  }
                  else {
                    if (loggedIn)  {
                      offers.setup({
                        sessionID:sessionID,                
                        webCookie:cookies,
                        APIKey: "SHAREDSECRET",
                      });
                      runBot(userSteamId, skinArray, callback);
                    }
                  else {
                    callback(new Error("loginFailed"))
                  }
                  }
                });
              }
            });
          }
          else {
console.log(response);


confirmMobile(userSteamId, (err, data) =>  {
if (err)  {
callback(err);
}
else {
callback(null);
}
}); 
          }
        });
      }
    }
  }
}




community.login({
  "accountName":"USERNAME",
  "password":"PASSWORD",
  "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
},(loginError, sessionID, cookies, steamguard) => {
  if (loginError)  {
    console.log(loginError);
  }
  else {
    community.loggedIn((communityError, loggedIn) => {
      if (communityError)  {
        console.log("err2 was: " + communityError);
      }
      else {
        if (loggedIn)  {
          offers.setup({
            sessionID:sessionID,
            webCookie:cookies,
            APIKey: "APIKEY",
          });


runBot("USERSTEAMID", ["SKINASSETID"], (err) =>  {
if (err)  {
console.log("There was an error");
}
else {
console.log("It worked!");
}
}); 
}
else {
console.log("Could not log in");
}
}
    });
  }
});
 

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