-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
328 lines (294 loc) · 10.2 KB
/
index.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
const { Client } = require('discord-rpc'),
fs = require('fs'),
readline = require('readline'),
stream = require('stream'),
Discord = require('discord.js'),
dclient = new Discord.Client()
token = "",
rpc = new Client({ transport: "ipc" }),
appClient = "413414231187390466",
colors = require('colors/safe')
var lastidk = "";
var currentlyalive = "";
var alive = "";
var gameover = "yes";
var myTeamPlayers = 4;
dclient.on('ready', () => {
console.log('Connected to Discord Bot!');
});
dclient.on('message', message => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith('win')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/win.mp3');
})
.catch(console.error);
}
if (message.content === 'players') {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/fortnitebot.mp3');
})
.catch(console.error);
}
if (message.content === 'gameover') {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/gameover.mp3');
})
.catch(console.error);
}
if (message.content.startsWith('leave')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.leave();
}
if (message.content.startsWith('players ')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join();
myTeamPlayers = parseInt(args[0]);
message.reply("Set players to " + args[0]);
}
if (message.content.includes('lee')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/lee.mp3');
})
.catch(console.error);
}
if (message.content.includes('man ben')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/manben.mp3');
})
.catch(console.error);
}
if (message.content.includes('.mp3')) {
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
const dispatcher = connection.playFile('C:/Users/Mick/Music/'+args[0]);
})
.catch(console.error);
}
if (message.content.includes('land')) {
console.log(message);
if (message.author !== 'Fornite'){
message.reply('I think you should go to...');
var myRandom = Math.floor((Math.random() * 10) + 1);
switch (myRandom) {
case 1:
message.reply('Retail Tactic');
break;
case 2:
message.reply('Tilted Towers');
break;
case 3:
message.reply('Salty Springs');
break;
case 4:
message.reply('Fatal Fields');
break;
case 5:
message.reply('Shifty Shafts');
break;
case 6:
message.reply('Greasy Grove');
break;
case 7:
message.reply('Snobby Shores');
break;
case 8:
message.reply('Pleasant Park');
break;
case 9:
message.reply('Lucky L4nding');
break;
case 10:
message.reply('Anarchy Acres');
break;
}
}
}
});
async function updatediscord() {
var lines = process.stdout.getWindowSize()[1];
for(var i = 0; i < lines; i++) {
console.log('\r\n');
}
console.log(colors.green("+=================================================+"))
console.log(colors.green("| Chaps Fornite Bot |"))
console.log(colors.green("|=================================================|"))
console.log(colors.green("| All Systems Online! |"))
console.log(colors.green("+-------------------------------------------------+"))
console.log("")
console.log("")
console.log("")
console.log("")
var instream = fs.createReadStream(process.env.LOCALAPPDATA+"/FortniteGame/Saved/Logs/FortniteGame.log");
var outstream = new stream;
var rl = readline.createInterface(instream, outstream);
rl.on('line', function(line) {
// process line here
i++;
var id = "["+i+"] ";
line = line.replace("[", "")
var split = line.split("]");
var command = split[2]+"";
var ctype = command.split(": ");
var type = ctype[0];
if(type=="LogExit"){
lastidk = "";
} else if(type=="LogOnline"){
var split = line.split(" ");
var split2 = command.split(" ");
if(split[3]=="FOnlinePresenceMcp::OnXmppPresenceReceived"){
if(split[7]){
var total = "";
for (var i = 7; i < split.length; i++) {
// console.log(split[7]+split[8])
total = total+split[i];
// console.log(split[8]);
}
lastidk = total;
}
}
}
});
if(lastidk != ""){
var obj = JSON.parse(lastidk);
var filteredParty = ""
var filtered = {}
//console.log("");console.log("");console.log(colors.yellow("------- rawJSON -------"));console.log(lastidk);
console.log("");console.log("");console.log(colors.yellow("------- obj -------"));console.log(obj);
console.log("");console.log("");console.log(colors.yellow("------- obj[0] -------"));console.log(obj[0].Properties);
for (key in obj[0].Properties) {
if (key.match(/joininfo/)) filteredParty = key;
//console.log(key.match(/joininfo/))
}
console.log("");console.log("");console.log("[Info] **Updating game data**");
if(obj[0].Properties[filteredParty].sourceDisplayName === "MickyDNet" || obj[0].Properties[filteredParty].sourceDisplayName === "Bossko30" || obj[0].Properties[filteredParty].sourceDisplayName === "Kato_m8" || obj[0].Properties[filteredParty].sourceDisplayName === "oOoSCOTToOo") {
console.log("[Info] Your party id: "+filteredParty)
console.log("[Info] Your party member: "+obj[0].Properties[filteredParty].sourceDisplayName)
if(obj[0].bIsPlaying==true){
if(obj[0].Status+"".includes("-")){
/*if(obj[0].Properties.FortPartySize_i <= myTeamPlayers){*/
var split = obj[0].Status.split("-");
var currentlyalive = split[1];
var currentlyalive = currentlyalive.replace("Alive", "");
gameover = "no";
if (currentlyalive <= 50){
if (currentlyalive == alive) {
console.log(); console.log();
console.log(colors.yellow("[Info] Same amount of players alive!"));
} else {
console.log(); console.log();
console.log(colors.green("[Info] Someone died! :O"));
console.log("[Info] Currently Alive: " + currentlyalive);
console.log("[Info] Alive: " + alive)
if (currentlyalive <= obj[0].Properties.FortPartySize_i){
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log(); console.log();
console.log(colors.green('[Info] Connected to Voice'));
const dispatcher = connection.playFile('C:/Users/Mick/Music/win.mp3');
})
.catch(console.error);
}
if (currentlyalive % 10 === 0){
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log(); console.log();
console.log(colors.green('Connected to Voice'));
const dispatcher = connection.playFile('C:/Users/Mick/Music/fortnitebot.mp3');
})
.catch(console.error);
} else {
console.log(); console.log();
console.log("Not a divider of 10!");
}
}
} else {
console.log(); console.log();
console.log(colors.yellow("[Info] TOO MANY PLAYERS!!!"));
}
alive = split[1];
alive = alive.replace("Alive", "");
console.log(); console.log();
console.log("[Info] Ingame - "+ alive + " Alive")
var tochannel = dclient.channels.find('name','fortnite-shit');
rpc.setActivity({
details: `Battle Royale`,
state: `Ingame - ${alive} Alive`,
largeImageKey: 'battle_royale',
smallImageKey: 'logo',
largeImageText: `Battle Royale`,
smallImageText: `Fortnite`,
instance: false,
});
/*} else {
console.log("NOT YOUR GAME!!!")
} --fixed to player name now.. */
}
} else {
if (gameover == "no"){
if(obj[0].Properties.FortPartySize_i > 2){
channel = dclient.channels.find('name', 'Admin Chit Chat');
channel.join()
.then(connection => {
console.log('Connected to Voice');
//const dispatcher = connection.playFile('C:/Users/Mick/Music/gameover.mp3');
})
.catch(console.error);
}
}
rpc.setActivity({
details: `Battle Royale`,
state: `Game Menu`,
largeImageKey: 'battle_royale',
smallImageKey: 'logo',
largeImageText: `Battle Royale`,
smallImageText: `Fortnite`,
instance: false,
});
gameover = "yes";
}
} else {
console.log(obj[0].Properties)
var filteredParty = ""
var filtered = {}
for (key in obj[0].Properties) {
if (key.match(/joininfo/)) filteredParty = key;
//console.log(key.match(/joininfo/))
}
console.log("")
console.log("")
console.log("")
console.log("")
console.log(colors.yellow("[Info] Found another party in your friends list: "+filteredParty))
console.log(colors.yellow("[Info] Their party member: "+obj[0].Properties[filteredParty].sourceDisplayName))
}
} else {
console.log(colors.yellow("Cannot see your game... Is Fortnite open?"))
}
lastidk = "";
}
rpc.on('ready', () => {
console.log(`Connected to Discord! (${appClient})`);
global.intloop = setInterval(updatediscord, 1500);
});
rpc.login(appClient).catch(console.log("Discord error"));
dclient.login(token);