Guest User

Untitled

a guest
Jul 8th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 0 0
  1. var fs = require("fs"),
  2. Steam = require("steam"),
  3. SteamID = require("steamid"),
  4. IntervalInt = null,
  5. readlineSync = require("readline-sync"),
  6. Protos = require("./protos/protos.js"),
  7. CountCommends = 0,
  8. Long = require("long"),
  9. process = require("process"),
  10. steamID = readlineSync.question("SteamID64 which will be commended: ");
  11.  
  12. var ClientHello = 4006,
  13. ClientWelcome = 4004;
  14.  
  15. var accounts = [];
  16.  
  17. var arrayAccountsTxt = fs.readFileSync("accounts.txt").toString().split("\n");
  18. for (i in arrayAccountsTxt) {
  19. var accInfo = arrayAccountsTxt[i].toString().trim().split(":");
  20. var username = accInfo[0];
  21. var password = accInfo[1];
  22. accounts[i] = [];
  23. accounts[i].push({
  24. username: username,
  25. password: password
  26. });
  27. }
  28.  
  29. function loginAndCommend(steamID) {
  30. if ((steamID == "") || !(steamID.indexOf("765") > -1) || (steamID.length < 17)) {
  31. console.log("That's not a valid SteamID!");
  32. process.exit();
  33. }
  34. if (accounts[0]) {
  35. var account = accounts[0][0];
  36. var account_name = account.username;
  37. var password = account.password;
  38. Client = new Steam.SteamClient();
  39. User = new Steam.SteamUser(Client);
  40. GC = new Steam.SteamGameCoordinator(Client, 730);
  41. Friends = new Steam.SteamFriends(Client);
  42.  
  43. Client.connect();
  44.  
  45. Client.on("connected", function() {
  46. User.logOn({
  47. account_name: account_name,
  48. password: password
  49. });
  50. });
  51.  
  52. Client.on("logOnResponse", function(res) {
  53. if (res.eresult !== Steam.EResult.OK) {
  54. if (res.eresult == Steam.EResult.ServiceUnavailable) {
  55. console.log("\n[STEAM CLIENT - " + account_name + "] Login failed - STEAM IS DOWN!");
  56. console.log(res);
  57. Client.disconnect();
  58. process.exit();
  59. } else {
  60. console.log("\n[STEAM CLIENT - " + account_name + "] Login failed!");
  61. console.log(res);
  62. Client.disconnect();
  63. accounts.splice(0, 1);
  64. loginAndCommend(steamID);
  65. }
  66. } else {
  67. console.log("\n[STEAM CLIENT - " + account_name + "] Logged in!");
  68.  
  69. Friends.setPersonaState(Steam.EPersonaState.Offline);
  70.  
  71. User.gamesPlayed({
  72. games_played: [{
  73. game_id: 730
  74. }]
  75. });
  76.  
  77. if (GC) {
  78. IntervalInt = setInterval(function() {
  79. GC.send({
  80. msg: ClientHello,
  81. proto: {}
  82. }, new Protos.CMsgClientHello({}).toBuffer());
  83. }, 2000);
  84. console.log("[GC - " + account_name + "] Client Hello sent!");
  85. } else {
  86. console.log("[GC - " + account_name + "] Not initialized!");
  87. Client.disconnect();
  88. accounts.splice(0, 1);
  89. loginAndCommend(steamID);
  90. }
  91. }
  92. });
  93.  
  94. Client.on("error", function(err) {
  95. console.log("[STEAM CLIENT - " + account_name + "] " + err);
  96. console.log("[STEAM CLIENT - " + account_name + "] Account is probably ingame!");
  97. Client.disconnect();
  98. accounts.splice(0, 1);
  99. loginAndCommend(steamID);
  100. });
  101.  
  102. GC.on("message", function(header, buffer, callback) {
  103. switch (header.msg) {
  104. case ClientWelcome:
  105. clearInterval(IntervalInt);
  106. console.log("[GC - " + account_name + "] Client Welcome received!");
  107. console.log("[GC - " + account_name + "] Commend request sent!");
  108. sendCommend(GC, Client, account_name, steamID);
  109. break;
  110. case Protos.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello:
  111. console.log("[GC - " + account_name + "] MM Client Hello sent!");
  112. break;
  113. default:
  114. console.log(header);
  115. break;
  116. }
  117. });
  118. } else {
  119. console.log("\n\n" + CountCommends + " commend(s) successfully sent!");
  120. Client.disconnect();
  121. }
  122. }
  123.  
  124. function sendCommend(GC, Client, account_name) {
  125. console.log("[GC - " + account_name + "] Commend request received!");
  126. console.log("[GC - " + account_name + "] Trying to commend the user!");
  127. var account_id = new SteamID(steamID).accountid;
  128.  
  129. var commend_payload = new Protos.PlayerCommendationInfo({
  130. cmdFriendly: 1,
  131. cmdTeaching: 2,
  132. cmdLeader: 4
  133. });
  134.  
  135. var commendProto = new Protos.CMsgGCCStrike15_v2_ClientCommendPlayer({
  136. accountId: account_id,
  137. matchId: 8,
  138. tokens: 10,
  139. commendation: commend_payload
  140. }).toBuffer();
  141.  
  142. GC.send({
  143. msg: Protos.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayer,
  144. proto: {}
  145. }, commendProto);
  146. console.log("[GC - " + account_name + "] Commendation Sent!");
  147. Client.disconnect();
  148. accounts.splice(0, 1);
  149. CountCommends++;
  150. loginAndCommend(steamID);
  151. }
  152.  
  153. process.on('uncaughtException', function (err) {
  154. });
  155.  
  156. loginAndCommend(steamID);
  157. console.log("Initializing CommendBot by CoolA1d...\nCredits: AskWrite for original ReportBot, Trololo - Idea for ReportBot");
Add Comment
Please, Sign In to add comment