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