-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommands.js
1179 lines (1136 loc) · 54.6 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
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* This is the file where the bot commands are located
*
* @license MIT license
*/
const MESSAGES_TIME_OUT = 7 * 24 * 60 * 60 * 1000;
var http = require('http');
var sys = require('sys');
// Lists for random generator commands
var adjectives = ["crystal", "floating", "eternal-dusk", "sunset", "snowy", "rainy", "sunny", "chaotic", "peaceful", "colorful", "gooey", "fiery", "jagged", "glass", "vibrant",
"rainbow", "foggy", "calm", "demonic", "polygonal", "glistening", "sexy", "overgrown", "frozen", "dark", "mechanical", "mystic", "steampunk", "subterranean", "polluted", "bleak",
"dank", "smooth", "vast", "pixelated", "enigmatic", "illusionary", "sketchy", "spooky", "flying", "legendary", "cubic", "moist", "oriental", "fluffy", "odd", "fancy", "strange",
"authentic", "bustling", "barren", "cluttered", "creepy", "dangerous", "distant", "massive", "exotic", "tainted", "filthy", "flawless", "forsaken", "frigid", "frosty", "grand",
"grandiose", "grotesque", "harmful", "harsh", "hospitable", "hot", "jaded", "meek", "weird", "awkward", "silly", "cursed", "blessed", "drought-stricken", "futuristic", "ancient",
"medieval", "gothic", "radioactive"
];
var locations = ["river", "island", "desert", "forest", "jungle", "plains", "mountains", "mesa", "cave", "canyon", "marsh", "lake", "plateau", "tundra", "volcano", "valley",
"waterfall", "atoll", "asteroid", "grove", "treetops", "cavern", "beach", "ocean", "heavens", "abyss", "city", "crag", "planetoid", "harbor", "evergreen", "cabin",
"hill", "field", "ship", "glacier", "estuary", "wasteland", "clouds", "chamber", "ruin", "tomb", "park", "closet", "terrace", "hot air balloon", "shrine", "room", "swamp", "road",
"path", "gateway", "school", "building", "vault", "pool", "pit", "temple", "lagoon", "prison", "harem", "mine", "catacombs", "rainforest", "laboratory", "library", "stadium",
"museum", "mansion", "carnival", "amusement park", "farm", "factory", "castle", "spaceship", "space station", "cafe", "theater", "island", "hospital", "ruins", "bazaar"
];
var characterAdjectives = ["sturdy", "helpless", "young", "rugged", "odd-looking", "amusing", "dynamic", "exuberant", "quirky", "awkward", "elderly", "adolescent", "'ancient'",
"odd", "funny-looking", "tall", "short", "round", "blind",
];
var characterTypes = ["Marksman", "Adventurer", "Pokemon Trainer", "Pokemon", "Dragonkin", "Chef", "Businessman", "Kitsune", "Youkai", "...thing", "Archer", "Taxi Driver",
"Dentist", "Demon", "Paladin", "Writer", "Diety", "Spy", "Goverment Agent", "Farmer", "Teacher", "Warrior", "Athlete", "Artist", "Assassin", "Beast", "Journalist",
"Designer", "Doctor", "Vampire", "Time Traveller", "Alien", "Butler", "Police Officer", "Toymaker", "Student", "Photographer", "Mage", "Computer Programmer"
];
var perks = ["kind of heart", "powerful", "handsome", "ambitious", "amiable", "brave", "rational", "witty", "honest", "agile", "athletic", "quick on their feet", "assertive",
"fearless", "intelligent", "persistent", "philosophical", "pioneering", "quiet", "wealthy", "not afraid to voice their opinion", "quick-witted", "lucky", "friendly", "neat",
"sympathetic", "sincere", "mysterious", "loyal", "trustworthy", "imaginative", "gentle"
];
var debuffs = ["sly", "unclean", "smelly", "obnoxiously loud", "fond of 'tricks'", "fond of 'games'", "fond of 'jokes'", "prone to 'accidentally' taking others' things", "cocky",
"prone to falling over", "prone to bad luck at times", "clingy", "foolish", "fussy", "greedy", "gullible", "impatient", "inconsiderate", "lazy", "moody", "obsessive",
"narrow-minded", "patronizing", "resentful", "unreliable", "vague", "weak-willed", "egotistical", "sensitive", "Grammar Nazi-ish", "'bitchy'", "emotionally scarred",
"overly-serious", "volatile", "morally scrupulous", "lacking of empathy", "prone to overreacting", "overbearing", "prone to panic attacks", "self-pessimistic"
];
var genres = ["Action", "Adventure", "Comedy", "Crime", "Drama", "Fantasy", "Historical", "Horror", "Mystery", "Philosophical", "Romance",
"Saga", "Satire", "Science Fiction", "Thriller"
];
var roles = ["Protagonist", "Antagonist", "Major character", "Minor character"];
var pronouns = {'male': 'he', 'female': 'she', 'hermaphrodite': 'shi', 'neuter': 'they'};
var possessivePronouns = {'male': 'His', 'female': 'Her', 'hermaphrodite': 'Hir', 'neuter': 'Their'};
var types = ["Normal", "Fire", "Water", "Electric", "Grass", "Ice", "Fighting", "Poison", "Flying", "Ground", "Psychic", "Bug", "Rock", "Ghost", "Dragon", "Dark", "Steel", "Fairy"];
exports.commands = {
/**
* Help commands
*
* These commands are here to provide information about the bot.
*/
about: function (arg, by, room) {
var text = this.hasRank(by, '#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + "**Writing Bot** by AxeBane & sirDonovan __(forked from Pokémon Showdown Bot by: Quinella, TalkTakesTime, and Morfent)__");
},
help: 'guide',
guide: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/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 bot\'s 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 (config.excepts.indexOf(toId(by)) === -1) return false;
try {
this.uncacheTree('./commands.js');
Commands = require('./commands.js').commands;
this.say(room, 'Reloaded. .w.');
console.log(by + ' reloaded the bot.');
} catch (e) {
error('failed to reload: ' + sys.inspect(e));
}
},
do: function (arg, by, room) {
if (!this.hasRank(by, '#')) return false;
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;
if (toId(arg) === "configpass") return false;
try {
var result = eval(arg.trim());
this.say(room, JSON.stringify(result));
} catch (e) {
this.say(room, e.name + ": " + e.message);
}
},
uptime: function (arg, by, room) {
var text = config.excepts.indexOf(toId(by)) < 0 ? '/pm ' + by + ', **Uptime:** ' : '**Uptime:** ';
var divisors = [52, 7, 24, 60, 60];
var units = ['week', 'day', 'hour', 'minute', 'second'];
var buffer = [];
var uptime = ~~(process.uptime());
do {
var divisor = divisors.pop();
var unit = uptime % divisor;
buffer.push(unit > 1 ? unit + ' ' + units.pop() + 's' : unit + ' ' + units.pop());
uptime = ~~(uptime / divisor);
} while (uptime);
switch (buffer.length) {
case 5:
text += buffer[4] + ', ';
/* falls through */
case 4:
text += buffer[3] + ', ';
/* falls through */
case 3:
text += buffer[2] + ', ' + buffer[1] + ', and ' + buffer[0];
break;
case 2:
text += buffer[1] + ' and ' + buffer[0];
break;
case 1:
text += buffer[0];
break;
}
this.say(room, text);
},
/**
* 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,
'false': false,
'+': '+',
'%': '%',
'@': '@',
'&': '&',
'#': '#',
'~': '~',
on: true,
enable: true,
'true': 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/false, +, %, @, &, #, ~, on/enable/true.');
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.
*/
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);
},
//This is a template for all Random Commands; please don't use this as an actual command.
randomcommands: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var variableone = list1[Math.floor(list1.length * Math.random())];
var variabletwo = list2[Math.floor(list2.length * Math.random())];
this.say(room, text + "Randomly generated thing: __" + variableone + " " + variabletwo + "__.");
},
//Random Commands Section!
//Place all 'random thing generator' commands in this area!
randchar: 'randomcharacter',
chargen: 'randomcharacter',
genchar: 'randomcharacter',
randomcharacter: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var adjective = characterAdjectives[Math.floor(characterAdjectives.length * Math.random())];
var type = characterTypes[Math.floor(characterTypes.length * Math.random())];
var role = roles[Math.floor(roles.length * Math.random())];
var gender = ["male", "female"][Math.floor(2 * Math.random())];
if (Math.floor(Math.random() * 4200 < 20)) var gender = "hermaphrodite";
if (Math.floor(Math.random() * 4200 < 10) || type === "...thing") var gender = "neuter";
var pronoun = pronouns[gender];
var possessivePronoun = possessivePronouns[gender];
var perkList = perks.slice(0);
var perk1 = perkList[Math.floor(perkList.length * Math.random())];
perkList.splice(perkList.indexOf(perk1), 1);
var perk2 = perkList[Math.floor(perkList.length * Math.random())];
perkList.splice(perkList.indexOf(perk2), 1);
var perk3 = perkList[Math.floor(perkList.length * Math.random())];
var debuff = debuffs[Math.floor(debuffs.length * Math.random())];
this.say(room, text + "Randomly generated character: __A " + gender + ", " + adjective + " " + type + " (" + role + "). " + possessivePronoun + " positive factors include: " + perk1 + ", " + perk2 + ", and " + perk3 + ", though " + pronoun + (gender === "neuter" ? " are" : " is") + " unfortunately rather " + debuff + ".__");
},
gentype: 'randomtype',
randtype: 'randomtype',
randomtype: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
arg = toId(arg);
if (arg && arg !== 'single' && arg !== 'dual') this.say(room, text + "Please input either 'single' or 'dual' as arguments, or leave it blank for a random decision. Continuing as if you left it blank.");
var firstType = types[Math.floor(types.length * Math.random())];
if (arg !== 'single' && (arg === 'dual' || Math.floor(Math.random() * 2))) {
var secondType = types[Math.floor(types.length * Math.random())];
while (firstType === secondType) {
secondType = types[Math.floor(types.length * Math.random())];
}
}
this.say(room, text + "Randomly generated type: __" + firstType + (secondType ? "/" + secondType : "") + "__.");
},
randstats: 'randomstats',
randomstats: function (arg, by, room, shuffle) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
arg = parseInt(arg);
if (arg && (isNaN(arg) || arg < 30 || arg > 780)) return this.say(room, text + "Specified BST must be a whole number between 30 and 780.");
var bst = arg ? Math.floor(arg) : Math.floor(580 * Math.random()) + 200;
var stats = [0, 0, 0, 0, 0, 0];
var currentST = 0;
var leveler = 2 * (Math.floor(Math.random() + 1));
for (var j = 0; j < leveler; j++) {
for (var i = 0; i < 6; i++) {
var randomPart = Math.floor((bst / (leveler * 6)) * Math.random()) + 1;
stats[i] += randomPart;
currentST += randomPart;
}
}
if (currentST > bst) {
for (var k = currentST; k > bst; k--) {
stats[Math.floor(5 * Math.random()) + 1] -= 1;
}
} else if (currentST < bst) {
for (var k = currentST; k < bst; k++) {
stats[Math.floor(5 * Math.random()) + 1] += 1;
}
}
stats = this.shuffle(stats);
this.say(room, text + "Randomly generated stats: HP: " + stats[0] + " Atk: " + stats[1] + " Def: " + stats[2] + " SpA: " + stats[3] + " SpD: " + stats[4] + " Spe: " + stats[5] + " BST: " + bst);
},
rollpokemon: 'randpokemon',
randpoke: 'randpokemon',
randompoke: 'randpokemon',
randompokemon: 'randpokemon',
randpokemon: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var randompokes = [];
var parameters = [];
/** OBJECT KEY
* 0 = will reject roll if it has property
* 1 = property will not affect roll
* 2 = roll will be rejected if it lacks this property
*/
var conditions = {"uber":1, "legend":1, "nfe":1, "mega":1, "forms":1, "shiny":1};
var types = {"normal":1, "fire":1, "water":1, "grass":1, "electric":1, "ice":1, "fighting":1, "poison":1, "ground":1, "flying":1, "psychic":1, "bug":1, "rock":1, "ghost":1, "dragon":1, "dark":1, "steel":1, "fairy":1};
var singleType = false;
var noDt = {"Unown":1, "Shellos":1, "Gastrodon":1, "Deerling":1, "Sawsbuck":1, "Vivillon":1, "Flabebe":1, "Floette":1, "Florges":1, "Furfrou":1};
var pokequantity = 1;
if (arg) {
var parameters = arg.toLowerCase().split(", ");
var hasBeenSet = false;
for (var j = 0; j < parameters.length; j++) {
if (parameters[j] == parseInt(parameters[j], 10)) {
if (hasBeenSet) return this.say(room, text + "Please only specify number of pokemon once");
if (parameters[j] < 1 || parameters[j] > 6) return this.say(room, text + "Quantity of random pokemon must be between 1 and 6.");
pokequantity = parameters[j];
hasBeenSet = true;
continue;
}
var notGate = false;
if (parameters[j].charAt(0) === '!') {
notGate = true;
parameters[j] = parameters[j].substr(1);
}
//argument alias list
switch (parameters[j]) {
case "legendary": parameters[j] = "legend"; break;
case "fe": parameters[j] = "nfe"; notGate = !notGate; break;
case "ubers": parameters[j] = "uber"; break;
}
if (parameters[j] in conditions) {
if (conditions[parameters[j]] !== 1) return this.say(room, text + "Cannot include both '" + parameters[j] + "' and '!" + parameters[j] + "'.");
if (notGate) {
if (parameters[j] === 'forms') conditions.mega = 0;
conditions[parameters[j]] = 0;
} else {
conditions[parameters[j]] = 2;
}
continue;
}
if (parameters[j].indexOf(' type') > -1) parameters[j] = parameters[j].substr(0, parameters[j].length - 5);
if (parameters[j] in types) {
if (types[parameters[j]] !== 1) return this.say(room, text + "Cannot include both '" + parameters[j] + "' and '!" + parameters[j] + "'.");
if (notGate) {
types[parameters[j]] = 0;
} else {
types[parameters[j]] = 2;
singleType = true;
}
continue;
} else {
return this.say(room, text + "Parameter '" + parameters[j] + "' not recognized.");
}
}
//More complex checks to prevent it getting stuck searching for combinations that don't exist
if (conditions.forms === 2 && singleType) return this.say(room, text + "The parameter 'forms' must be used by itself.");
if ((conditions.uber === 2 && conditions.legend === 0 && pokequantity > 3) || (conditions.mega === 2 && conditions.uber === 2 && pokequantity > 1) ||
(conditions.nfe === 2 && (conditions.uber === 2 || conditions.legend === 2 || conditions.mega === 2))) return this.say(room, text + "Invalid generation conditions.");
if (singleType) {
if (conditions.uber === 2 || conditions.legend === 2 || conditions.mega === 2) return this.say(room, text + "Invalid generation conditions.");
for (var set in types) {
if (types[set] === 1) types[set] = 0;
}
}
}
if (pokequantity == 1 && room.charAt(0) !== ',' && this.hasRank(by, '+%@#&~')) text = '!dt ';
var attempt = -1;
var dexNumbers = [];
if (parameters.length > 0) {
//create an array for all dex numbers and then shuffle it
for (var g = 0; g < 722; g++) {
dexNumbers.push(g);
}
dexNumbers = this.shuffle(dexNumbers);
}
for (var i = 0; i < pokequantity; i++) {
attempt++;
if (attempt > 721) {
console.log('randpoke fail: ' + parameters);
return this.say(room, text + "Could not find " + pokequantity + " unique Pokemon with ``" + parameters.join(', ') + "``");
}
var skipPoke = false;
if (parameters.length > 0) {
var pokeNum = dexNumbers[attempt];
} else {
var pokeNum = Math.floor(722 * Math.random());
}
if (conditions.uber === 2 && !Pokedex[pokeNum].uber) {i--; continue;}
if (conditions.legend === 2 && !Pokedex[pokeNum].legend) {i--; continue;}
if (conditions.nfe === 2 && !Pokedex[pokeNum].nfe) {i--; continue;}
if (conditions.mega === 2 && !Pokedex[pokeNum].mega) {i--; continue;}
if (conditions.forms === 2 && !Pokedex[pokeNum].forms) {i--; continue;}
if (conditions.uber === 0 && Pokedex[pokeNum].uber) {i--; continue;}
if (conditions.legend === 0 && Pokedex[pokeNum].legend) {i--; continue;}
if (conditions.nfe === 0 && Pokedex[pokeNum].nfe) {i--; continue;}
for (var h = 0; h < Pokedex[pokeNum].type.length; h++) {
var currentType = Pokedex[pokeNum].type[h].toLowerCase();
if (types[currentType] !== 0) break;
skipPoke = true;
}
if (skipPoke) {i--; continue;}
if (Pokedex[pokeNum].mega && conditions.mega !== 0) {
var buffer = Pokedex[pokeNum].species;
var megaNum = (conditions.mega === 2 ? 0 : -1)
megaNum += Math.floor((Pokedex[pokeNum].mega.length + (conditions.mega === 2 ? 0 : 1)) * Math.random());
if (megaNum == -1) {
randompokes.push(buffer);
} else {
randompokes.push(buffer + '-' + Pokedex[pokeNum].mega[megaNum]);
}
continue;
}
if (Pokedex[pokeNum].forms && conditions.forms !== 0) {
var formNum = Math.floor(Pokedex[pokeNum].forms.length * Math.random());
if (Pokedex[pokeNum].forms[formNum] !== "norm") {
var buffer = Pokedex[pokeNum].species;
if (text === '!dt ' && noDt[buffer] && Pokedex[pokeNum].forms[formNum] !== "eternal-flower") text = '';
randompokes.push(buffer + '-__' + Pokedex[pokeNum].forms[formNum] + '__');
continue;
}
}
randompokes.push(Pokedex[pokeNum].species);
}
for (var k = 0; k < randompokes.length; k++) {
if (Math.floor(((conditions.shiny === 2) ? 2 : 1364) * Math.random()) !== 0) continue;
randompokes[k] = '``shiny`` ' + randompokes[k];
}
this.say(room, (text === "!dt " ? text + randompokes.join(", ") : text + "Randomly generated Pokemon: " + randompokes.join(", ")));
},
randscene: 'randomlocation',
randomscene: 'randomlocation',
randlocation: 'randomlocation',
randomlocation: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var adjective = adjectives[Math.floor(adjectives.length * Math.random())];
var location = locations[Math.floor(locations.length * Math.random())];
this.say(room, text + "Randomly generated scene: __" + adjective + " " + location + "__.");
},
randmove: 'randommove',
randommove: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var types = {"normal":1, "fire":1, "water":1, "grass":1, "electric":1, "ice":1, "fighting":1, "poison":1, "ground":1, "flying":1, "psychic":1, "bug":1, "rock":1, "ghost":1, "dragon":1, "dark":1, "steel":1, "fairy":1};
var classes = {"physical": 1, "special": 1, "status": 1};
var moveQuantity = 1;
var hasBeenSet = false;
var singleType = false;
var singleClass = false;
var parameters = arg.split(', ');
if (parameters.length > 10) return this.say(room, text + "Please use 10 or fewer arguments.");
for (var i = 0; i < parameters.length; i++) {
if (parameters[i] == parseInt(parameters[i], 10)) {
if (hasBeenSet) return this.say(room, text + "Please only specify number of pokemon once");
if (parameters[i] < 1 || parameters[i] > 6) return this.say(room, text + "Quantity of random moves must be between 1 and 6.");
moveQuantity = parameters[i];
hasBeenSet = true;
continue;
}
var notGate = false;
if (parameters[i].charAt(0) === '!') {
notGate = true;
parameters[i] = parameters[i].substr(1);
}
var parameter = toId(parameters[i]);
if (parameter in types) {
if (types[parameter] === 1 && !notGate) {
types[parameter] = 2;
singleType = true;
} else if (types[parameter] === 1 && notGate) {
types[parameter] = 0;
} else {
return this.say(room, text + "Cannot include both '" + parameters[i] + "' and '!" + parameters[i] + "'.");
}
} else if (parameter in classes) {
if (classes[parameter] === 1 && !notGate) {
classes[parameter] = 2;
singleClass = true;
} else if (classes.parameter === 1 && notGate) {
classes[parameter] = 0;
} else {
return this.say(room, text + "Cannot include both '" + parameters[i] + "' and '!" + parameters[i] + "'.");
}
} else {
return this.say(room, text + "Please specify a parameter or check that you are spelling it correctly.");
}
}
if (singleType) {
if (moveQuantity > 3) return this.say(room, text + "Invalid generation conditions.");
for (var set in types) {
if (types[set] == 1) types[set] = 0;
}
}
if (singleClass) {
for (var set in classes) {
if (classes[set] == 1) classes[set] = 0;
}
}
var randomMoves = [];
for (var j = 0; j < moveQuantity; j++) {
var roll = Math.floor(614 * Math.random()) + 1;
if (types[Movedex[roll].type] === 0 || classes[Movedex[roll].class] === 0 || randomMoves.indexOf(Movedex[roll].name) > -1) {
j--;
continue;
}
randomMoves.push(Movedex[roll].name);
}
this.say(room, text + randomMoves.join(', '));
},
randstyle: 'randomgenre',
randomstyle: 'randomgenre',
randgenre: 'randomgenre',
randomgenre: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var genre1 = genres[Math.floor(genres.length * Math.random())];
var genre2 = genres[Math.floor(genres.length * Math.random())];
while (genre1 === genre2) {
genre2 = genres[Math.floor(genres.length * Math.random())];
}
this.say(room, text + "Randomly generated genre: __" + genre1 + "/" + genre2 + "__.");
},
idea: 'randomstory',
randidea: 'randomstory',
randomidea: 'randomstory',
randstory: 'randomstory',
randomstory: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
var genre1 = genres[Math.floor(genres.length * Math.random())];
if (Math.floor(Math.random() * 2)) {
var genre2 = genres[Math.floor(genres.length * Math.random())];
while (genre1 === genre2) {
genre2 = genres[Math.floor(genres.length * Math.random())];
}
}
var adjective = adjectives[Math.floor(adjectives.length * Math.random())];
var location = locations[Math.floor(locations.length * Math.random())];
var characterAdjective = characterAdjectives[Math.floor(characterAdjectives.length * Math.random())];
var type = characterTypes[Math.floor(characterTypes.length * Math.random())];
var role = roles[Math.floor(4 * Math.random())];
var gender = ["male", "female"][Math.floor(2 * Math.random())];
if (Math.floor(Math.random() * 4200 < 20)) var gender = "hermaphrodite";
if (Math.floor(Math.random() * 4200 < 10) || type === "...thing") var gender = "neuter";
var pronoun = pronouns[gender];
var possessivePronoun = possessivePronouns[gender];
var perkList = perks.slice(0);
var perk1 = perkList[Math.floor(perkList.length * Math.random())];
perkList.splice(perkList.indexOf(perk1), 1);
var perk2 = perkList[Math.floor(perkList.length * Math.random())];
perkList.splice(perkList.indexOf(perk2), 1);
var perk3 = perkList[Math.floor(perkList.length * Math.random())];
var debuff = debuffs[Math.floor(debuffs.length * Math.random())];
this.say(room, text + "Randomly generated story | Setting: __" + adjective + " " + location + "__ | Genre: __" + genre1 + (genre2 ? "/" + genre2 : "") + "__ | " + role + ": __a " + gender + ", " + characterAdjective + " " + type + ". " + possessivePronoun + " postive factors include: " + perk1 + ", " + perk2 + ", and " + perk3 + ", though " + pronoun + (gender === "neuter" ? " are" : " is") + " unfortunately rather " + debuff + ".__");
},
//End Random Commands
'word': 'wotd',
wotd: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
if (!arg || !this.hasRank(by, '+%@#&~')) return this.say(room, text + "Today's Word of the Day is **" + this.settings.wotd.word + "**: " + this.settings.wotd.kind + " [__" + this.settings.wotd.pron + "__] - " + this.settings.wotd.definition);
if (toId(arg) === 'check' || toId(arg) === 'time') return this.say(room, text + "The Word of the Day was last updated to **" + this.settings.wotd.word + "** " + this.getTimeAgo(this.settings.wotd.time) + " ago by " + this.settings.wotd.user);
arg = arg.split(', ');
if (arg.length < 4) return this.say(room, text + "Invalid arguments specified. The format is: __word__, __pronunciation__, __part of speech__, __defintion__.");
this.settings.wotd = {
word: arg[0],
pron: arg[1],
kind: arg[2],
definition: arg.slice(3).join(',').trim(),
time: Date.now(),
user: by.substr(1)
};
this.writeSettings();
this.say(room, text + "The Word of the Day has been set to '" + arg[0] + "'!");
},
site: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + "Writing Room's Website: http://pswriting.weebly.com/");
},
time: function (arg, by, room) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var hr = today.getHours();
var mi = today.getMinutes();
var se = today.getSeconds();
if (mm === 1) { this.mmm = "January"; var sea = "winter"};
if (mm === 2) { this.mmm = "Febuary"; var sea = "winter"};
if (mm === 3) { this.mmm = "March"; var sea = "spring"};
if (mm === 4) { this.mmm = "April"; var sea = "spring"};
if (mm === 5) { this.mmm = "May"; var sea = "spring"};
if (mm === 6) { this.mmm = "June"; var sea = "summer"};
if (mm === 7) { this.mmm = "July"; var sea = "summer"};
if (mm === 8) { this.mmm = "August"; var sea = "summer"};
if (mm === 9) { this.mmm = "September"; var sea = "autumn"};
if (mm === 10) { this.mmm = "October"; var sea = "autumn"};
if (mm === 11) { this.mmm = "November"; var sea = "autumn"};
if (mm === 12) { this.mmm = "December"; var sea = "winter"};
if (dd === 1) { this.ddd = "first" };
if (dd === 2) { this.ddd = "second" };
if (dd === 3) { this.ddd = "third" };
if (dd === 4) { this.ddd = "forth" };
if (dd === 5) { this.ddd = "fifth" };
if (dd === 6) { this.ddd = "sixth" };
if (dd === 7) { this.ddd = "seventh" };
if (dd === 8) { this.ddd = "eighth" };
if (dd === 9) { this.ddd = "nineth" };
if (dd === 10) { this.ddd = "tenth" };
if (dd === 11) { this.ddd = "eleventh" };
if (dd === 12) { this.ddd = "twelfth" };
if (dd === 13) { this.ddd = "thirteenth" };
if (dd === 14) { this.ddd = "forteenth" };
if (dd === 15) { this.ddd = "fifteenth" };
if (dd === 16) { this.ddd = "sixteenth" };
if (dd === 17) { this.ddd = "seventeenth" };
if (dd === 18) { this.ddd = "eighteenth" };
if (dd === 19) { this.ddd = "nineteenth" };
if (dd === 20) { this.ddd = "twentieth" };
if (dd === 21) { this.ddd = "twenty-first" };
if (dd === 22) { this.ddd = "twenty-second" };
if (dd === 23) { this.ddd = "twenty-third" };
if (dd === 24) { this.ddd = "twenty-forth" };
if (dd === 25) { this.ddd = "twenty-fifth" };
if (dd === 26) { this.ddd = "twenty-sixth" };
if (dd === 27) { this.ddd = "twenty-seventh" };
if (dd === 28) { this.ddd = "twenty-eighth" };
if (dd === 29) { this.ddd = "twenty-nineth" };
if (dd === 30) { this.ddd = "thirtieth" };
if (dd === 31) { this.ddd = "thirty-first" };
//And one more, just for good luck.
if (dd === 32) { this.ddd = "thirty-second" };
var AMorPM = "AM"
if (hr === 12) AMorPM = "PM"
if (hr === 24) { hr = 12; AMorPm = "AM" };
if (hr > 12) {
if (hr === 13) { hr = 1 };
if (hr === 14) { hr = 2 };
if (hr === 15) { hr = 3 };
if (hr === 16) { hr = 4 };
if (hr === 17) { hr = 5 };
if (hr === 18) { hr = 6 };
if (hr === 19) { hr = 7 };
if (hr === 20) { hr = 8 };
if (hr === 21) { hr = 9 };
if (hr === 22) { hr = 10 };
if (hr === 23) { hr = 11 };
AMorPM = "PM";
};
if (dd<10) { dd = "0" + dd };
if (mm<10) { mm = "0" + mm };
if (mi<10) { mi = "0" + mi };
if (se<10) { se = "0" + se };
var theDay = today.getDay();
if (theDay === 0) { this.theDay = "Sunday" };
if (theDay === 1) { this.theDay = "Monday" };
if (theDay === 2) { this.theDay = "Tuesday" };
if (theDay === 3) { this.theDay = "Wednesday" };
if (theDay === 4) { this.theDay = "Thursday" };
if (theDay === 5) { this.theDay = "Friday" };
if (theDay === 6) { this.theDay = "Saturday"};
var today = hr + ":" + mi + ":" + se + " " + AMorPM + ", " + mm + '/' + dd + '/' + yyyy + ', the ' + this.ddd + " of the " + sea + " month of " + this.mmm + ', ' + yyyy + ' (' + this.theDay + ')';
this.say(room, "The current time is: " + today);
},
newbie: 'rules',
faq: 'rules',
rules: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + "If you're new to the Writing room, be sure to read our introduction: http://pswriting.weebly.com/introduction.html Feel free to ask any room staff any questions that you may have!");
},
esupport: function (arg, by, room) {
var text = this.hasRank(by, '%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'I love you, ' + by + '.');
},
drive: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Community Drive: http://bit.do/pswritingarchives');
},
contests: 'events',
contest: 'events',
events: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Visit this page for a list of our weekly challenges and contests: http://pswriting.weebly.com/events.html');
},
hype: 'sundayscribing',
slam: 'sundayscribing',
sundayslam: 'sundayscribing',
scribing: 'sundayscribing',
sundayscribing: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + "Every week we hold a Sunday Scribing challenge in which participants are to write a story or a poem (depending on the week) based on the topic announced on Sunday. They have until the following Friday to submit it. For more info and the submission link: http://goo.gl/Ezik4q");
},
plug: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Come join our Plug.dj~! https://plug.dj/pokemon-showdown-writing-room');
},
titlehelp: 'title',
title: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Need help capitalising a title? Try out this helpful tool! http://titlecapitalization.com/');
},
poems: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Writing Room Poems: http://bit.do/PSwritingpoems');
},
stories: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Writing Room Stories: http://bit.do/PSwritingstories');
},
voice: function (arg, by, room) {
var text = this.hasRank(by, '+%@#&~') || room.charAt(0) === ',' ? '' : '/pm ' + by + ', ';
this.say(room, text + 'Interested in becoming a voice? Check out the guideines for your chance at having a shot! http://bit.do/pswritingvoicerules or http://bit.do/pswritingvoicerap');
},
announce: function (arg, by, room) {
if (!this.hasRank(by, '%@#&~')) return false;
arg = toId(arg);
if (arg === 'off') {
if (this.buzzer) clearInterval(this.buzzer);
return this.say(room, 'Announcements have been disabled.');
} else if (arg === 'on') {
var self = this;
this.buzzer = setInterval(function() {
var tips = ["Don't forget to allow people to comment on your work when it's done! Click 'Share', and set permissions accordingly.",
"We like to play writing games, too! Click 'Activities' in our room introduction (the fancy box you saw when you joined) to see what games are available!",
"Looking for feedback? Ask writers for an R/R, or a 'review for review'. It's a win-win for both parties!",
"Questions on the (+) voice rank? Read our Voice Guidelines at http://bit.do/pswritingvoiceguidlines for more information.",
"Confused as to the time? Wanting to punch timezones in the face? Look no further, for I have a fancy ``time`` command! Try it out!",
"Would you like to host your work on our cloud drive? Ask a staff member about getting your own folder!",