AnonymousBOL

[NodeJS] Steam hours idling

Dec 2nd, 2015
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //NoobKillerPL for UnknownCheats.me
  2. var Steam = require('steam');
  3.  
  4. //define accounts, ONLY NO STEAMGUARD SUPPORTED!!
  5. var accounts = [
  6.     {
  7.         nickname: "John // AFK #1",
  8.         username: "yourlogin",
  9.         password: "yourpassword",
  10.         loggedIn: false
  11.     },
  12.     {
  13.         nickname: "John // AFK #2",
  14.         username: "yourlogin",
  15.         password: "yourpassword",
  16.         loggedIn: false
  17.     },
  18.     {
  19.         nickname: "John // AFK #3",
  20.         username: "yourlogin",
  21.         password: "yourpassword",
  22.         loggedIn: false
  23.     },
  24.     {
  25.         nickname: "John // AFK #4",
  26.         username: "yourlogin",
  27.         password: "yourpassword",
  28.         loggedIn: false
  29.     }
  30. ];
  31.  
  32. function randomInt(low, high) {
  33.     return Math.floor(Math.random() * (high - low + 1) + low);
  34. }
  35.  
  36. var RunAccount = function(index)
  37. {
  38.     var indx = index;
  39.     var account = accounts[index];
  40.     var nickname = account.nickname;
  41.     var username = account.username;
  42.     var password = account.password;
  43.    
  44.     console.log('[' + username + '][' + indx + '] Initializing...');
  45.    
  46.     var sClient = new Steam.SteamClient();
  47.     var sUser = new Steam.SteamUser(sClient);
  48.     var sFriends = new Steam.SteamFriends(sClient);
  49.    
  50.     var AlreadyNotifiedUsers = {}; //map for messages
  51.     var HandledError = false;
  52.    
  53.     sClient.connect();
  54.    
  55.     sClient.on('connected', function() {
  56.         sUser.logOn({
  57.             account_name: username,
  58.             password: password,
  59.         });
  60.     });
  61.    
  62.     sClient.on('logOnResponse', function(logonResp)
  63.     {
  64.         if (logonResp.eresult == Steam.EResult.OK)
  65.         {
  66.             console.log('[' + username + '] Logged in!');
  67.             sFriends.setPersonaName(nickname);
  68.             sFriends.setPersonaState(Steam.EPersonaState.Online);
  69.            
  70.             sUser.gamesPlayed({
  71.                 games_played: [{
  72.                   game_id: '730'
  73.                 },
  74.                 {
  75.                   game_id: '440'
  76.                 },
  77.                 {
  78.                   game_id: '227700'
  79.                 }]
  80.             });
  81.            
  82.             var IdlingTime = randomInt(3600000, 7200000);
  83.             var TrueTime = IdlingTime / 60 / 60 / 1000;
  84.             console.log('[' + username + '] Idling for ' + TrueTime + ' hours!');
  85.             setTimeout(function(index) {
  86.                 if (!HandledError)
  87.                 {
  88.                     HandledError = true;
  89.                     sClient.disconnect();
  90.                     RunAccount(index);
  91.                 }
  92.             }, IdlingTime|0, indx); //1 hour delay
  93.         }
  94.         else
  95.         {
  96.             console.log('[' + username + '] Error! :( Reconnecting in 5 minutes...');
  97.             if (!HandledError)
  98.             {
  99.                 HandledError = true;
  100.                 setTimeout(function(index) {
  101.                     sClient.disconnect();
  102.                     RunAccount(index);
  103.                 }, 300000|0, indx);
  104.             }
  105.         }
  106.     });
  107.    
  108.     sClient.on('error', function(e) {
  109.         if (e.eresult == Steam.EResult.InvalidPassword) {
  110.             console.log('[' + username + '] Login Failed. Invalid password!');
  111.         } else if (e.eresult == Steam.EResult.AlreadyLoggedInElsewhere) {
  112.             console.log('[' + username + '] Login Failed. You are already logged in elsewhere.');
  113.             if (!HandledError)
  114.             {
  115.                 HandledError = true;
  116.                 setTimeout(function(index) {
  117.                     sClient.disconnect();
  118.                     RunAccount(index);
  119.                 }, 300000|0, indx);
  120.             }
  121.         } else if (e.eresult == Steam.EResult.AccountLogonDenied) {
  122.             console.log('[' + username + '] Login Failed. Denied by steam. (SteamGuard?)');
  123.         }
  124.         else
  125.         {
  126.             console.log('[' + username + '] Login Failed. ' + e);
  127.             if (!HandledError)
  128.             {
  129.                 HandledError = true;
  130.                 setTimeout(function(index) {
  131.                     sClient.disconnect();
  132.                     RunAccount(index);
  133.                 }, 600000|0, indx);
  134.             }
  135.         }
  136.     });
  137.    
  138.     sFriends.on('friend', function(source, action)
  139.     {
  140.         if (action == Steam.EFriendRelationship.RequestRecipient)
  141.         {
  142.             console.log('[' + username + '] Invited to friends by ' + source + '!');
  143.             sFriends.addFriend(source);
  144.             sFriends.sendMessage(source, 'I am currently AFK. Sorry :(', Steam.EChatEntryType.ChatMsg);
  145.             AlreadyNotifiedUsers[source] = true;
  146.         }
  147.     });
  148.    
  149.     sFriends.on('friendMsg', function(source, message, type, chatter)
  150.     {
  151.         if (type == Steam.EChatEntryType.ChatMsg)
  152.         {
  153.             console.log('[' + username + '] Chat (' + source + '): ' + message);
  154.             if (!AlreadyNotifiedUsers[source])
  155.             {
  156.                 sFriends.sendMessage(source, 'I am currently AFK. Sorry :(', Steam.EChatEntryType.ChatMsg);
  157.                 AlreadyNotifiedUsers[source] = true;
  158.             }
  159.         }
  160.     });
  161. }
  162.  
  163. var build = function() {
  164.     for (var index in accounts) {
  165.         RunAccount(index);
  166.     }
  167. }
  168. build();
Advertisement
Add Comment
Please, Sign In to add comment