Advertisement
hydrlon

anelsexi

Feb 9th, 2017
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. /*
  2. _ _ _ _ _____ _____ _ _ _____ _ _ _ _
  3. | \ | | | | | |/ ____| |_ _| | | | / ____| (_) | | | | | |
  4. | \| | ___ __| | ___ | | (___ | | __| | | ___ | (___ ___ _ __ _ _ __ | |_ | |__ _ _ | | _ _ _ __ __ ____ _ __ _
  5. | . ` |/ _ \ / _` |/ _ \_ | |\___ \ | | / _` | |/ _ \ \___ \ / __| '__| | '_ \| __| | '_ \| | | | | | | | | | '_ \\ \/ / _` |/ _` |
  6. | |\ | (_) | (_| | __/ |__| |____) | _| || (_| | | __/ ____) | (__| | | | |_) | |_ | |_) | |_| | | |___| |_| | | | |> < (_| | (_| |
  7. |_| \_|\___/ \__,_|\___|\____/|_____/ |_____\__,_|_|\___| |_____/ \___|_| |_| .__/ \__| |_.__/ \__, | |______\__, |_| |_/_/\_\__,_|\__,_|
  8. | | __/ | __/ |
  9. |_| |___/ |___/
  10. */
  11.  
  12. // npm install steam@v0.6.8
  13. var steam = require('steam');
  14. var fs = require('fs');
  15. // npm install readline-sync
  16. var readlineSync = require('readline-sync');
  17.  
  18. // request an auth code from the user, this freezes any other progress until a response is received
  19. var promptAuthCode = function(account) {
  20. var code = readlineSync.question('[STEAM][' + account.username + '][AUTHCODE]: Enter authcode: ');
  21. account.authcode = code;
  22. }
  23.  
  24. // just for swagger
  25. var shuffleArray = function(array) {
  26. for (var i = array.length - 1; i > 0; i--) {
  27. var j = Math.floor(Math.random() * (i + 1));
  28. var temp = array[i];
  29. array[i] = array[j];
  30. array[j] = temp;
  31. }
  32.  
  33. return array;
  34. }
  35.  
  36. // accounts array, you can move this into another file if you want
  37. // if you move it to a different file you'll need to do var ... = require(...)
  38. // to access the array.
  39. var accounts = [
  40. {
  41. username: "",
  42. password: "",
  43. games: [
  44. 730,
  45. 570,
  46. 440,
  47. 363970,
  48. 333930,
  49. 227700
  50. ],
  51. loggedIn: false
  52. }
  53. ];
  54.  
  55. var build = function() {
  56. for (var index in accounts) {
  57. buildBot(index);
  58. }
  59. }
  60.  
  61. var buildBot = function(index) {
  62. var account = accounts[index];
  63. var username = account.username;
  64. var password = account.password;
  65. var authcode = account.authcode;
  66. var sentryFileHash = new Buffer(username).toString('base64');
  67. var bot = new steam.SteamClient();
  68.  
  69. if (fs.existsSync(sentryFileHash)) {
  70. var sentry = fs.readFileSync(sentryFileHash);
  71. console.log("[STEAM][" + username + "]: Logging in with sentry. (" + sentryFileHash + ")");
  72. bot.logOn({
  73. accountName: username,
  74. password: password,
  75. shaSentryfile: sentry
  76. });
  77. } else {
  78. console.log("[STEAM][" + username + "]: Logging in without sentry.");
  79. bot.logOn({
  80. accountName: username,
  81. password: password,
  82. authCode: authcode
  83. });
  84. }
  85.  
  86. bot.on('loggedOn', function() {
  87. console.log("[STEAM][" + username + "]: Logged In.");
  88. account.loggedIn = true;
  89. bot.setPersonaState(steam.EPersonaState.Online); // our bot needs to be in an online state for our idling to work.
  90. bot.gamesPlayed(shuffleArray(account.games)); // idle games
  91.  
  92. setInterval(function() {
  93. //
  94. if (account.loggedIn) {
  95. try {
  96. console.log("[STEAM][" + username + "]: Changing games");
  97. bot.gamesPlayed([]); // empty array, we aren't playing anything.
  98. bot.gamesPlayed(shuffleArray(account.games));
  99. } catch (ex) {}
  100. }
  101. //
  102. }, 7200000); // 2 hours
  103. });
  104.  
  105. bot.on('sentry', function(sentryHash) {
  106. console.log("[STEAM][" + username + "]: Received sentry file.");
  107. fs.writeFile(sentryFileHash, sentryHash, function(err) {
  108. if (err){
  109. console.log("[STEAM][" + username + "]: " + err);
  110. } else {
  111. console.log("[STEAM][" + username + "]: Wrote sentry file.");
  112. }
  113. });
  114. });
  115.  
  116. bot.on('error', function(e) {
  117. if (e.eresult == steam.EResult.InvalidPassword) {
  118. console.log("[STEAM][" + username + "]: " + 'Login Failed. Reason: invalid password');
  119. } else if (e.eresult == steam.EResult.AlreadyLoggedInElsewhere) {
  120. console.log("[STEAM][" + username + "]: " + 'Login Failed. Reason: already logged in elsewhere');
  121. } else if (e.eresult == steam.EResult.AccountLogonDenied) {
  122. console.log("[STEAM][" + username + "]: " + 'Login Failed. Reason: logon denied - steam guard needed');
  123. promptAuthCode(accounts[index]);
  124. buildBot(index);
  125. } else {
  126. if (account.loggedIn) {
  127. account.loggedIn = false;
  128. bot.logOff();
  129. // change log in status to false to prevent exceptions
  130. // a logout reason of 'unknown' happens when ever you cannot access the account
  131. // or when you're logged out.
  132. console.log("[STEAM][" + username + "]: -----------------------------------------------------------");
  133. console.log("[STEAM][" + username + "]: Cannot log in at this time.");
  134. console.log("[STEAM][" + username + "]: !!! The script will try to log in again in 5 minutes. !!!");
  135. console.log("[STEAM][" + username + "]: If you're currently logged into the account log out.");
  136. console.log("[STEAM][" + username + "]: You are able to log into an account whilst it's idling, just don't play games.");
  137. setTimeout(function() {
  138. // try again.
  139. buildBot(index);
  140. }, 300000);
  141. console.log("[STEAM][" + username + "]: -----------------------------------------------------------");
  142. } else {
  143. console.log("[STEAM][" + username + "]: Login Failed. Reason: " + e.eresult);
  144. }
  145. }
  146. });
  147. }
  148.  
  149. // run the idle script.
  150. build();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement