RafGDev

Untitled

Apr 17th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var SteamTradeOffers = require('steam-tradeoffers');
  2. var SteamCommunity = require('steamcommunity');
  3. var SteamTotp = require('steam-totp');
  4.  
  5. var offers = new SteamTradeOffers();
  6. var community = new SteamCommunity();
  7.  
  8.  
  9. function confirmMobile(userSteamId, callback)  {
  10.       var unixTime = SteamTotp.time();
  11.         var confirmationKey = SteamTotp.getConfirmationKey("IDENTITYSECRET", unixTime, "conf");
  12.        
  13.         community.getConfirmations(unixTime, confirmationKey, (err, confirmations) =>  {
  14.             if (err)  {
  15.                 callback(err);
  16.             }
  17.             else {
  18.                 console.log(confirmations);
  19.                 callback(null);
  20.             }
  21.         });    
  22.  
  23. }
  24.  
  25.  
  26. function runBot(userSteamId, skinArray, callback)  {
  27.     console.log(typeof userSteamId);
  28.   if (!userSteamId || !skinArray)  {
  29.     callback(new Error("500error"));
  30.   }
  31.   else if (skinArray.length === 0)  {
  32.     callback(new Error("500error"))
  33.   }
  34.   else {
  35.  
  36.     var sendSkinArray = [];
  37.  
  38.     console.log("Skin array 8is: " + skinArray);
  39.  
  40.  
  41.     for (var i = 0;i<skinArray.length;i++)  {
  42.  
  43.       sendSkinArray.push({
  44.         appid: 730,
  45.         contextid: 2,
  46.         amount: 1,
  47.         assetid: String(skinArray[i])
  48.       });
  49.  
  50.       if (i === (skinArray.length -1))  {
  51.         offers.makeOffer({
  52.           partnerSteamId: userSteamId,  
  53.           itemsFromMe: sendSkinArray,
  54.           itemsFromThem: [],
  55.           message: "Hey! This is the CSGO ACORN bot"
  56.         },(err, response)  => {
  57.           if (err)  { //If cookies have expired, then get new cookies from steamcommunity.com
  58.             community.login({
  59.               "accountName":"USERNAME",
  60.               "password":"PASSWORD",
  61.               "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
  62.             },(loginError, sessionID, cookies, steamguard) => {
  63.               if (loginError)  {
  64.                 console.log("err when trying to log inHELLOWO");
  65.  
  66.                 console.log("err is: " + loginError);
  67.                 console.log("sessionID is: " + sessionID);
  68.                 console.log("cookies is: " + cookies);
  69.                 console.log("steamguard is: " + steamguard);
  70.                 callback(new Error("500error"));
  71.               }
  72.               else {
  73.  
  74.                 community.loggedIn((communityError, loggedIn) => {
  75.  
  76.                   if (communityError)  {
  77.                     console.log("err2 was: " + communityError);
  78.                     callback(new Error("loginFailed"));
  79.                   }
  80.                   else {
  81.                     if (loggedIn)  {
  82.                       console.log(util.inspect(cookies, false, null));
  83.                       console.log("err is: " + communityError);
  84.                       console.log("sessionID is: " + sessionID);
  85.                       console.log("cookies is: " + cookies);
  86.                       console.log("steamguard is: " + steamguard);
  87.                       offers.setup({
  88.                         sessionID:sessionID,
  89.                         //webCookie: cookiesCache,
  90.                         webCookie:cookies,
  91.                         APIKey: "APIKEY",
  92.                       });
  93.  
  94.                       runBot(userSteamId, skinArray, callback);
  95.                     }
  96.                   else {
  97.  
  98.                     console.log("Logged in is: " + loggedIn);
  99.                     console.log("could not log in");
  100.                     console.log("err is: " + err);
  101.                     console.log("sessionID is: " + sessionID);
  102.                     console.log("cookies is: " + cookies);
  103.                     console.log("steamguard is: " + steamguard);
  104.  
  105.                     callback(new Error("loginFailed"))
  106.                   }
  107.                   }
  108.  
  109.                 });
  110.  
  111.  
  112.               }
  113.             });
  114.  
  115.           }
  116.           else {
  117.                         console.log(response);
  118.  
  119.                         confirmMobile(userSteamId, (err, data) =>  {
  120.                             if (err)  {
  121.                                 callback(err);
  122.                             }
  123.                             else {
  124.                                 callback(null);
  125.                             }
  126.                         });
  127.           }
  128.         });
  129.       }
  130.     }
  131.   }
  132. }
  133.  
  134.  
  135. community.login({
  136.   "accountName":"USERNAME",
  137.   "password":"PASSWORD",
  138.   "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
  139. },(loginError, sessionID, cookies, steamguard) => {
  140.   if (loginError)  {
  141.     console.log(loginError);
  142.   }
  143.   else {
  144.     community.loggedIn((communityError, loggedIn) => {
  145.       if (communityError)  {
  146.         console.log("err2 was: " + communityError);
  147.       }
  148.       else {
  149.         if (loggedIn)  {
  150.           offers.setup({
  151.             sessionID:sessionID,
  152.             webCookie:cookies,
  153.             APIKey: "APIKEY",
  154.           });
  155.  
  156.                 runBot("STEAMID", ["5794350713"], (err) =>  {
  157.                     if (err)  {
  158.                         console.log("There was an error");
  159.                         }
  160.                         else {
  161.                             console.log("It worked!");
  162.                         }
  163.                     });
  164.                 }
  165.                 else {
  166.                     console.log("Could not log in");
  167.                 }
  168.             }
  169.     });
  170.   }
  171. });
Advertisement
Add Comment
Please, Sign In to add comment