Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = 'my username'; // Bot's Steam Username
- password = 'my password'; // Bot's Steam Password
- // Define all our included variables
- var steam = require('steam');
- var steamtrade = require('steam-trade');
- var winston = require('winston');
- var readline = require('readline');
- var fs = require('fs');
- var appid = {
- TF2: 440,
- Steam: 753
- };
- var contextid = {
- TF2: 2,
- Steam: 6
- }
- var rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- var logger = new (winston.Logger)({
- transports: [
- new (winston.transports.Console)({
- colorize: true,
- level: 'debug'
- }),
- new (winston.transports.File)({
- level: 'info',
- timestamp: true,
- filename: 'cratedump.log',
- json: false
- })
- ]
- });
- // Initialize the Steam client and our trading library
- var client = new steam.SteamClient();
- var trade = new steamtrade();
- if(fs.existsSync('servers.json')) {
- steam.servers = JSON.parse(fs.readFileSync('servers.json'));
- }
- if(fs.existsSync('sentryfile.' + username + '.hash')) {
- sentryfile = fs.readFileSync('sentryfile.' + username + '.hash');
- }
- client.logOn({
- accountName: 'my username',
- password: 'my password',
- shaSentryfile: sentryfile // If null, a new Steam Guard code will be requested
- });
- client.on('error', function(e) {
- // Error code for invalid Steam Guard code
- if (e.eresult == steam.EResult.AccountLogonDenied) {
- // Prompt the user for Steam Gaurd code
- rl.question('Steam Guard Code: ', function(code) {
- // Try logging on again
- client.logOn({
- accountName: 'datvagoss',
- password: '1234512345bot',
- authCode: code
- });
- });
- } else { // For simplicity, we'll just log anything else.
- // A list of ENUMs can be found here:
- // https://github.com/SteamRE/SteamKit/blob/d0114b0cc8779dff915c4d62e0952cbe32202289/Resources/SteamLanguage/eresult.steamd
- logger.error('Steam Error: ' + e.eresult);
- // Note: Sometimes Steam returns InvalidPassword (5) for valid passwords.
- // Simply trying again solves the problem a lot of the time.
- }
- });
- client.on('sentry', function(sentry) {
- logger.info('Got new sentry file hash from Steam. Saving.');
- fs.writeFile('sentryfile.' + username + '.hash', sentry);
- });
- client.on('loggedOn', function() {
- logger.info('Logged on to Steam');
- client.setPersonaName("DevBot");
- client.setPersonaState(steam.EPersonaState.Offline);
- });
- client.on('webSessionID', function(sessionid) {
- trade.sessionID = sessionid; // Share the session between libraries
- client.webLogOn(function(cookie) {
- cookie.forEach(function(part) { // Share the cookie between libraries
- trade.setCookie(part.trim()); // Now we can trade!
- });
- logger.info('Logged into web');
- // No longer appear offline
- client.setPersonaState(steam.EPersonaState.LookingToTrade);
- });
- });
- client.on("message", function(steamID, message){
- var messageD = message.toLowerCase().split(" ");
- if(messageD[0] == "Hey"){
- client.sendMessage(steamID, "Bleep Blop");
- }
- });
Add Comment
Please, Sign In to add comment