Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = 'moorhuhn_private1'; // Bot's Steam Username
- password = 'aA135246'; // Bot's Steam Password
- var steam = require('steam');
- var steamtrade = require('steam-trade');
- var fs = require('fs');
- var winston = require('winston');
- var readline = require('readline');
- var level = require('level');
- var appid = {
- TF2: 440,
- Steam: 753
- };
- var contextid = {
- TF2: 2,
- Steam: 6
- }
- var inTrade = false;
- var myBackpack;
- 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
- })
- ]
- });
- var client = new steam.SteamClient();
- var trade = new steamtrade();
- var dbusersfriends(~/Desktop/bot/dbusersfriends);
- var dbusersstatus(~/Desktop/bot/dbusersstatus);
- if(fs.existsSync('servers.json')) {
- steam.servers = JSON.parse(fs.readFileSync('servers.json'));
- }
- // We can provide a sentry file for Steam Guard when we login to avoid
- // having to enter a code each time. If we have one saved to file, use it.
- var sentryfile;
- if(fs.existsSync('sentryfile.' + username + '.hash')) {
- sentryfile = fs.readFileSync('sentryfile.' + username + '.hash');
- }
- // Now we can finally start doing stuff! Let's try logging in.
- client.logOn({
- accountName: username,
- password: password,
- shaSentryfile: sentryfile // If null, a new Steam Guard code will be requested
- });
- // If Steam returns an error the "error" event is emitted.
- // We can deal with some of them.
- // See docs on Event Emitter to understand how this works:
- // http://nodejs.org/api/events.html
- 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: username,
- password: password,
- 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);
- }
- });
- 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("Hans");
- 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('friend', function(steamID, relationship) {
- if (relationship == steam.EFriendRelationship.PendingInvitee) {
- logger.info('[' + steamID + '] Accepted friend request');
- setTimeout(function(){ client.addFriend(steamID); }, 4000);
- setTimeout(function(){ client.sendMessage(steamID, 'Hi. I am the Happy Raffles and Giveaways Inviting Helper.');}, 10000);
- 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);
- 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);
- setTimeout(function(){ client.sendMessage(steamID, 'Once you have invited you will be in the giveaway.');}, 34000);
- 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);
- setTimeout(function(){ client.sendMessage(steamID, 'How many of your friends are allready in the group? (you can see this on the group page)');}, 50000);
- }
- else if (relationship == steam.EFriendRelationship.None) {
- logger.info('[' + steamID + '] Un-friended');
- }
- });
- client.on('friendMsg', function(steamID, message, type) {
- if (type == steam.EChatEntryType.ChatMsg) { // Regular chat message
- logger.info('[' + steamID + '] MSG: ' + message); // Log it
- client.sendMessage(steamID, '');
- }
- });
- // If a user sends a trade request...
- client.on('tradeProposed', function(tradeID, steamID) {
- if (inTrade) {
- client.respondToTrade(tradeID, false); // Decline
- client.sendMessage(steamID, 'I\'m currently trading with someone else.');
- } else {
- client.respondToTrade(tradeID, true); // Accept
- logger.info('[' + steamID + '] Accepted trade request');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement