-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommands.js
551 lines (538 loc) · 14.8 KB
/
commands.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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
// This file is all of the bot's commands
//
// Commands have the following variables available to them:
// - name: the name of the user who spoke the command
// - text: the text spoken by the user
// - bot: the bot object
commands = [
{
name: 'play',
match: function(text) {
return (text.match(/^\/play$/) || text.match(/^play with me$/) || text.match(/^hop on .*mace$/));
},
command: function(data) {
bot.speak('Yeah, not doing that yet. Maybe next time');
},
help: 'play or whatever',
show: false
},
{
name: 'hello',
match: function(text) {
return (text.match(/^hello$/) || text.match(/^hey bot$/));
},
command: function(data) {
bot.speak('Hey! How are ya @'+data.name+'?');
},
help: 'say hello or whatever',
show: false
},
{
name: 'funny',
match: function(text){
return (text.toLowerCase().match(/^haha$/)|| text.match(/^hehe$/) || text.match(/^lol$/));
},
command: function(data){
//bot.speak('What\'s so funny @'+data.name+'?');
var rand = Math.floor((Math.random()*100)+1);
bot.speak(WHATS_FUNNY[rand % WHATS_FUNNY.length].replace(/%%/g, '@'+data.name));
},
help: 'laugh at something',
show: false
},
{
name: 'thanks',
match: function(text){
return (text.toLowerCase().match(/thank.*(spice|)bot/));
},
command: function(data){
var rand = Math.floor((Math.random()*100)+1);
bot.speak(YOURE_WELCOME[rand % YOURE_WELCOME.length].replace(/%%/g, '@'+data.name));
},
help: 'tell spice bot thank you',
show: false
},
{
name: 'drink',
match: function(text) {
return (text.match(/^bot .*(beer|vodka|alcohol|drink|rum|soda|gin|tequilla)$/));
},
command: function(data) {
bot.speak('@'+data.name+' get your own fraking drink!');
},
help: 'alcoholic',
show: false
},
{
name: 'drink classy',
match: function(text) {
return (text.match(/^bot.*(whiskey|wine)$/));
},
command: function(data) {
bot.speak('Aren\'t you classy @'+data.name+' but no!!');
},
help: 'classy alcoholic',
show: false
},
{
name: 'drink safely',
match: function(text) {
return (text.match(/^bot get me a cab$/));
},
command: function(data) {
bot.speak('@'+data.name+' srsly? youre in a company tt-room and should be workin. You arent drunk r u?');
},
help: 'need',
show: false
},
{
name: 'bot jump on',
match: function(text) {
return text.match(/^bot jump on$/);
},
command: function(data) {
bot.addDj();
},
help: 'stage, bot starts DJing',
show: true
},
{
name: 'bot jump off',
match: function(text) {
return text.match(/^bot jump off$/);
},
command: function(data) {
bot.remDj();
},
help: 'stage, bot stops DJing',
show: true
},
{
name: 'info',
match: function(text) {
return text.match(/^bot info$/);
},
command: function(ddata) {
bot.roomInfo(true, function(data) {
var userid = ddata.userid;
var user_count = data.room.metadata.djs.length;
var vote_count = data.room.metadata.upvotes;
bot.pm('ab' + autobop, userid);
bot.pm('as' + autoskip, userid);
bot.pm('djc' + user_count, userid);
bot.pm('vc' + vote_count, userid);
bot.pm('botid'+bot.userId, userid);
bot.pm('bos'+ botOnSet, userid);
bot.pm('djl' + djs, userid);
});
},
help: 'presents help commands in a PM',
show: false
},
{
name: 'status',
match: function(text) {
return text.match(/^bot status$/);
},
command: function(ddata) {
bot.roomInfo(true, function(data) {
var userid = ddata.userid;
bot.pm("botID" + botUserId,userid);
bot.pm("bcp" + botCurrentlyPlaying,userid);
bot.pm("joas" + jumpOffAfterSong,userid);
bot.pm("bos" + botOnSet,userid);
bot.pm("bsi" + botSetIndex,userid);
});
},
help: 'presents bot status in a PM',
show: false
},
{
name: 'bot add song',
match: function(text) {
return text.match(/^bot add song$/);
},
command: function(data) {
bot.roomInfo(true, function(data) {
var newSong = data.room.metadata.current_song._id;
var songName = data.room.metadata.current_song.metadata.song;
bot.vote('up');
bot.playlistAdd(newSong);
bot.speak('Added '+ songName);
});
},
help: "adds current song to bot playlist",
show: true
},
{
name: 'bot remove song',
match:function(text){
return text.match(/^bot remove song$/);
},
command: function(data) {
bot.roomInfo(true,function(data) {
var newSong = data.room.metadata.current_song.id;
var songName = data.room.metadata.current_song.metadata.song;
bot.playlistRemove(newSong);
bot.speak('Removed '+ songName+ "...skipping...");
bot.skip();
});
},
help: "remove an Unwanted song from bot playlist",
show:true
},
{
name: 'bot show song',
match:function(text){
return text.match(/^bot show song$/)
},
command: function(data) {
bot.roomInfo(true,function(data){
if(data.room.metadata.current_song){
var dj_name = data.room.metadata.current_song.djname;
bot.speak("@"+dj_name+" is Currently Playing: "+ artist+" - "+ song);
}else {bot.speak("No Music, I can't hear anything, atleast not to my Robot Ears");}
});
},
help: "Show current song playing",
show: true
},
{
name: 'bot dance',
match: function(text) {
return text.match(/^bot dance$/);
},
command: function(data) {
bot.vote('up');
},
help: 'upvote the current song',
show: true
},
{
name: 'bot downvote',
match: function(text) {
return text.match(/^bot downvote$/);
},
command: function(data) {
bot.vote('down');
},
help: 's the current song',
show: true
},
{
name: 'bot skip',
match: function(text) {
return text.match(/^bot skip(\ssong)?/);
},
command: function(data) {
bot.skip();
},
help: 'skip the current song',
show: true
},
{
name: 'default response',
match: function(text) {
return text.match(/.*spice_bot.*/);
},
command: function(data) {
//sleep(100000);
bot.speak('wut?');
},
help: 'respond to shit',
show: false
},
{
name: 'autobop',
match: function(text) {
return text.match(/^bot autobop(\son|\soff)?/);
},
command: function(data) {
autobop= !autobop;
if(!data.text.match(/(on|off)/)) {
if(autobop){
bot.speak('All songs are awesome');
bot.vote('up');
}
else{
bot.speak('ok good, my neck is starting to hurt');
}
}
if(data.text.match(/off/)){
bot.speak('ok good, my neck is starting to hurt');
autobop=false;
}
if(data.text.match(/on/)){
bot.speak('All songs are awesome');
bot.vote('up');
autobop=true;
}
},
help: 'toggle autobop',
show: true
},
{
name: 'autoskip',
match: function(text) {
return text.match(/^bot autoskip(\son|\soff)?/);
},
command: function(data) {
autoskip = !autoskip;
if(!data.text.match(/(on|off)/)){
if(autoskip) {
bot.speak("fine... I'll skip");
bot.skip();
}
else {
bot.speak('playing mee tunes!');
}
}
if(data.text.match(/on/)) {
autoskip=true;
bot.speak("fine... I'll skip");
bot.skip();
}
if(data.text.match(/off/)) {
autoskip=false;
bot.speak('playing mee tunes!');
}
},
help: 'toggle autobot',
show: true
},
{
name: 'autostats',
match: function(text) {
return text.match(/^bot autostats(\son|\soff)?/);
},
command: function(data) {
if(data.text.match(/on/)) {
autostats=true;
bot.speak('Ill give ya guys the details');
}
if(data.text.match(/off/)) {
autostats=false;
bot.speak('Im showin ya nuthin!');
}
},
help: 'toggle song stats',
show: true
},
{ // TODO: Needs a fix because sometimes there are 11 PMs sent
name: 'help',
match: function(text) {
return text.match(/^bot help$/);
},
command: function(data) {
bot.pm('Commands:',data.userid);
// loop over these commands and speak them
for(i = 0; i < commands.length; i++) {
var command = commands[i];
if (command.show) {
bot.pm('|' + command.name + ': ' + command.help,data.userid);
}
}
},
help: 'list commands',
show: false
},
{
name: 'flip',
match: function(text) {
return text.match(/^bot (table)?\s?flip$/);
},
command: function(data) {
bot.speak('(╯°□°)╯︵ ┻━┻');
},
help: 'flip table',
show: true
},
{
name: 'smile',
match: function(text) {
return text.match(/^bot smile$/);
},
command: function(data) {
bot.speak('(́◉◞౪◟◉‵)');
},
help: 'make me smile',
show: true
},
{
name: 'disapprove',
match: function(text) {
return text.match(/^bot (disapprove|glare)$/);
},
command: function(data) {
bot.speak('ಠ_ಠ');
},
help: 'disapprove of stuff',
show: true
},
{
name: 'say',
match: function(text) {
return text.match(/^bot say/);
},
command: function(data) {
var message = data.text;
var message = message.replace(/^bot say(:+)?/, '');
bot.speak(message);
},
help: 'make the bot say stuff using \"\'s',
show: false
},
{
name: 'weather',
match: function(text) {
return text.match(/^bot weather$/);
},
command: function(data) {
bot.request("http://query.yahooapis.com/v1/public/yql?q=select%20item.description%20from%20weather.forecast%20where%20woeid%3D%202357536&format=json&diagnostics=false", function(error, response, body) {
var json = JSON.parse(body);
var weather = json.query.results.channel.item.description.match(/(Current Conditions[\s\S]*?)<a/i)[1].replace(/(<\/?B\s*?>|\n|\r)/gi, '').split(/<\/?BR.*?>/i)
weather.forEach(function(item){
setTimeout(function() {bot.speak(item);}, 200)
// console.log(item);
setTimeout(function() {}, 200)
});
});
},
help: 'get the weather in Austin',
show: true
},
{
name: 'pizza',
match: function(text) {
return text.match(/^bot (get)?.*pizza( now!?)?$/);
},
command: function(data) {
bot.speak("Oh yeah! Gettin' some 'Za");
bot.sleep(200);
bot.speak("Uhhh... from where:");
bot.request("http://query.yahooapis.com/v1/public/yql?q=select%20Title%20from%20local.search%20where%20zip%3D'78730'%20and%20query%3D'pizza'&format=json&callback=", function(error, response, body) {
var json = JSON.parse(body);
json.query.results.Result.forEach(function(item){
var pizza = item.Title;
bot.speak("- " + pizza);
// bot.sleep(200);
});
});
},
help: 'get us some Pizza!!!',
show: true
},
{
name: 'asian',
match: function(text) {
return text.match(/^bot (get)?.*asian( food)?( now!?)?$/);
},
command: function(data) {
bot.speak("Alright! Time for good Asian food!");
bot.sleep(200);
bot.speak("Uhhh... from where:");
bot.request("http://query.yahooapis.com/v1/public/yql?q=select%20Title%20from%20local.search%20where%20zip%3D'78730'%20and%20query%3D'asian'&format=json&callback=", function(error, response, body) {
var json = JSON.parse(body);
json.query.results.Result.forEach(function(item){
var asian = item.Title;
bot.speak("- " + asian);
// bot.sleep(200);
});
});
},
help: 'get us some Asian Food!!!',
show: true
},
{
name: 'roll',
match: function(text) {
return text.match(/^bot roll$/);
},
command: function(data) {
var number = Math.floor(Math.random()*100)+1
setTimeout(function() {setTimeout( function() {setTimeout(function(){bot.speak("Rolling my 100-sided die...");}, 200)
setTimeout(function(){bot.speak("And... it's...");}, 700)}, 200)
setTimeout(function(){bot.speak(number);}, 1000)}, 100)
},
help: 'roll 100-sided die',
show: true
},
{
name: 'stocks',
match: function(text) {
return text.match(/^bot (market|stocks)$/);
},
command: function(data) {
bot.request("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20google.igoogle.stock%20where%20stock%20in%20('.DJI'%2C'.INX'%2C'.ixic')&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=", function(error, response, body) {
var json = JSON.parse(body);
var quotes = json.query.results.xml_api_reply;
quotes.forEach(function(item){
var company = item.finance.company.data.replace(' Industrial Average', '').replace('Composite', '');
bot.speak(company+': $'+item.finance.last.data);
bot.sleep(200);
});
});
},
help: 'Check the stock market indices',
show: true
},
{
name: 'stock',
match: function(text) {
return text.match(/^bot stock \S+$/);
},
command: function(data) {
var stock = data.text.replace(/^bot stock /, '');
bot.request("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20google.igoogle.stock%20where%20stock%20=%20'" + stock + "'%3B&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=", function(error, response, body) {
var json = JSON.parse(body);
var quotes = json.query.results.xml_api_reply.finance;
var company = quotes.company.data;
var price = quotes.last.data;
bot.speak(company + ': $' + price);
});
},
help: 'Check a stock price',
show: true
},
{
name: 'moon',
match: function(text) {
return text.match(/^bot moon(\s?phase)?$/);
},
command: function(data) {
var now = new Date();
var req = {
uri: 'http://aa.usno.navy.mil/cgi-bin/aa_pap.pl',
form: {
xxy: now.getFullYear(),
xxm: now.getMonth() + 1,
xxd: now.getDate(),
st: 'TX',
place: 'austin',
FFX: 1,
ID: 'AA',
uri: 'http://aa.usno.navy.mil/cgi-bin/aa_pap.pl'
}
};
bot.request.post(req, function(error, response, body) {
// Hack: too late at night to do this correctly...need to refactor
var phase = body.replace(/(\s+| )/g, ' ').replace(/.*Phase of the Moon on.*?:\s*/, '').replace(/(\s*disk.*)/, '').replace(" of the Moon\'s", '');
bot.speak('The moon is:');
bot.sleep(200);
bot.speak(phase);
});
},
help: 'Check the current phase of the moon',
show: true
},
{
name: 'time',
match: function(text) {
return text.match(/^bot (time|date)$/);
},
command: function(data) {
bot.speak(new Date());
},
help: 'get the current date/time',
show: true
}];