forked from TalkTakesTime/Pokemon-Showdown-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.js
More file actions
810 lines (768 loc) · 32.5 KB
/
commands.js
File metadata and controls
810 lines (768 loc) · 32.5 KB
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/**
* This is the file where the bot commands are located
*
* @license MIT license
*/
var http = require('http');
var sys = require('sys');
if (config.serverid === 'showdown') {
var https = require('https');
var csv = require('csv-parse');
}
exports.commands = {
/**
* Help commands
*
* These commands are here to provide information about the bot.
*/
credits: 'about',
about: function(arg, by, room) {
if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
var text = '';
} else {
var text = '/pm ' + by + ', ';
}
text += '**Pokémon Showdown Bot** by: Quinella, TalkTakesTime, and Morfent';
this.say(room, text);
},
git: function(arg, by, room) {
var text = config.excepts.indexOf(toId(by)) < 0 ? '/pm ' + by + ', ' : '';
text += '**Pokemon Showdown Bot** source code: ' + config.fork;
this.say(room, text);
},
help: 'guide',
guide: function(arg, by, room) {
if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
var text = '';
} else {
var text = '/pm ' + by + ', ';
}
if (config.botguide) {
text += 'A guide on how to use this bot can be found here: ' + config.botguide;
} else {
text += 'There is no guide for this bot. PM the owner with any questions.';
}
this.say(room, text);
},
/**
* Dev commands
*
* These commands are here for highly ranked users (or the creator) to use
* to perform arbitrary actions that can't be done through any other commands
* or to help with upkeep of the bot.
*/
reload: function(arg, by, room) {
if (!this.hasRank(by, '#~')) return false;
try {
this.uncacheTree('./commands.js');
Commands = require('./commands.js').commands;
this.say(room, 'Commands reloaded.');
} catch (e) {
error('failed to reload: ' + sys.inspect(e));
}
},
custom: function(arg, by, room) {
if (!this.hasRank(by, '~')) return false;
// Custom commands can be executed in an arbitrary room using the syntax
// ".custom [room] command", e.g., to do !data pikachu in the room lobby,
// the command would be ".custom [lobby] !data pikachu". However, using
// "[" and "]" in the custom command to be executed can mess this up, so
// be careful with them.
if (arg.indexOf('[') === 0 && arg.indexOf(']') > -1) {
var tarRoom = arg.slice(1, arg.indexOf(']'));
arg = arg.substr(arg.indexOf(']') + 1).trim();
}
this.say(tarRoom || room, arg);
},
js: function(arg, by, room) {
if (config.excepts.indexOf(toId(by)) === -1) return false;
try {
var result = eval(arg.trim());
this.say(room, JSON.stringify(result));
} catch (e) {
this.say(room, e.name + ": " + e.message);
}
},
/**
* Room Owner commands
*
* These commands allow room owners to personalise settings for moderation and command use.
*/
settings: 'set',
set: function(arg, by, room) {
if (!this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
var settable = {
say: 1,
joke: 1,
choose: 1,
usagestats: 1,
buzz: 1,
'8ball': 1,
survivor: 1,
games: 1,
wifi: 1,
monotype: 1,
autoban: 1,
happy: 1,
guia: 1,
studio: 1,
'switch': 1,
banword: 1
};
var modOpts = {
flooding: 1,
caps: 1,
stretching: 1,
bannedwords: 1
};
var opts = arg.split(',');
var cmd = toId(opts[0]);
if (cmd === 'mod' || cmd === 'm' || cmd === 'modding') {
if (!opts[1] || !toId(opts[1]) || !(toId(opts[1]) in modOpts)) return this.say(room, 'Incorrect command: correct syntax is ' + config.commandcharacter + 'set mod, [' +
Object.keys(modOpts).join('/') + '](, [on/off])');
if (!this.settings['modding']) this.settings['modding'] = {};
if (!this.settings['modding'][room]) this.settings['modding'][room] = {};
if (opts[2] && toId(opts[2])) {
if (!this.hasRank(by, '#~')) return false;
if (!(toId(opts[2]) in {on: 1, off: 1})) return this.say(room, 'Incorrect command: correct syntax is ' + config.commandcharacter + 'set mod, [' +
Object.keys(modOpts).join('/') + '](, [on/off])');
if (toId(opts[2]) === 'off') {
this.settings['modding'][room][toId(opts[1])] = 0;
} else {
delete this.settings['modding'][room][toId(opts[1])];
}
this.writeSettings();
this.say(room, 'Moderation for ' + toId(opts[1]) + ' in this room is now ' + toId(opts[2]).toUpperCase() + '.');
return;
} else {
this.say(room, 'Moderation for ' + toId(opts[1]) + ' in this room is currently ' +
(this.settings['modding'][room][toId(opts[1])] === 0 ? 'OFF' : 'ON') + '.');
return;
}
} else {
if (!Commands[cmd]) return this.say(room, config.commandcharacter + '' + opts[0] + ' is not a valid command.');
var failsafe = 0;
while (!(cmd in settable)) {
if (typeof Commands[cmd] === 'string') {
cmd = Commands[cmd];
} else if (typeof Commands[cmd] === 'function') {
if (cmd in settable) {
break;
} else {
this.say(room, 'The settings for ' + config.commandcharacter + '' + opts[0] + ' cannot be changed.');
return;
}
} else {
this.say(room, 'Something went wrong. PM TalkTakesTime here or on Smogon with the command you tried.');
return;
}
failsafe++;
if (failsafe > 5) {
this.say(room, 'The command "' + config.commandcharacter + '' + opts[0] + '" could not be found.');
return;
}
}
var settingsLevels = {
off: false,
disable: false,
'+': '+',
'%': '%',
'@': '@',
'&': '&',
'#': '#',
'~': '~',
on: true,
enable: true
};
if (!opts[1] || !opts[1].trim()) {
var msg = '';
if (!this.settings[cmd] || (!this.settings[cmd][room] && this.settings[cmd][room] !== false)) {
msg = '' + config.commandcharacter + '' + cmd + ' is available for users of rank ' + ((cmd === 'autoban' || cmd === 'banword') ? '#' : config.defaultrank) + ' and above.';
} else if (this.settings[cmd][room] in settingsLevels) {
msg = '' + config.commandcharacter + '' + cmd + ' is available for users of rank ' + this.settings[cmd][room] + ' and above.';
} else if (this.settings[cmd][room] === true) {
msg = '' + config.commandcharacter + '' + cmd + ' is available for all users in this room.';
} else if (this.settings[cmd][room] === false) {
msg = '' + config.commandcharacter + '' + cmd + ' is not available for use in this room.';
}
this.say(room, msg);
return;
} else {
if (!this.hasRank(by, '#~')) return false;
var newRank = opts[1].trim();
if (!(newRank in settingsLevels)) return this.say(room, 'Unknown option: "' + newRank + '". Valid settings are: off/disable, +, %, @, &, #, ~, on/enable.');
if (!this.settings[cmd]) this.settings[cmd] = {};
this.settings[cmd][room] = settingsLevels[newRank];
this.writeSettings();
this.say(room, 'The command ' + config.commandcharacter + '' + cmd + ' is now ' +
(settingsLevels[newRank] === newRank ? ' available for users of rank ' + newRank + ' and above.' :
(this.settings[cmd][room] ? 'available for all users in this room.' : 'unavailable for use in this room.')))
}
}
},
blacklist: 'autoban',
ban: 'autoban',
ab: 'autoban',
autoban: function(arg, by, room) {
if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
arg = arg.split(',');
var added = [];
var illegalNick = [];
var alreadyAdded = [];
if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(room, 'You must specify at least one user to blacklist.');
for (var i = 0; i < arg.length; i++) {
var tarUser = toId(arg[i]);
if (tarUser.length < 1 || tarUser.length > 18) {
illegalNick.push(tarUser);
continue;
}
if (!this.blacklistUser(tarUser, room)) {
alreadyAdded.push(tarUser);
continue;
}
this.say(room, '/roomban ' + tarUser + ', Blacklisted user');
this.say(room, '/modnote ' + tarUser + ' was added to the blacklist by ' + by + '.');
added.push(tarUser);
}
var text = '';
if (added.length) {
text += 'User(s) "' + added.join('", "') + '" added to blacklist successfully. ';
this.writeSettings();
}
if (alreadyAdded.length) text += 'User(s) "' + alreadyAdded.join('", "') + '" already present in blacklist. ';
if (illegalNick.length) text += 'All ' + (text.length ? 'other ' : '') + 'users had illegal nicks and were not blacklisted.';
this.say(room, text);
},
unblacklist: 'unautoban',
unban: 'unautoban',
unab: 'unautoban',
unautoban: function(arg, by, room) {
if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
arg = arg.split(',');
var removed = [];
var notRemoved = [];
if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(room, 'You must specify at least one user to unblacklist.');
for (var i = 0; i < arg.length; i++) {
var tarUser = toId(arg[i]);
if (tarUser.length < 1 || tarUser.length > 18) {
notRemoved.push(tarUser);
continue;
}
if (!this.unblacklistUser(tarUser, room)) {
notRemoved.push(tarUser);
continue;
}
this.say(room, '/roomunban ' + tarUser);
removed.push(tarUser);
}
var text = '';
if (removed.length) {
text += 'User(s) "' + removed.join('", "') + '" removed from blacklist successfully. ';
this.writeSettings();
}
if (notRemoved.length) text += (text.length ? 'No other ' : 'No ') + 'specified users were present in the blacklist.';
this.say(room, text);
},
rab: 'regexautoban',
regexautoban: function(arg, by, room) {
if (config.regexautobanwhitelist.indexOf(toId(by)) < 0 || !this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
if (!arg) return this.say(room, 'You must specify a regular expression to (un)blacklist.');
try {
new RegExp(arg, 'i');
} catch (e) {
return this.say(room, e.message);
}
arg = '/' + arg + '/i';
if (!this.blacklistUser(arg, room)) return this.say(room, '/' + arg + ' is already present in the blacklist.');
this.writeSettings();
this.say(room, '/' + arg + ' was added to the blacklist successfully.');
},
unrab: 'unregexautoban',
unregexautoban: function(arg, by, room) {
if (config.regexautobanwhitelist.indexOf(toId(by)) < 0 || !this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
if (!arg) return this.say(room, 'You must specify a regular expression to (un)blacklist.');
arg = '/' + arg.replace(/\\\\/g, '\\') + '/i';
if (!this.unblacklistUser(arg, room)) return this.say(room,'/' + arg + ' is not present in the blacklist.');
this.writeSettings();
this.say(room, '/' + arg + ' was removed from the blacklist successfully.');
},
viewbans: 'viewblacklist',
vab: 'viewblacklist',
viewautobans: 'viewblacklist',
viewblacklist: function(arg, by, room) {
if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
var text = '';
if (!this.settings.blacklist || !this.settings.blacklist[room]) {
text = 'No users are blacklisted in this room.';
} else {
if (arg.length) {
var nick = toId(arg);
if (nick.length < 1 || nick.length > 18) {
text = 'Invalid nickname: "' + nick + '".';
} else {
text = 'User "' + nick + '" is currently ' + (nick in this.settings.blacklist[room] ? '' : 'not ') + 'blacklisted in ' + room + '.';
}
} else {
var nickList = Object.keys(this.settings.blacklist[room]);
if (!nickList.length) return this.say(room, '/pm ' + by + ', No users are blacklisted in this room.');
this.uploadToHastebin('The following users are banned in ' + room + ':\n\n' + nickList.join('\n'), function (link) {
this.say(room, "/pm " + by + ", Blacklist for room " + room + ": " + link);
}.bind(this));
return;
}
}
this.say(room, '/pm ' + by + ', ' + text);
},
banphrase: 'banword',
banword: function(arg, by, room) {
if (!this.canUse('banword', room, by)) return false;
if (!this.settings.bannedphrases) this.settings.bannedphrases = {};
arg = arg.trim().toLowerCase();
if (!arg) return false;
var tarRoom = room;
if (room.charAt(0) === ',') {
if (!this.hasRank(by, '~')) return false;
tarRoom = 'global';
}
if (!this.settings.bannedphrases[tarRoom]) this.settings.bannedphrases[tarRoom] = {};
if (arg in this.settings.bannedphrases[tarRoom]) return this.say(room, "Phrase \"" + arg + "\" is already banned.");
this.settings.bannedphrases[tarRoom][arg] = 1;
this.writeSettings();
this.say(room, "Phrase \"" + arg + "\" is now banned.");
},
unbanphrase: 'unbanword',
unbanword: function(arg, by, room) {
if (!this.canUse('banword', room, by)) return false;
arg = arg.trim().toLowerCase();
if (!arg) return false;
var tarRoom = room;
if (room.charAt(0) === ',') {
if (!this.hasRank(by, '~')) return false;
tarRoom = 'global';
}
if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom] || !(arg in this.settings.bannedphrases[tarRoom]))
return this.say(room, "Phrase \"" + arg + "\" is not currently banned.");
delete this.settings.bannedphrases[tarRoom][arg];
if (!Object.size(this.settings.bannedphrases[tarRoom])) delete this.settings.bannedphrases[tarRoom];
if (!Object.size(this.settings.bannedphrases)) delete this.settings.bannedphrases;
this.writeSettings();
this.say(room, "Phrase \"" + arg + "\" is no longer banned.");
},
viewbannedphrases: 'viewbannedwords',
vbw: 'viewbannedwords',
viewbannedwords: function(arg, by, room) {
if (!this.canUse('banword', room, by)) return false;
arg = arg.trim().toLowerCase();
var tarRoom = room;
if (room.charAt(0) === ',') {
if (!this.hasRank(by, '~')) return false;
tarRoom = 'global';
}
var text = "";
if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom]) {
text = "No phrases are banned in this room.";
} else {
if (arg.length) {
text = "The phrase \"" + arg + "\" is currently " + (arg in this.settings.bannedphrases[tarRoom] ? "" : "not ") + "banned " +
(room.charAt(0) === ',' ? "globally" : "in " + room) + ".";
} else {
var banList = Object.keys(this.settings.bannedphrases[tarRoom]);
if (!banList.length) return this.say(room, "No phrases are banned in this room.");
this.uploadToHastebin("The following phrases are banned " + (room.charAt(0) === ',' ? "globally" : "in " + room) + ":\n\n" + banList.join('\n'), function (link) {
this.say(room, (room.charAt(0) === ',' ? "" : "/pm " + by + ", ") + "Banned Phrases " + (room.charAt(0) === ',' ? "globally" : "in " + room) + ": " + link);
}.bind(this));
return;
}
}
this.say(room, text);
},
/**
* General commands
*
* Add custom commands here.
*/
tell: 'say',
say: function(arg, by, room) {
if (!this.canUse('say', room, by)) return false;
this.say(room, stripCommands(arg) + ' (' + by + ' said this)');
},
joke: function(arg, by, room) {
if (!this.canUse('joke', room, by) || room.charAt(0) === ',') return false;
var self = this;
var reqOpt = {
hostname: 'api.icndb.com',
path: '/jokes/random',
method: 'GET'
};
var req = http.request(reqOpt, function(res) {
res.on('data', function(chunk) {
try {
var data = JSON.parse(chunk);
self.say(room, data.value.joke.replace(/"/g, "\""));
} catch (e) {
self.say(room, 'Sorry, couldn\'t fetch a random joke... :(');
}
});
});
req.end();
},
choose: function(arg, by, room) {
if (arg.indexOf(',') === -1) {
var choices = arg.split(' ');
} else {
var choices = arg.split(',');
}
choices = choices.filter(function(i) {return (toId(i) !== '')});
if (choices.length < 2) return this.say(room, (room.charAt(0) === ',' ? '': '/pm ' + by + ', ') + config.commandcharacter + 'choose: You must give at least 2 valid choices.');
var choice = choices[Math.floor(Math.random()*choices.length)];
this.say(room, ((this.canUse('choose', room, by) || room.charAt(0) === ',') ? '':'/pm ' + by + ', ') + stripCommands(choice));
},
usage: 'usagestats',
usagestats: function(arg, by, room) {
if (this.canUse('usagestats', room, by) || room.charAt(0) === ',') {
var text = '';
} else {
var text = '/pm ' + by + ', ';
}
text += 'http://www.smogon.com/stats/2015-02/';
this.say(room, text);
},
seen: function(arg, by, room) { // this command is still a bit buggy
var text = (room.charAt(0) === ',' ? '' : '/pm ' + by + ', ');
arg = toId(arg);
if (!arg || arg.length > 18) return this.say(room, text + 'Invalid username.');
if (arg === toId(by)) {
text += 'Have you looked in the mirror lately?';
} else if (arg === toId(config.nick)) {
text += 'You might be either blind or illiterate. Might want to get that checked out.';
} else if (!this.chatData[arg] || !this.chatData[arg].seenAt) {
text += 'The user ' + arg + ' has never been seen.';
} else {
text += arg + ' was last seen ' + this.getTimeAgo(this.chatData[arg].seenAt) + ' ago' + (
this.chatData[arg].lastSeen ? ', ' + this.chatData[arg].lastSeen : '.');
}
this.say(room, text);
},
'8ball': function(arg, by, room) {
if (this.canUse('8ball', room, by) || room.charAt(0) === ',') {
var text = '';
} else {
var text = '/pm ' + by + ', ';
}
var rand = ~~(20 * Math.random()) + 1;
switch (rand) {
case 1: text += "Signs point to yes."; break;
case 2: text += "Yes."; break;
case 3: text += "Reply hazy, try again."; break;
case 4: text += "Without a doubt."; break;
case 5: text += "My sources say no."; break;
case 6: text += "As I see it, yes."; break;
case 7: text += "You may rely on it."; break;
case 8: text += "Concentrate and ask again."; break;
case 9: text += "Outlook not so good."; break;
case 10: text += "It is decidedly so."; break;
case 11: text += "Better not tell you now."; break;
case 12: text += "Very doubtful."; break;
case 13: text += "Yes - definitely."; break;
case 14: text += "It is certain."; break;
case 15: text += "Cannot predict now."; break;
case 16: text += "Most likely."; break;
case 17: text += "Ask again later."; break;
case 18: text += "My reply is no."; break;
case 19: text += "Outlook good."; break;
case 20: text += "Don't count on it."; break;
}
this.say(room, text);
},
/**
* Room specific commands
*
* These commands are used in specific rooms on the Smogon server.
*/
espaol: 'esp',
ayuda: 'esp',
esp: function(arg, by, room) {
// links to relevant sites for the Wi-Fi room
if (config.serverid !== 'showdown') return false;
var text = '';
if (room = 'espaol') {
if (!this.canUse('guia', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
var messages = {
reglas: 'Recuerda seguir las reglas de nuestra sala en todo momento: http://ps-salaespanol.weebly.com/reglas.html',
faq: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
faqs: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
foro: '¡Visita nuestro foro para participar en multitud de actividades! http://ps-salaespanol.proboards.com/',
guia: 'Desde este índice (http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu) podrás acceder a toda la información importante de la sala. By: Lost Seso',
liga: '¿Tienes alguna duda sobre la Liga? ¡Revisa el **índice de la Liga** aquí!: (http://goo.gl/CxH2gi) By: xJoelituh'
};
text += (toId(arg) ? (messages[toId(arg)] || '¡Bienvenidos a la comunidad de habla hispana! Si eres nuevo o tienes dudas revisa nuestro índice de guías: http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu') : '¡Bienvenidos a la comunidad de habla hispana! Si eres nuevo o tienes dudas revisa nuestro índice de guías: http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu');
this.say(room, text);
},
studio: function(arg, by, room) {
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'thestudio') {
if (!this.canUse('studio', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
var messages = {
plug: '/announce The Studio\'s plug.dj can be found here: https://plug.dj/the-studio/'
};
this.say(room, text + (messages[toId(arg)] || ('Welcome to The Studio, a music sharing room on PS!. If you have any questions, feel free to PM a room staff member. Available commands for .studio: ' + Object.keys(messages).join(', '))));
},
'switch': function(arg, by, room) {
if (room !== 'gamecorner' || config.serverid !== 'showdown' || !this.canUse('switch', room, by)) return false;
this.say(room, 'Taking over the world. Starting with Game Corner. Room deregistered.');
this.say(room, '/k ' + (toId(arg) || by) + ', O3O YOU HAVE TOUCHED THE SWITCH');
},
wifi: function(arg, by, room) {
// links to relevant sites for the Wi-Fi room
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'wifi') {
if (!this.canUse('wifi', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
arg = arg.split(',');
var msgType = toId(arg[0]);
if (!msgType) return this.say(room, 'Welcome to the Wi-Fi room! Links can be found here: http://pstradingroom.weebly.com/links.html');
switch (msgType) {
case 'intro':
return this.say(room, text + 'Here is an introduction to Wi-Fi: http://tinyurl.com/welcome2wifi');
case 'rules':
return this.say(room, text + 'The rules for the Wi-Fi room can be found here: http://pstradingroom.weebly.com/rules.html');
case 'faq':
case 'faqs':
return this.say(room, text + 'Wi-Fi room FAQs: http://pstradingroom.weebly.com/faqs.html');
case 'scammers':
return this.say(room, text + 'List of known scammers: http://tinyurl.com/psscammers');
case 'cloners':
return this.say(room, text + 'List of approved cloners: http://goo.gl/WO8Mf4');
case 'tips':
return this.say(room, text + 'Scamming prevention tips: http://pstradingroom.weebly.com/scamming-prevention-tips.html');
case 'breeders':
return this.say(room, text + 'List of breeders: http://tinyurl.com/WiFIBReedingBrigade');
case 'signup':
return this.say(room, text + 'Breeders Sign Up: http://tinyurl.com/GetBreeding');
case 'bans':
case 'banappeals':
return this.say(room, text + 'Ban appeals: http://tinyurl.com/WifiBanAppeals');
case 'lists':
return this.say(room, text + 'Major and minor list compilation: http://tinyurl.com/WifiSheets');
case 'trainers':
return this.say(room, text + 'List of EV trainers: http://tinyurl.com/WifiEVtrainingCrew');
case 'youtube':
return this.say(room, text + 'Wi-Fi room\'s official YouTube channel: http://tinyurl.com/wifiyoutube');
case 'league':
return this.say(room, text + 'Wi-Fi Room Pokemon League: http://tinyurl.com/wifiroomleague');
case 'checkfc':
if (!config.googleapikey) return this.say(room, text + 'A Google API key has not been provided and is required for this command to work.');
if (arg.length < 2) return this.say(room, text + 'Usage: .wifi checkfc, [fc]');
this.wifiRoom = this.wifiroom || {docRevs: ['', ''], scammers : {}, cloners: []};
var self = this;
this.getDocMeta('0AvygZBLXTtZZdFFfZ3hhVUplZm5MSGljTTJLQmJScEE', function (err, meta) {
if (err) return self.say(room, text + 'An error occured while processing your command.');
var value = arg[1].replace(/\D/g, '');
if (value.length !== 12) return self.say(room, text + '"' + arg[1] + '" is not a valid FC.');
if (self.wifiRoom.docRevs[1] === meta.version) {
value = self.wifiRoom.scammers[value];
if (value) return self.say(room, text + '**The FC ' + arg[1] + ' belongs to a known scammer: ' + (value.length > 61 ? value + '..' : value) + '.**');
return self.say(room, text + 'This FC does not belong to a known scammer.')
}
self.wifiRoom.docRevs[1] = meta.version;
self.getDocCsv(meta, function (data) {
csv(data, function (err, data) {
if (err) return self.say(room, text + 'An error occured while processing your command.');
for (var i = 0, len = data.length; i < len; i++) {
var str = data[i][1].replace(/\D/g, '');
var strLen = str.length;
if (str && strLen > 11) {
for (var j = 0; j < strLen; j += 12) {
self.wifiRoom.scammers[str.substr(j, 12)] = data[i][0];
}
}
}
value = self.wifiRoom.scammers[value];
if (value) return self.say(room, text + '**The FC ' + arg[1] + ' belongs to a known scammer: ' + (value.length > 61 ? value.substr(0, 61) + '..' : value) + '.**');
return self.say(room, 'This FC does not belong to a known scammer.');
});
});
});
break;
/*
case 'ocloners':
case 'onlinecloners':
if (!config.googleapikey) return this.say(room, text + 'A Google API key has not been provided and is required for this command to work.');
this.wifiRoom = this.wifiroom || {docRevs: ['', ''], scammers : {}, cloners: []};
var self = this;
self.getDocMeta('0Avz7HpTxAsjIdFFSQ3BhVGpCbHVVdTJ2VVlDVVV6TWc', function (err, meta) {
if (err) {
console.log(err);
return self.say(room, text + 'An error occured while processing your command. Please report this!');
}
text = '/pm ' + by + ', ';
if (self.wifiRoom.docRevs[0] == meta.version) {
var found = [];
for (var i in self.wifiRoom.cloners) {
if (self.chatData[toId(self.wifiRoom.cloners[i][0])]) {
found.push('Name: ' + self.wifiRoom.cloners[i][0] + ' | FC: ' + self.wifiRoom.cloners[i][1] + ' | IGN: ' + self.wifiRoom.cloners[i][2]);
}
}
if (!found.length) {
self.say(room, text + 'No cloners were found online.');
return;
}
var foundstr = found.join(' ');
if(foundstr.length > 266) {
self.uploadToHastebin("The following cloners are online :\n\n" + found.join('\n'), function (link) {
self.say(room, (room.charAt(0) === ',' ? "" : "/pm " + by + ", ") + link);
});
return;
}
self.say(room, by, "The following cloners are online :\n\n" + foundstr);
return;
}
self.say(room, text + 'Cloners List changed. Updating...');
self.wifiRoom.docRevs[0] = meta.version;
self.getDocCsv(meta, function (data) {
csv(data, function (err, data) {
if (err) {
console.log(err);
this.say(room, text + 'An error occured while processing your command. Please report this!');
return;
}
data.forEach(function (ent) {
var str = ent[1].replace(/\D/g, '');
if (str && str.length >= 12) {
self.wifiRoom.cloners.push([ent[0], ent[1], ent[2]]);
}
});
var found = [];
for (var i in self.wifiRoom.cloners) {
if (self.chatData[toId(self.wifiRoom.cloners[i][0])]) {
found.push('Name: ' + self.wifiRoom.cloners[i][0] + ' | FC: ' + self.wifiRoom.cloners[i][1] + ' | IGN: ' + self.wifiRoom.cloners[i][2]);
}
}
if (!found.length) {
self.say(room, text + 'No cloners were found online.');
return;
}
var foundstr = found.join(' ');
if (foundstr.length > 266) {
self.uploadToHastebin("The following cloners are online :\n\n" + found.join('\n'), function (link) {
self.say(room, (room.charAt(0) === ',' ? "" : "/pm " + by + ", ") + link);
});
return;
}
self.say(room, by, "The following cloners are online :\n\n" + foundstr);
});
});
});
break;
*/
default:
return this.say(room, text + 'Unknown option. General links can be found here: http://pstradingroom.weebly.com/links.html');
}
},
mono: 'monotype',
monotype: function(arg, by, room) {
// links and info for the monotype room
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'monotype') {
if (!this.canUse('monotype', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
var messages = {
forums: 'The monotype room\'s forums can be found here: http://psmonotypeforum.createaforum.com/index.php',
plug: 'The monotype room\'s plug can be found here: http://plug.dj/monotype-3-am-club/',
rules: 'The monotype room\'s rules can be found here: http://psmonotype.wix.com/psmono#!rules/cnnz',
site: 'The monotype room\'s site can be found here: http://www.psmonotype.wix.com/psmono',
league: 'Information on the Monotype League can be found here: http://themonotypeleague.weebly.com/'
};
text += messages[toId(arg)] || 'Unknown option. General information can be found here: http://www.psmonotype.wix.com/psmono';
this.say(room, text);
},
survivor: function(arg, by, room) {
// contains links and info for survivor in the Survivor room
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'survivor') {
if (!this.canUse('survivor', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
var gameTypes = {
hg: "The rules for this game type can be found here: http://survivor-ps.weebly.com/hunger-games.html",
hungergames: "The rules for this game type can be found here: http://survivor-ps.weebly.com/hunger-games.html",
classic: "The rules for this game type can be found here: http://survivor-ps.weebly.com/classic.html"
};
arg = toId(arg);
if (!arg) return this.say(room, text + "The list of game types can be found here: http://survivor-ps.weebly.com/themes.html");
text += gameTypes[arg] || "Invalid game type. The game types can be found here: http://survivor-ps.weebly.com/themes.html";
this.say(room, text);
},
games: function(arg, by, room) {
// lists the games for the games room
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'gamecorner') {
if (!this.canUse('games', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
this.say(room, text + 'Game List: 1. Would You Rather, 2. NickGames, 3. Scattegories, 4. Commonyms, 5. Questionnaires, 6. Funarios, 7. Anagrams, 8. Spot the Reference, 9. Pokemath, 10. Liar\'s Dice');
this.say(room, text + '11. Pun Game, 12. Dice Cup, 13. Who\'s That Pokemon?, 14. Pokemon V Pokemon (BST GAME), 15. Letter Getter, 16. Missing Link, 17. Parameters! More information can be found here: http://psgamecorner.weebly.com/games.html');
},
thp: 'happy',
thehappyplace: 'happy',
happy: function(arg, by, room) {
// info for The Happy Place
if (config.serverid !== 'showdown') return false;
var text = '';
if (room === 'thehappyplace') {
if (!this.canUse('happy', room, by)) text += '/pm ' + by + ', ';
} else if (room.charAt(0) !== ',') {
return false;
}
arg = toId(arg);
if (arg === 'askstaff' || arg === 'ask' || arg === 'askannie') {
text += "http://thepshappyplace.weebly.com/ask-the-staff.html";
} else {
text += "The Happy Place, at its core, is a friendly environment for anyone just looking for a place to hang out and relax. We also specialize in taking time to give advice on life problems for users. Need a place to feel at home and unwind? Look no further!";
}
this.say(room, text);
},
/**
* Jeopardy commands
*
* The following commands are used for Jeopardy in the Academics room
* on the Smogon server.
*/
b: 'buzz',
buzz: function(arg, by, room) {
if (this.buzzed || !this.canUse('buzz', room, by) || room.charAt(0) === ',') return false;
this.say(room, '**' + by.substr(1) + ' has buzzed in!**');
this.buzzed = by;
this.buzzer = setTimeout(function(room, buzzMessage) {
this.say(room, buzzMessage);
this.buzzed = '';
}.bind(this), 7 * 1000, room, by + ', your time to answer is up!');
},
reset: function(arg, by, room) {
if (!this.buzzed || !this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
clearTimeout(this.buzzer);
this.buzzed = '';
this.say(room, 'The buzzer has been reset.');
},
};