Guest User

Untitled

a guest
May 12th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1.  
  2. username = 'my username'; // Bot's Steam Username
  3. password = 'my password'; // Bot's Steam Password
  4.  
  5. // Define all our included variables
  6. var steam = require('steam');
  7. var steamtrade = require('steam-trade');
  8. var winston = require('winston');
  9. var readline = require('readline');
  10. var fs = require('fs');
  11.  
  12.  
  13. var appid = {
  14. TF2: 440,
  15. Steam: 753
  16. };
  17.  
  18. var contextid = {
  19. TF2: 2,
  20. Steam: 6
  21. }
  22.  
  23.  
  24. var rl = readline.createInterface({
  25. input: process.stdin,
  26. output: process.stdout
  27. });
  28.  
  29.  
  30. var logger = new (winston.Logger)({
  31. transports: [
  32. new (winston.transports.Console)({
  33. colorize: true,
  34. level: 'debug'
  35. }),
  36. new (winston.transports.File)({
  37. level: 'info',
  38. timestamp: true,
  39. filename: 'cratedump.log',
  40. json: false
  41. })
  42. ]
  43. });
  44.  
  45. // Initialize the Steam client and our trading library
  46. var client = new steam.SteamClient();
  47. var trade = new steamtrade();
  48.  
  49. if(fs.existsSync('servers.json')) {
  50. steam.servers = JSON.parse(fs.readFileSync('servers.json'));
  51. }
  52.  
  53. if(fs.existsSync('sentryfile.' + username + '.hash')) {
  54. sentryfile = fs.readFileSync('sentryfile.' + username + '.hash');
  55. }
  56.  
  57.  
  58. client.logOn({
  59. accountName: 'my username',
  60. password: 'my password',
  61. shaSentryfile: sentryfile // If null, a new Steam Guard code will be requested
  62. });
  63.  
  64. client.on('error', function(e) {
  65. // Error code for invalid Steam Guard code
  66. if (e.eresult == steam.EResult.AccountLogonDenied) {
  67. // Prompt the user for Steam Gaurd code
  68. rl.question('Steam Guard Code: ', function(code) {
  69. // Try logging on again
  70. client.logOn({
  71. accountName: 'datvagoss',
  72. password: '1234512345bot',
  73. authCode: code
  74. });
  75. });
  76. } else { // For simplicity, we'll just log anything else.
  77. // A list of ENUMs can be found here:
  78. // https://github.com/SteamRE/SteamKit/blob/d0114b0cc8779dff915c4d62e0952cbe32202289/Resources/SteamLanguage/eresult.steamd
  79. logger.error('Steam Error: ' + e.eresult);
  80. // Note: Sometimes Steam returns InvalidPassword (5) for valid passwords.
  81. // Simply trying again solves the problem a lot of the time.
  82. }
  83. });
  84.  
  85. client.on('sentry', function(sentry) {
  86. logger.info('Got new sentry file hash from Steam. Saving.');
  87. fs.writeFile('sentryfile.' + username + '.hash', sentry);
  88. });
  89.  
  90. client.on('loggedOn', function() {
  91. logger.info('Logged on to Steam');
  92. client.setPersonaName("DevBot");
  93. client.setPersonaState(steam.EPersonaState.Offline);
  94. });
  95.  
  96.  
  97. client.on('webSessionID', function(sessionid) {
  98. trade.sessionID = sessionid; // Share the session between libraries
  99. client.webLogOn(function(cookie) {
  100. cookie.forEach(function(part) { // Share the cookie between libraries
  101. trade.setCookie(part.trim()); // Now we can trade!
  102. });
  103. logger.info('Logged into web');
  104. // No longer appear offline
  105. client.setPersonaState(steam.EPersonaState.LookingToTrade);
  106. });
  107. });
  108.  
  109. client.on("message", function(steamID, message){
  110.  
  111. var messageD = message.toLowerCase().split(" ");
  112.  
  113. if(messageD[0] == "Hey"){
  114. client.sendMessage(steamID, "Bleep Blop");
  115. }
  116.  
  117. });
Add Comment
Please, Sign In to add comment