Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
1,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Steam = require("steam"),
  2.     util = require("util"),
  3.     fs = require("fs"),
  4.     csgo = require("csgo"),
  5.     Long = require("long"),
  6.     bot = new Steam.SteamClient(),
  7.     steamUser = new Steam.SteamUser(bot),
  8.     steamFriends = new Steam.SteamFriends(bot),
  9.     steamGC = new Steam.SteamGameCoordinator(bot, 730);
  10.     CSGOCli = new csgo.CSGOClient(steamUser, steamGC, false),
  11.     readlineSync = require("readline-sync"),
  12.     crypto = require("crypto");
  13.     SteamID64 = process.argv[2];
  14.  
  15. function MakeSha(bytes) {
  16.     var hash = crypto.createHash('sha1');
  17.     hash.update(bytes);
  18.     return hash.digest();
  19. }
  20.  
  21. var onSteamLogOn = function onSteamLogOn(response){
  22.         if (response.eresult == Steam.EResult.OK) {
  23.             console.log('Logged in!');
  24.         }
  25.         else
  26.         {
  27.             util.log('error, ', response);
  28.             process.exit();
  29.         }
  30.         steamFriends.setPersonaState(Steam.EPersonaState.Busy);
  31.  
  32.         CSGOCli.launch();
  33.  
  34.         CSGOCli.on("unhandled", function(message) {
  35.             util.log("Unhandled msg");
  36.             util.log(message);
  37.         });
  38.  
  39.         CSGOCli.on("ready", function() {
  40.             CSGOCli.requestLiveGameForUser(CSGOCli.ToAccountID(String(SteamID64)));
  41.             CSGOCli.on("matchList", function(list) {
  42.                if (list.matches && list.matches.length > 0) {
  43.                     var matchIDobj = JSON.parse(JSON.stringify(list.matches[0], null, 2));
  44.                     var matchID = new Long(matchIDobj.matchid.low, matchIDobj.matchid.high, matchIDobj.matchid.unsigned).toString();
  45.                     console.log("MatchID: ",matchID);
  46.                     fs.writeFile('playerMatchId.txt', matchID);
  47.                } else {
  48.                     console.log("Game not found!");
  49.                     fs.writeFile('playerMatchId.txt', "game_not_found");
  50.                }
  51.                
  52.                setTimeout(function() {process.exit();}, 2*1000);
  53.             });
  54.  
  55.  
  56.         });
  57.  
  58.         CSGOCli.on("unready", function onUnready(){
  59.             util.log("node-csgo unready.");
  60.         });
  61.  
  62.         CSGOCli.on("unhandled", function(kMsg) {
  63.             util.log("UNHANDLED MESSAGE " + kMsg);
  64.         });
  65.     },
  66.     onSteamSentry = function onSteamSentry(sentry) {
  67.         util.log("Received sentry.");
  68.         require('fs').writeFileSync('sentryMatchID', sentry);
  69.     }
  70.  
  71. var username = "";
  72. var password = "";
  73. var authCode = "";
  74.  
  75. var logOnDetails = {
  76.     "account_name": username,
  77.     "password": password,
  78. };
  79. if (authCode !== "") {
  80.     logOnDetails.auth_code = authCode;
  81. }
  82. var sentry = fs.readFileSync('sentryMatchID');
  83. if (sentry.length) {
  84.     logOnDetails.sha_sentryfile = MakeSha(sentry);
  85. }
  86. bot.connect();
  87. steamUser.on('updateMachineAuth', function(response, callback){
  88.     fs.writeFileSync('sentryMatchID', response.bytes);
  89.     callback({ sha_file: MakeSha(response.bytes) });
  90. });
  91. bot.on("logOnResponse", onSteamLogOn)
  92.     .on('sentry', onSteamSentry)
  93.     .on('connected', function(){
  94.         steamUser.logOn(logOnDetails);
  95.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement