Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. const SteamUser = require('steam-user');
  2. const SteamTotp = require('steam-totp')
  3. const config = require ('./config.json')
  4. const SteamCommunity = require('steamcommunity')
  5. const TradeOfferManager = require('steam-tradeoffer-manager')
  6. const Winston = require('winston')
  7.  
  8. const client = new SteamUser();
  9. const community = new SteamCommunity();
  10. const manager = new TradeOfferManager({
  11.  
  12. });
  13.  
  14. const logOnOptions = {
  15. accountName: config.username,
  16. password: config.password,
  17. twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
  18. };
  19.  
  20. const keysToAccept = [
  21. "Chroma 2 Case Key",
  22. "Huntsman Case Key",
  23. "Chroma Case Key",
  24. "eSports Key",
  25. "Winter Offensive Case Key",
  26. "Revolver Case Key",
  27. "Operation Vanguard Case Key",
  28. "Shadow Case Key",
  29. "Operation Wildfire Case Key",
  30. "Falchion Case Key",
  31. "Operation Breakout Case Key",
  32. "Chroma 3 Case Key",
  33. "CS:GO Case Key",
  34. "Operation Phoenix Case Key",
  35. "Gamma Case Key",
  36. "Gamma 2 Case Key",
  37. "Glove Case Key",
  38. "Spectrum Case Key"
  39. ];
  40.  
  41. client.logOn(logOnOptions);
  42.  
  43. client.on('loggedOn', () => {
  44. console.log('Successfully logged on');
  45. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  46. client.gamesPlayed(["Nycklar Inne"]);
  47. });
  48.  
  49. client.on("friend.Message", function(steamID, message) {
  50. if (message == "Tja"){
  51. client.chatMessage(steamID, "Tja");
  52. }
  53.  
  54. });
  55.  
  56. client.on('webSession', (sessionid, cookies) => {
  57. manager.setCookies(cookies);
  58.  
  59. community.setCookies(cookies);
  60. community.startConfirmationChecker(20000, config.identitysecret);
  61. });
  62.  
  63. function acceptOffer(offer) {
  64. offer.accept((err) => {
  65. community.checkConfirmations();
  66. console.log("We accepted an offer")
  67. if (err) console.log ("There was an error accepting the offer.")
  68. });
  69. }
  70.  
  71. function declineOffer(offer) {
  72. offer.decline((err) => {
  73. console.log("We declined an offer.")
  74. if (err) console.log ("There was an error declining the offer.")
  75. });
  76. }
  77.  
  78. manager.on('newOffer', (offer) => {
  79. if (offer.partner.getSteamID64() === config.ownerID) {
  80. acceptOffer(offer);
  81. } else{
  82. client.friends.sendMessage(offer.partner.getSteamID64(), "Vi har mottagit din beställning på x nycklar. Var god Swisha x SEK till 070 888 22 31.");
  83. }
  84.  
  85. var client = new SteamUser();
  86. var offers = new TradeOfferManager
  87. steam: client
  88. domain: config.domain
  89. language: "en"
  90. pollInterval: 10000
  91. cancelTime: 600000
  92.  
  93. client.friends.on('relationships', function(){
  94. var friendcount = 0;
  95. for (steamID in client.friends.friends) {
  96. friendcount++;
  97. if (client.friends.friends[steamID] === SteamUser.Steam.EFriendRelationship.RequestRecipient) {
  98. logger.info("Friend request while offline from: "+steamID);
  99. client.friends.addFriend(steamID);
  100. }
  101. }
  102. logger.debug("We have "+friendcount+" friends.");
  103. if (friendcount > 200) {
  104. logger.warn("We're approaching the default friends limit. Maybe we need to purge old friends?");
  105. }
  106. });
  107.  
  108. client.friends.on('friend', function (steamID, realationship) {
  109. if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipent) {
  110. logger.info('[' + steamID + '] Accepted friend request');
  111. client.friends.addFriend(steamID);
  112. }
  113. else if (relationship == SteamUser.Steam.EFriendRelationship.None) {
  114. logger.info('[' + steamID + '] Un-friended');
  115. }
  116. });
  117.  
  118. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement