Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
2,438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. var Steam = require("steam"),
  2. util = require("util"),
  3. fs = require("fs"),
  4. csgo = require("csgo"),
  5. bot = new Steam.SteamClient(),
  6. steamUser = new Steam.SteamUser(bot),
  7. steamFriends = new Steam.SteamFriends(bot),
  8. steamGC = new Steam.SteamGameCoordinator(bot, 730),
  9. CSGOCli = new csgo.CSGOClient(steamUser, steamGC, false),
  10. readlineSync = require("readline-sync"),
  11. crypto = require("crypto");
  12.  
  13. function MakeSha(bytes) {
  14. var hash = crypto.createHash('sha1');
  15. hash.update(bytes);
  16. return hash.digest();
  17. }
  18.  
  19. var onSteamLogOn = function onSteamLogOn(response) {
  20. if (response.eresult == Steam.EResult.OK) {
  21. util.log('Logged in!');
  22. }
  23. else {
  24. util.log('error, ', response);
  25. process.exit();
  26. }
  27. steamFriends.setPersonaState(Steam.EPersonaState.Busy);
  28. util.log("Logged on.");
  29.  
  30. util.log("Current SteamID64: " + bot.steamID);
  31. util.log("Account ID: " + CSGOCli.ToAccountID(bot.steamID));
  32.  
  33. CSGOCli.launch();
  34.  
  35. CSGOCli.on("unhandled", function (message) {
  36. util.log("Unhandled msg");
  37. util.log(message);
  38. });
  39.  
  40. CSGOCli.on("ready", function () {
  41. util.log("node-csgo ready.");
  42.  
  43. CSGOCli.matchmakingStatsRequest();
  44. CSGOCli.on("matchmakingStatsData", function (matchmakingStatsResponse) {
  45. util.log("Avg. Wait Time: " + matchmakingStatsResponse.global_stats.search_time_avg);
  46. util.log("Players Online: " + matchmakingStatsResponse.global_stats.players_online);
  47. util.log("Players Searching: " + matchmakingStatsResponse.global_stats.players_searching);
  48. util.log("Servers Online: " + matchmakingStatsResponse.global_stats.servers_online);
  49. util.log("Servers Available: " + matchmakingStatsResponse.global_stats.servers_available);
  50. util.log("Matches in Progress: " + matchmakingStatsResponse.global_stats.ongoing_matches);
  51. console.log(JSON.stringify(matchmakingStatsResponse, null, 4));
  52.  
  53. CSGOCli.playerProfileRequest(CSGOCli.ToAccountID(bot.steamID));
  54. CSGOCli.on("playerProfile", function (profile) {
  55. console.log("Profile");
  56. console.log("Player Rank: " + CSGOCli.Rank.getString(profile.account_profiles[0].ranking.rank_id))
  57. console.log(JSON.stringify(profile, null, 2));
  58. });
  59.  
  60. CSGOCli.requestRecentGames();
  61. CSGOCli.on("matchList", function (list) {
  62. console.log("Match List");
  63. if (list.matches && list.matches.length > 0) {
  64. console.log(list.matches[0]);
  65. }
  66. });
  67.  
  68. CSGOCli.richPresenceUpload({
  69. RP: {
  70. status: "Hello World!", // Sets rich presence text to "Hello World!"
  71. version: 13503, // Not sure what this value does
  72. time: 161.164087 // This might be the amount of time since you have started the game, not sure.
  73. }
  74. });
  75.  
  76. // steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198084749846A6768147729D12557175561287951743
  77. CSGOCli.itemDataRequest("76561198084749846", "6768147729", "12557175561287951743", "0");
  78.  
  79. CSGOCli.on("itemData", function (itemdata) {
  80. console.log(itemdata);
  81. });
  82. });
  83. });
  84.  
  85. CSGOCli.on("unready", function onUnready() {
  86. util.log("node-csgo unready.");
  87. });
  88.  
  89. CSGOCli.on("unhandled", function (kMsg) {
  90. util.log("UNHANDLED MESSAGE " + kMsg);
  91. });
  92. },
  93. onSteamSentry = function onSteamSentry(sentry) {
  94. util.log("Received sentry.");
  95. require('fs').writeFileSync('sentry', sentry);
  96. },
  97. onSteamServers = function onSteamServers(servers) {
  98. util.log("Received servers.");
  99. fs.writeFile('servers.json', JSON.stringify(servers, null, 2));
  100. };
  101.  
  102. // var username = readlineSync.question('Username: ');
  103. // var password = readlineSync.question('Password: ', {noEchoBack: true});
  104. var authCode = readlineSync.question('AuthCode: ');
  105.  
  106. var logOnDetails = {
  107. "account_name": 'xxx',
  108. "password": 'xxx'
  109. };
  110. if (authCode !== "") {
  111. logOnDetails.two_factor_code = authCode;
  112. }
  113.  
  114. var sentry = fs.readFileSync('sentry');
  115. if (sentry.length) {
  116. logOnDetails.sha_sentryfile = MakeSha(sentry);
  117. }
  118. bot.connect();
  119. steamUser.on('updateMachineAuth', function (response, callback) {
  120. fs.writeFileSync('sentry', response.bytes);
  121. callback({sha_file: MakeSha(response.bytes)});
  122. });
  123.  
  124. function testLink() {
  125. CSGOCli.itemDataRequest("0", "9392736252", "12000417601414030355", "208694537381375111");
  126. CSGOCli.itemDataRequest("0", "9973779171", "9803223881298145965", "1511365146725850462");
  127. CSGOCli.on("itemData", function(itemdata) {
  128. console.log(itemdata.iteminfo.floatvalue);
  129. });
  130.  
  131. }
  132.  
  133. bot.on("logOnResponse", onSteamLogOn)
  134. .on('sentry', onSteamSentry)
  135. .on('servers', onSteamServers)
  136. .on('connected', testLink);
  137.  
  138.  
  139.  
  140. CSGOCli.itemDataRequest("0", "9392736252", "12000417601414030355", "208694537381375111");
  141. CSGOCli.itemDataRequest("0", "9973779171", "9803223881298145965", "1511365146725850462");
  142. CSGOCli.on("itemData", function(itemdata) {
  143. console.log(itemdata.iteminfo.floatvalue);
  144. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement