-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathexample.js
139 lines (121 loc) · 5.36 KB
/
example.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
var Steam = require("steam"),
util = require("util"),
fs = require("fs"),
csgo = require("../"),
bot = new Steam.SteamClient(),
steamUser = new Steam.SteamUser(bot),
steamFriends = new Steam.SteamFriends(bot),
steamGC = new Steam.SteamGameCoordinator(bot, 730),
CSGOCli = new csgo.CSGOClient(steamUser, steamGC, true),
readlineSync = require("readline-sync"),
crypto = require("crypto");
Steam.servers = require('./servers.json')
/* Decoding Share Codes */
var scDecoder = new csgo.SharecodeDecoder("CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD");
console.log("Sharecode CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD decodes into: ");
console.log(scDecoder.decode());
function MakeSha(bytes) {
var hash = crypto.createHash('sha1');
hash.update(bytes);
return hash.digest();
}
var onSteamLogOn = function onSteamLogOn(response){
if (response.eresult == Steam.EResult.OK) {
util.log('Logged in!');
}
else
{
util.log('error, ', response);
process.exit();
}
steamFriends.setPersonaState(Steam.EPersonaState.Busy);
util.log("Logged on.");
util.log("Current SteamID64: " + bot.steamID);
util.log("Account ID: " + CSGOCli.ToAccountID(bot.steamID));
CSGOCli.launch();
CSGOCli.on("unhandled", function(message) {
util.log("Unhandled msg");
util.log(message);
});
CSGOCli.on("ready", function() {
util.log("node-csgo ready.");
CSGOCli.matchmakingStatsRequest();
CSGOCli.on("matchmakingStatsData", function(matchmakingStatsResponse) {
util.log("Avg. Wait Time: " + matchmakingStatsResponse.global_stats.search_time_avg);
util.log("Players Online: " + matchmakingStatsResponse.global_stats.players_online);
util.log("Players Searching: " + matchmakingStatsResponse.global_stats.players_searching);
util.log("Servers Online: " + matchmakingStatsResponse.global_stats.servers_online);
util.log("Servers Available: " + matchmakingStatsResponse.global_stats.servers_available);
util.log("Matches in Progress: " + matchmakingStatsResponse.global_stats.ongoing_matches);
console.log(JSON.stringify(matchmakingStatsResponse, null, 4));
CSGOCli.playerProfileRequest(CSGOCli.ToAccountID(bot.steamID));
CSGOCli.on("playerProfile", function(profile) {
console.log("Profile");
console.log("Player Rank: " + CSGOCli.Rank.getString(profile.account_profiles[0].ranking.rank_id))
console.log(JSON.stringify(profile, null, 2));
});
CSGOCli.requestRecentGames();
CSGOCli.on("matchList", function(list) {
console.log("Match List");
if (list.matches && list.matches.length > 0) {
console.log(list.matches[0]);
}
});
CSGOCli.richPresenceUpload({
RP: {
status: "Hello World!", // Sets rich presence text to "Hello World!"
version: 13508, // Not sure what this value does
time: 161.164087, // This might be the amount of time since you have started the game, not sure.
"game:state": "lobby",
steam_display: "#display_Lobby",
connect: "+gcconnectG082AA752",
"game:mode": "casual"
}
});
// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198084749846A6768147729D12557175561287951743
CSGOCli.itemDataRequest("76561198084749846", "6768147729", "12557175561287951743", "0");
CSGOCli.on("itemData", function(itemdata) {
console.log(itemdata);
});
});
});
CSGOCli.on("unready", function onUnready(){
util.log("node-csgo unready.");
});
CSGOCli.on("unhandled", function(kMsg) {
util.log("UNHANDLED MESSAGE " + kMsg);
});
},
onSteamSentry = function onSteamSentry(sentry) {
util.log("Received sentry.");
require('fs').writeFileSync('sentry', sentry);
},
onSteamServers = function onSteamServers(servers) {
util.log("Received servers.");
fs.writeFileSync('servers.json', JSON.stringify(servers, null, 2));
}
var username = readlineSync.question('Username: ');
var password = readlineSync.question('Password: ', {noEchoBack: true});
var authCode = readlineSync.question('AuthCode: ');
var logOnDetails = {
"account_name": username,
"password": password,
};
if (authCode !== "") {
logOnDetails.auth_code = authCode;
}
var sentry = fs.readFileSync('sentry');
if (sentry.length) {
logOnDetails.sha_sentryfile = MakeSha(sentry);
}
bot.connect();
steamUser.on('updateMachineAuth', function(response, callback){
fs.writeFileSync('sentry', response.bytes);
callback({ sha_file: MakeSha(response.bytes) });
});
bot.on("logOnResponse", onSteamLogOn)
.on('sentry', onSteamSentry)
.on('servers', onSteamServers)
.on('connected', function(){
steamUser.logOn(logOnDetails);
});