Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var crypto = require( "crypto" );
- var csgo = require( "csgo" );
- var fs = require( "fs" );
- var readlineSync = require( "readline-sync" );
- var Steam = require( "steam" );
- var SteamClient = new Steam.SteamClient();
- var SteamFriends = new Steam.SteamFriends( SteamClient );
- var SteamGameCoordinator = new Steam.SteamGameCoordinator( SteamClient, 730 );
- var SteamUser = new Steam.SteamUser( SteamClient );
- var CSGOClient = new csgo.CSGOClient( SteamUser, SteamGameCoordinator, false );
- var args = process.argv.slice( 2 );
- var username = args[0];
- var password = args[1];
- var auth_code = args[2];
- var two_factor_code = "";
- var sentryfile = username + ".sentryfile";
- SteamClient.connect();
- SteamClient.on( "connected", function() {
- if ( fs.existsSync( sentryfile ) )
- {
- var logOnOptions = {
- account_name: username,
- password: password,
- sha_sentryfile: getSHA1( fs.readFileSync( sentryfile ) )
- };
- if ( two_factor_code == "" )
- console.log( "Logging in with a sentry file..." );
- else
- logOnOptions["two_factor_code"] = two_factor_code;
- SteamUser.logOn( logOnOptions );
- }
- else
- {
- console.log( "Logging in without a sentry file..." );
- var logOnOptions = {
- account_name: username,
- password: password
- };
- if ( auth_code != "" )
- logOnOptions["auth_code"] = auth_code;
- if ( two_factor_code != "" )
- logOnOptions["two_factor_code"] = two_factor_code;
- SteamUser.logOn( logOnOptions );
- }
- } );
- SteamClient.on( "logOnResponse", function( e ) {
- if ( e.eresult == Steam.EResult.OK )
- {
- console.log( "Logged in!" );
- SteamFriends.setPersonaState( Steam.EPersonaState.Offline );
- CSGOClient.launch();
- CSGOClient.on( "ready", function() {
- console.log( "node-csgo is ready!\n" );
- var Command = args[3];
- var SteamID = parseInt( args[4], 10 );
- if ( Command == "report" )
- {
- console.log( "Reporting " + SteamID + "..." );
- CSGOClient.reportPlayer( SteamID, 1, 1, 1, 1, 1, 1, 0 );
- }
- else if ( Command == "commend" )
- {
- console.log( "Commending " + SteamID + "..." );
- CSGOClient.commendPlayer( SteamID, 0, 1, 1, 1, 0 );
- }
- else
- {
- console.log( Command + " is not a valid command. Valid commands are report and commend." );
- // Use setTimeout?
- SteamClient.disconnect();
- }
- } );
- }
- else if ( e.eresult == Steam.EResult.InvalidPassword )
- console.log( "Login failed: Invalid password." );
- else if ( e.eresult == Steam.EResult.AlreadyLoggedInElsewhere )
- console.log( "Login failed: Already logged in elsewhere." );
- else if ( e.eresult == Steam.EResult.AccountLogonDenied )
- console.log( "Login failed: No SteamGuard code." );
- else if ( e.eresult == Steam.EResult.InvalidLoginAuthCode )
- console.log( "Login failed: Invalid SteamGuard code." );
- else if ( e.eresult == Steam.EResult.AccountLogonDeniedNeedTwoFactorCode )
- {
- two_factor_code = readlineSync.question( "Mobile auth code needed for " + username + ". Type it here: " );
- SteamClient.connect();
- }
- else
- console.log( "Login failed: " + e.eresult );
- } );
- CSGOClient.on( "reportResponse", function( message )
- {
- var Command = "commend player.";
- if ( message.response_type == csgo.ECSGOCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer )
- Command = "report player.";
- if ( message.response_result )
- console.log( "Succeeded to " + Command );
- else
- console.log( "Failed to " + Command );
- // Use setTimeout?
- SteamClient.disconnect();
- } );
- SteamClient.on( "error", function( e ) {
- } );
- SteamUser.on( "updateMachineAuth", function( sentry, callback ) {
- fs.writeFileSync( sentryfile, sentry.bytes );
- console.log( "Saved the sentry file." );
- callback( {
- sha_file: getSHA1( sentry.bytes )
- } );
- } );
- function getSHA1( bytes ) {
- var hash = crypto.createHash( "sha1" );
- hash.update( bytes );
- return hash.digest();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement