Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  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(["B>Cards: 0.11 | S>Cards: 0.33",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.  
  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. function LogTradesCompleted(){
  101. winston.info("trades completed " + TradesCompleted + " we should make 60 a day to make profit.");
  102. }
  103.  
  104. setInterval(LogTradesCompleted, 1440 * 1000);
  105.  
  106.  
  107. manager.on('newOffer', function(offer) {
  108.  
  109. var partnerID = offer.partner.getSteamID64();
  110.  
  111. var OurCardVaule = Get_Cards(offer.itemsToGive, config.CardsSellPrice);
  112. var OurMetal = Get_Metal(offer.itemsToGive);
  113. var VauleToGive = OurCardVaule + OurMetal;
  114.  
  115. var ThereCardVaule = Get_Cards(offer.itemsToReceive,config.CardsBuyPrice);
  116. var ThereMetal = Get_Metal(offer.itemsToReceive);
  117. var VauleToReceive = ThereCardVaule + ThereMetal;
  118.  
  119.  
  120. if(VauleToReceive >= VauleToGive) {
  121. acceptOffer(offer, partnerID);
  122. console.log("accepted offer");
  123. console.log("invited to group");
  124. }else{
  125. declineOffer(offer);
  126. console.log("declined offer");
  127. }
  128. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement