Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 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. function Get_Cards(offer, price) {
  59.  
  60. var Vaule = 0;
  61.  
  62. offer.forEach(function(item) {
  63. if (item.tags) {
  64. item.tags.forEach(function(tag) {
  65. if (tag.name && tag.name == "Trading Card") {
  66. Vaule += Math.round(price * 9);
  67. }
  68. });
  69. }
  70. });
  71. return Vaule;
  72. }
  73.  
  74. function Get_backround(offer, price) {
  75.  
  76. var Vaule = 0;
  77.  
  78. offer.forEach(function(item) {
  79. if (item.tags) {
  80. item.tags.forEach(function(tag) {
  81. if (tag.name && tag.name == "Profile Background") {
  82. Vaule += Math.round(price * 9);
  83. }
  84. });
  85. }
  86. });
  87. return Vaule;
  88. }
  89.  
  90. function Get_emoticons(offer, price) {
  91.  
  92. var Vaule = 0;
  93.  
  94. offer.forEach(function(item) {
  95. if (item.tags) {
  96. item.tags.forEach(function(tag) {
  97. if (tag.name && tag.name == "Emoticon") {
  98. Vaule += Math.round(price * 9);
  99. }
  100. });
  101. }
  102. });
  103. return Vaule;
  104. }
  105.  
  106.  
  107.  
  108. function Get_Metal(offer) {
  109.  
  110. var Vaule = 0;
  111.  
  112. for (i = 0; i < offer.length; i++) {
  113. if (offer[i].market_hash_name.includes('Refined Metal')) {
  114. Vaule+=9;
  115. } else {
  116. if (offer[i].market_hash_name.includes('Reclaimed Metal')) {
  117. Vaule+=3;
  118. } else {
  119. if (offer[i].market_hash_name.includes('Scrap Metal')) {
  120. Vaule++;
  121. }
  122. }
  123. }
  124. }
  125. return Vaule;
  126. }
  127.  
  128.  
  129.  
  130.  
  131. function acceptOffer(offer, partnerID) {
  132. offer.accept((err) => {
  133. if (err) console.log(`Unable to accept offer: ${err.message}`);
  134. community.checkConfirmations();
  135. client.inviteToGroup(partnerID, config.groupSteamID);
  136. });
  137. }
  138.  
  139.  
  140.  
  141.  
  142. function declineOffer(offer) {
  143. offer.decline((err) => {
  144. if (err) return console.log(`Unable to decline offer: ${err.message}`);
  145. });
  146. }
  147.  
  148. function LogTradesCompleted(){
  149. winston.info("trades completed " + TradesCompleted + " we should make 60 a day to make profit.");
  150. }
  151.  
  152. setInterval(LogTradesCompleted, 1440 * 1000);
  153.  
  154.  
  155. manager.on('newOffer', function(offer) {
  156.  
  157. var partnerID = offer.partner.getSteamID64();
  158.  
  159. var OurCardVaule = Get_Cards(offer.itemsToGive, config.CardsSellPrice);
  160. var OurMetal = Get_Metal(offer.itemsToGive);
  161. var OurBackroundVaule = Get_backround(offer.itemsToGive, config.BackroundSellPrice)
  162. var OurEmoticonVaule = Get_emoticons(offer.itemsToGive, config.EmoticonSellPrice)
  163. var VauleToGive = OurCardVaule + OurMetal + OurEmoticonVaule + OurBackroundVaule;
  164.  
  165. var ThereCardVaule = Get_Cards(offer.itemsToReceive,config.CardsBuyPrice);
  166. var ThereMetal = Get_Metal(offer.itemsToReceive);
  167. var ThereBackroundVaule = Get_backround(offer.itemsToReceive, config.BackroundBuyPrice);
  168. var ThereEmoticonVaule = Get_emoticons(offer.itemsToReceive, config.EmoticonBuyPrice);
  169. var VauleToReceive = ThereCardVaule + ThereMetal + ThereBackroundVaule + ThereEmoticonVaule;
  170.  
  171.  
  172. if(VauleToReceive >= VauleToGive) {
  173. acceptOffer(offer, partnerID);
  174. console.log("accepted offer");
  175. console.log("invited to group");
  176. }else{
  177. declineOffer(offer);
  178. console.log("declined offer");
  179. }
  180. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement