Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
1,653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. var SteamUser = require('steam-user');
  2. var SteamTotp = require('steam-totp');
  3. var botFactory = {};
  4.  
  5. botFactory.buildBot = function (config)
  6. {
  7. var bot = new SteamUser({
  8. promptSteamGuardCode: false,
  9. dataDirectory: "./sentry",
  10. singleSentryfile: false
  11. });
  12.  
  13. bot.username = config.username;
  14. bot.password = config.password;
  15. bot.sharedSecret = config.sharedSecret;
  16. bot.games = config.games;
  17. bot.messageReceived = {};
  18.  
  19. bot.on('loggedOn', function(details) {
  20. console.log("[" + this.username + "] Logged into Steam as " + bot.steamID.getSteam3RenderedID());
  21. bot.setPersona(SteamUser.EPersonaState.Online);
  22. bot.gamesPlayed([730,303386]);
  23. bot.requestFreeLicense([303386,730], function(err, grantedPackages, grantedAppIDs){
  24. if(err){ console.log('303386 blad: '+err); }
  25. if(grantedAppIDs){ console.log('303386 grantedAppIDs: '+grantedAppIDs); }
  26. if(grantedPackages){ console.log('303386 grantedPackages: '+grantedPackages); }
  27. if(!err){ bot.gamesPlayed([730,303386]); }
  28. });
  29. bot.gamesPlayed([730,303386]);
  30. setTimeout(function(){ bot.gamesPlayed([730,303386]); }, 1000);
  31.  
  32. });
  33.  
  34. bot.on('error', function(e) {
  35. console.log("[" + this.username + "] " + e);
  36. setTimeout(function() {bot.doLogin();}, 30*60*1000);
  37. });
  38.  
  39. bot.doLogin = function ()
  40. {
  41. this.logOn({
  42. "accountName": this.username,
  43. "password": this.password
  44. });
  45. }
  46.  
  47. bot.on('steamGuard', function(domain, callback) {
  48. if ( !this.sharedSecret ) {
  49. var readlineSync = require('readline-sync');
  50. //var authCode = readlineSync.question("[" + this.username + "] " + 'Steam Guard' + (!domain ? ' App' : '') + ' Code: ');
  51. //callback(authCode);
  52. console.log('[' + this.username + '] Guard SKIP');
  53. }
  54. else {
  55. var authCode = SteamTotp.generateAuthCode( this.sharedSecret );
  56. console.log("[" + this.username + "] Generated Auth Code: " + authCode);
  57. callback(authCode);
  58. }
  59.  
  60. });
  61.  
  62. bot.on("friendMessage", function(steamID, message) {
  63. console.log("[" + this.username + "] Message from " + steamID+ ": " + message);
  64. if ( !this.messageReceived[steamID] ) {
  65. bot.chatMessage(steamID, "[Automated Message] I am currently idle. I will respond when I am next available.");
  66. this.messageReceived[steamID] = true;
  67. }
  68. });
  69.  
  70.  
  71. bot.on('vacBans', function(numBans, appids) {
  72. if(numBans > 0) {
  73. console.log( "[" + this.username + "] " + numBans + " VAC ban" + (numBans == 1 ? '' : 's') + "." +
  74. (appids.length == 0 ? '' : " In apps: " + appids.join(', ')) );
  75. }
  76. });
  77.  
  78. bot.on('accountLimitations', function(limited, communityBanned, locked, canInviteFriends) {
  79. var limitations = [];
  80.  
  81. if(limited) {
  82. limitations.push('LIMITED');
  83. }
  84.  
  85. if(communityBanned) {
  86. limitations.push('COMMUNITY BANNED');
  87. }
  88.  
  89. if(locked) {
  90. limitations.push('LOCKED');
  91. }
  92.  
  93. if(limitations.length !== 0) {
  94. console.log("[" + this.username + "] Limitations: " + limitations.join(', ') + ".");
  95. }
  96. });
  97.  
  98. return bot;
  99. }
  100.  
  101. module.exports = botFactory;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement