forked from luk1337/vapor-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommend.js
144 lines (121 loc) · 4.23 KB
/
commend.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
var vapor = require('vapor');
var steamID = require("steamid");
var steamTotp = require('steam-totp');
var fs = require('fs');
var protos = require("./protos/protos.js");
if (!process.argv[3]) {
console.log("Usage: node commend.js [config file] [id]");
process.exit();
}
// Create our config object
var config = JSON.parse(fs.readFileSync(process.argv[2]));
config.state = "Online";
// Create bot instance
var bot = vapor();
// Initialize bot with our config
bot.init(config);
// Enable plugins we use
bot.use(vapor.plugins.consoleLogger);
bot.use(vapor.plugins.fs);
// Add our custom 2FA-steamguard plugin
if (config["shared_secret"] && config["shared_secret"].length == 28) {
bot.use({
name: '2FA-steamguard',
plugin: function(VaporAPI) {
VaporAPI.registerHandler({
emitter: 'vapor',
event: 'steamGuard'
}, function(callback) {
callback(steamTotp.generateAuthCode(config["shared_secret"]));
});
}
});
} else {
bot.use(vapor.plugins.stdinSteamGuard);
}
// Proto stuff
var ClientHello = 4006;
var ClientWelcome = 4004;
var clientTimeout = null;
var helloMsgInterval = null;
function stop(msg) {
if (msg)
console.log(msg);
clearTimeout(clientTimeout);
clearInterval(helloMsgInterval);
bot.disconnect();
}
// Create custom plugin
bot.use({
name: 'vapor-commend',
plugin: function(VaporAPI) {
var Steam = VaporAPI.getSteam();
var client = VaporAPI.getClient();
var steamUser = VaporAPI.getHandler('steamUser');
var steamGameCoordinator = new Steam.SteamGameCoordinator(client, 730);
var clientMessage = { games_played: [ { game_id: 730 } ] };
VaporAPI.registerHandler({
emitter: 'vapor',
event: 'ready'
}, function() {
steamUser.gamesPlayed(clientMessage);
helloMsgInterval = setInterval(function() {
if (!client.connected)
return;
if (steamGameCoordinator._client._connection == undefined)
stop("[INFO] Disconnected: Someone is playing on this account right now");
steamGameCoordinator.send({
msg: ClientHello,
proto: { }
}, new protos.CMsgClientHello({}).toBuffer());
}, 2000);
clientTimeout = setTimeout(function() {
stop("[INFO] Timed out after 15 seconds");
}, 15000);
});
VaporAPI.registerHandler({
emitter: 'vapor',
event: 'disconnected'
}, function(error) {
clearTimeout(clientTimeout);
clearInterval(helloMsgInterval);
});
steamGameCoordinator.on('message', function(header, buffer, callback) {
switch (header.msg) {
case ClientWelcome:
clearInterval(helloMsgInterval);
console.log("[INFO] Trying to commend the user!");
steamGameCoordinator.send({
msg: protos.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayer,
proto: { }
}, new protos.CMsgGCCStrike15_v2_ClientCommendPlayer({
accountId: new steamID(process.argv[3]).accountid,
matchId: 8,
commendation: new protos.PlayerCommendationInfo({
cmdFriendly: 1,
cmdTeaching: 2,
cmdLeader: 4
}),
tokens: 10
}).toBuffer());
setTimeout(function() {
stop();
}, 3000);
break;
case protos.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello:
console.log("[INFO] MM Client Hello sent!");
break;
default:
console.log(header);
break;
}
});
}
});
// Start the bot
bot.connect();
// Handle SIGINT (Ctrl+C) gracefully
process.on('SIGINT', function() {
bot.disconnect();
setTimeout(process.exit, 1000, 0);
});