Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.51 KB | None | 0 0
  1. username = 'moorhuhn_private1'; // Bot's Steam Username
  2. password = 'aA135246'; // Bot's Steam Password
  3.  
  4. var steam = require('steam');
  5. var steamtrade = require('steam-trade');
  6. var fs = require('fs');
  7. var winston = require('winston');
  8. var readline = require('readline');
  9. var level = require('level');
  10.  
  11. var appid = {
  12. TF2: 440,
  13. Steam: 753
  14. };
  15. var contextid = {
  16. TF2: 2,
  17. Steam: 6
  18. }
  19.  
  20. var inTrade = false;
  21.  
  22. var myBackpack;
  23.  
  24. var rl = readline.createInterface({
  25. input: process.stdin,
  26. output: process.stdout
  27. });
  28.  
  29. var logger = new (winston.Logger)({
  30. transports: [
  31. new (winston.transports.Console)({
  32. colorize: true,
  33. level: 'debug'
  34. }),
  35. new (winston.transports.File)({
  36. level: 'info',
  37. timestamp: true,
  38. filename: 'cratedump.log',
  39. json: false
  40. })
  41. ]
  42. });
  43.  
  44. var client = new steam.SteamClient();
  45. var trade = new steamtrade();
  46. var dbusersfriends(~/Desktop/bot/dbusersfriends);
  47. var dbusersstatus(~/Desktop/bot/dbusersstatus);
  48.  
  49.  
  50. if(fs.existsSync('servers.json')) {
  51. steam.servers = JSON.parse(fs.readFileSync('servers.json'));
  52. }
  53.  
  54. // We can provide a sentry file for Steam Guard when we login to avoid
  55. // having to enter a code each time. If we have one saved to file, use it.
  56. var sentryfile;
  57. if(fs.existsSync('sentryfile.' + username + '.hash')) {
  58. sentryfile = fs.readFileSync('sentryfile.' + username + '.hash');
  59. }
  60.  
  61. // Now we can finally start doing stuff! Let's try logging in.
  62. client.logOn({
  63. accountName: username,
  64. password: password,
  65. shaSentryfile: sentryfile // If null, a new Steam Guard code will be requested
  66. });
  67.  
  68. // If Steam returns an error the "error" event is emitted.
  69. // We can deal with some of them.
  70. // See docs on Event Emitter to understand how this works:
  71. // http://nodejs.org/api/events.html
  72. client.on('error', function(e) {
  73. // Error code for invalid Steam Guard code
  74. if (e.eresult == steam.EResult.AccountLogonDenied) {
  75. // Prompt the user for Steam Gaurd code
  76. rl.question('Steam Guard Code: ', function(code) {
  77. // Try logging on again
  78. client.logOn({
  79. accountName: username,
  80. password: password,
  81. authCode: code
  82. });
  83. });
  84. } else { // For simplicity, we'll just log anything else.
  85. // A list of ENUMs can be found here:
  86. // https://github.com/SteamRE/SteamKit/blob/d0114b0cc8779dff915c4d62e0952cbe32202289/Resources/SteamLanguage/eresult.steamd
  87. logger.error('Steam Error: ' + e.eresult);
  88. }
  89. });
  90.  
  91. client.on('sentry', function(sentry) {
  92. logger.info('Got new sentry file hash from Steam. Saving.');
  93. fs.writeFile('sentryfile.' + username + '.hash', sentry);
  94. });
  95.  
  96. client.on('loggedOn', function() {
  97. logger.info('Logged on to Steam');
  98. client.setPersonaName("Hans");
  99. client.setPersonaState(steam.EPersonaState.Offline);
  100. });
  101.  
  102.  
  103. client.on('webSessionID', function(sessionid) {
  104. trade.sessionID = sessionid; // Share the session between libraries
  105. client.webLogOn(function(cookie) {
  106. cookie.forEach(function(part) { // Share the cookie between libraries
  107. trade.setCookie(part.trim()); // Now we can trade!
  108. });
  109. logger.info('Logged into web');
  110. // No longer appear offline
  111. client.setPersonaState(steam.EPersonaState.LookingToTrade);
  112. });
  113. });
  114.  
  115. client.on('friend', function(steamID, relationship) {
  116. if (relationship == steam.EFriendRelationship.PendingInvitee) {
  117. logger.info('[' + steamID + '] Accepted friend request');
  118. setTimeout(function(){ client.addFriend(steamID); }, 4000);
  119. setTimeout(function(){ client.sendMessage(steamID, 'Hi. I am the Happy Raffles and Giveaways Inviting Helper.');}, 10000);
  120. setTimeout(function(){ client.sendMessage(steamID, 'I am here because steam lets a hole group only invite 250 friends in two hours. Every invite that exceeds the limit does not get trough.');}, 18000);
  121. setTimeout(function(){ client.sendMessage(steamID, 'To grow better and to invite more people, I will tell people you when you may invite friends. You then have time to answer and invite your friends.');}, 28000);
  122. setTimeout(function(){ client.sendMessage(steamID, 'Once you have invited you will be in the giveaway.');}, 34000);
  123. setTimeout(function(){ client.sendMessage(steamID, 'I am a BOT so please dont ask questions. If something is wrong, add the admin Consoco about it. Thank you.');}, 42000);
  124. setTimeout(function(){ client.sendMessage(steamID, 'How many of your friends are allready in the group? (you can see this on the group page)');}, 50000);
  125. }
  126. else if (relationship == steam.EFriendRelationship.None) {
  127. logger.info('[' + steamID + '] Un-friended');
  128. }
  129. });
  130.  
  131. client.on('friendMsg', function(steamID, message, type) {
  132. if (type == steam.EChatEntryType.ChatMsg) { // Regular chat message
  133. logger.info('[' + steamID + '] MSG: ' + message); // Log it
  134. client.sendMessage(steamID, '');
  135. }
  136. });
  137.  
  138. // If a user sends a trade request...
  139. client.on('tradeProposed', function(tradeID, steamID) {
  140. if (inTrade) {
  141. client.respondToTrade(tradeID, false); // Decline
  142. client.sendMessage(steamID, 'I\'m currently trading with someone else.');
  143. } else {
  144. client.respondToTrade(tradeID, true); // Accept
  145. logger.info('[' + steamID + '] Accepted trade request');
  146. }
  147. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement