daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const SteamUser = require('steam-user');
  2. const TradeOfferManager = require('steam-tradeoffer-manager');
  3. const SteamTotp = require('steam-totp');
  4. const SteamCommunity = require('steamcommunity');
  5. const config = require('./config.json');
  6.  
  7. const community = new SteamCommunity();
  8. const client = new SteamUser();
  9. const manager = new TradeOfferManager({
  10.     steam: client,
  11.     domain: 'example.com',
  12.     language: 'en'
  13. });
  14.  
  15. const logOnOptions = {
  16.     accountName: config.username,
  17.     password: config.password,
  18.     twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
  19. };
  20. //log on
  21. client.logOn(logOnOptions);
  22.  
  23. client.on('loggedOn', function(details) {
  24.     console.log(`Logged into Steam as ${client.steamID.getSteam3RenderedID()}`); //online then play tf2
  25.     client.setPersona(SteamUser.Steam.EPersonaState.Online);
  26.     client.gamesPlayed([440])
  27. });
  28.  
  29. client.on('webSession', function(sessionID, cookies) {
  30.     manager.setCookies(cookies, function(err) {
  31.         if (err) return console.log(err);
  32.         console.log(`Got API key: ${manager.apiKey}`);
  33.     });
  34.  
  35.     community.setCookies(cookies);
  36.     community.startConfirmationChecker(10000, config.identitySecret);
  37. });
  38.  
  39.  
  40. console.log("only keep tradeable items in the bot")
  41.  
  42. function Get_Cards(offer, price) {
  43.  
  44.     var Vaule = 0;
  45.  
  46.     offer.forEach(function(item) {
  47.         if (item.tags) {
  48.             item.tags.forEach(function(tag) {
  49.                 if (tag.name && tag.name == "Trading Card") {
  50.                     Vaule += Math.round(price * 9);
  51.                 }
  52.             });
  53.         }
  54.     });
  55.     return Vaule;
  56. }
  57.  
  58.  
  59.  
  60. function Get_Metal(offer) {
  61.  
  62.   var Vaule = 0;
  63.  
  64.     for (i = 0; i < offer.length; i++) {
  65.         if (offer[i].market_hash_name.includes('Refined Metal')) {
  66.           Vaule+=9;
  67.         } else {
  68.             if (offer[i].market_hash_name.includes('Reclaimed Metal')) {
  69.                 Vaule+=3;
  70.             } else {
  71.                 if (offer[i].market_hash_name.includes('Scrap Metal')) {
  72.                     Vaule++;
  73.                 }
  74.             }
  75.         }
  76.     }
  77.     return Vaule;
  78. }
  79.  
  80.  
  81.  
  82.  
  83. function acceptOffer(offer, partnerID) {
  84.     offer.accept((err) => {
  85.         if (err) console.log(`Unable to accept offer: ${err.message}`);
  86.         community.checkConfirmations();
  87.         client.inviteToGroup(partnerID, config.groupSteamID);
  88.     });
  89. }
  90.  
  91.  
  92.  
  93.  
  94. function declineOffer(offer) {
  95.     offer.decline((err) => {
  96.         if (err) return console.log(`Unable to decline offer: ${err.message}`);
  97.     });
  98. }
  99.  
  100. manager.on('newOffer', function(offer) {
  101.  
  102.     var partnerID = offer.partner.getSteamID64();
  103.  
  104.     var OurCardVaule = Get_Cards(offer.itemsToGive, config.CardsSellPrice);
  105.     var OurMetal = Get_Metal(offer.itemsToGive);
  106.     var VauleToGive = OurCardVaule + OurMetal;
  107.  
  108.     var ThereCardVaule = Get_Cards(offer.itemsToReceive,config.CardsBuyPrice);
  109.     var ThereMetal = Get_Metal(offer.itemsToReceive);
  110.     var VauleToReceive = ThereCardVaule + ThereMetal;
  111.  
  112.  
  113.     if(VauleToReceive >= VauleToGive) {
  114.       acceptOffer(offer, partnerID);
  115.       console.log("accepted offer");
  116.       console.log("invited to group");
  117.     }else{
  118.       declineOffer(offer);
  119.       console.log("declined offer");
  120.     }
  121. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top