-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame.js
166 lines (163 loc) · 7.77 KB
/
game.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
157
158
159
160
161
162
163
164
165
166
var steam = require("steam"),
util = require("util"),
fs = require("fs"),
dota2 = require("dota2"),
bot = new steam.SteamClient(),
Dota2 = new dota2.Dota2Client(bot, true);
var onSteamLogOn = function onSteamLogOn() {
bot.setPersonaState(steam.EPersonaState.Offline); // to display your bot's status as "Online"
bot.setPersonaName("Fuck Off Retard xD"); // to change its nickname
util.log("Logged on.");
Dota2.launch();
Dota2.on("ready", function() {
console.log("Node-dota2 ready.");
/* Note: Should not declare new event listeners nested inside of
'ready', else you could end up with duplicated handlers if 'ready'
is fired multiple times. Exception is made within this test file
for the same of keeping relevant samples together. */
/* INVENTORY */
// Dota2.setItemPositions([[ITEM ID, POSITION]]);
// Dota2.deleteItem(ITEM ID);
/* MATCHES */
// Event based
// Dota2.matchDetailsRequest(246546269);
// Dota2.on("matchData", function (matchId, matchData) {
// console.log(JSON.stringify(matchData, null, 2));
// });
// Dota2.matchmakingStatsRequest();
// Dota2.on("matchmakingStatsData", function(waitTimesByGroup, searchingPlayersByGroup, disabledGroups, matchmakingStatsResponse) {
// console.log(JSON.stringify(matchmakingStatsResponse, null, 2));
// });
// Callback based
//Dota2.matchDetailsRequest(246546269, function(err, body) {
// if (err) throw err;
// console.log(JSON.stringify(body));
//});
/* COMMUNITY */
// Event based
// Dota2.profileRequest(28956443, true);
// Dota2.on("profileData", function (accountId, profileData) {
// console.log(JSON.stringify(profileData, null, 2));
// });
// Dota2.passportDataRequest(28956443);
// Dota2.on("passportData", function (accountId, passportData) {
// console.log(passportData.leagueGuesses.stampedPlayers);
// });
// Dota2.hallOfFameRequest();
// Dota2.on("hallOfFameData", function(week, featuredPlayers, featuredFarmer, hallOfFameResponse) {
// console.log(JSON.stringify(hallOfFameResponse, null, 2));
// });
// Callback based
//Dota2.profileRequest(28956443, true, function(err, body) {
// if (err) throw err;
// console.log(JSON.stringify(body));
//});
// Dota2.passportDataRequest(28956443, function(err, body) {
// console.log(JSON.stringify(body));
// });
// Dota2.hallOfFameRequest(null, function(err, body){
// console.log(JSON.stringify(body));
// });
/* CHAT */
// Event based
// Dota2.joinChat("rj");
// setTimeout(function(){ Dota2.sendMessage("rj", "wowoeagnaeigniaeg"); }, 5000);
// setTimeout(function(){ Dota2.leaveChat("rj"); }, 10000);
/* GUILD */
// Dota2.requestGuildData();
// Dota2.on("guildOpenPartyData", function(guildId, openParties){
// Event based
// Dota2.inviteToGuild(guildId, 28956443);
// Dota2.setGuildAccountRole(guildId, 28956443, 2);
// Dota2.cancelInviteToGuild(guildId, 75028261);
// Callback based
// Dota2.inviteToGuild(guildId, 28956443, function(err, body){
// console.log(JSON.stringify(body));
// });
// Dota2.cancelInviteToGuild(guildId, 75028261, function(err, body){
// console.log(JSON.stringify(body));
// });
// Dota2.setGuildAccountRole(guildId, 28956443, 2, function(err, body){
// console.log(JSON.stringify(body));
// });
// Doing chat stuffs.
// var guildChannelName = util.format("Guild_%s", guildId);
// Dota2.joinChat(guildChannelName, dota2.DOTAChatChannelType_t.DOTAChannelType_Guild);
// setTimeout(function(){ Dota2.sendMessage(guildChannelName, "wowoeagnaeigniaeg"); }, 5000);
// setTimeout(function(){ Dota2.leaveChat(guildChannelName); }, 10000);
// });
/* LOBBIES */
// Dota2.createPracticeLobby("Techies cheese", "boop", Dota2.ServerRegion.PERFECTWORLDTELECOM, Dota2.GameMode.DOTA_GAMEMODE_AR, function(err, body){
// console.log(JSON.stringify(body));
// });
// setTimeout(function(){
// Dota2.leavePracticeLobby(function(err, body){
// console.log(JSON.stringify(body));
// });
// }, 60000);
/* LEAGUES */
Dota2.leaguesInMonthRequest(10, 2013, function(err, data) { // November 2013
for (let league in data.leagues) {
for (let atr of data.leagues[league]) {
console.log(atr);
}
}
console.log('Found ' + data.leagues.length + ' leagues full of schedule data :D');
});
// Dota2.leaguesInMonthRequest(08, 2015); // November 2013
// Dota2.on("leaguesInMonthResponse", function(err, data) {
// console.log('Found ' + data.leagues.length + ' leagues full of schedule data :D');
// });
/* SOURCETV */
//Dota2.findSourceTVGames({}, function(data) { // May 2015
// for (game in data.games) {
// console.log(data.games[game]);
// for (atr in data.games[game]) {
// console.log(data.games[game][atr]);
// }
// }
// console.log('Successfully received SourceTVGames: ' + data.games[0]);
//});
});
Dota2.on("unready", function onUnready() {
console.log("Node-dota2 unready.");
});
Dota2.on("chatMessage", function(channel, personaName, message) {
// util.log([channel, personaName, message].join(", "));
});
Dota2.on("guildInvite", function(guildId, guildName, inviter) {
// Dota2.setGuildAccountRole(guildId, 75028261, 3);
});
Dota2.on("unhandled", function(kMsg) {
util.log("UNHANDLED MESSAGE " + kMsg);
});
// setTimeout(function(){ Dota2.exit(); }, 5000);
},
onSteamSentry = function onSteamSentry(sentry) {
util.log("Received sentry.");
require('fs').writeFileSync('sentry', sentry);
},
onSteamServers = function onSteamServers(servers) {
util.log("Received servers.");
fs.writeFile('servers', JSON.stringify(servers));
},
onWebSessionID = function onWebSessionID(webSessionID) {
util.log("Received web session id.");
// steamTrade.sessionID = webSessionID;
bot.webLogOn(function onWebLogonSetTradeCookies(cookies) {
util.log("Received cookies.");
for (var i = 0; i < cookies.length; i++) {
// steamTrade.setCookie(cookies[i]);
}
});
};
// Login, only passing authCode if it exists
var logOnDetails = {
"accountName": process.env.STEAM_USER,
"password": process.env.STEAM_PASS,
};
if (process.env.STEAM_GUARD_CODE) logOnDetails.authCode = process.env.STEAM_GUARD_CODE;
var sentry = fs.readFileSync('sentry');
if (sentry.length) logOnDetails.shaSentryfile = sentry;
bot.logOn(logOnDetails);
bot.on("loggedOn", onSteamLogOn).on('sentry', onSteamSentry).on('servers', onSteamServers).on('webSessionID', onWebSessionID);