-
Notifications
You must be signed in to change notification settings - Fork 3
/
Merged Script.js
1473 lines (1450 loc) · 57.9 KB
/
Merged Script.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 script has all the current scripts merged together into one neat package
//report bugs to Crystal Moogle
//feel free to use it, edit it, improve it, do whatever.
//lot of stuff "borrowed" from main scripts and stackoverflow~ :3
//commands found by using ~commandlist
//currently needs 2.0.05 to fix channel links
//Config settings has been moved to ~commandslist
//Make sure to check them to set everything :x
//these things below shouldn't be touched unless you know what you're doing~
/*jshint "laxbreak":true,"shadow":true,"undef":true,"evil":true,"trailing":true,"proto":true,"withstmt":true*/
/*global sys,client, playerswarn:true, channelusers:true, playersonline:true*/
var script_url = "https://raw.github.com/CrystalMoogle/PO-User-Scripts/master/script.js"; //where the script is stored
var global = this;
var poScript, Script_Version, etext, tgreentext, flash, autoresponse, friendsflash, checkversion, clientbotname, clientbotcolour, clientbotstyle, greentext, fontcolour, fonttype, fontsize, fontstyle, commandsymbol, hilight, armessage, arstart, arend, artype, stalkwords, friends, ignore, logchannel, fchannel, auth_symbol, auth_style;
function init() { //defines all the variables that are going to be used in the script, uses default if no saved settings are found
if(sys.getVal('etext') === "true") {
etext = true;
} else {
etext = false;
}
if(sys.getVal('tgreentext') === "true") {
tgreentext = "true";
} else {
tgreentext = "false";
}
if(sys.getVal('flash') === "false") { //making sure flash is on always unless specified to not be
flash = false;
} else {
flash = true;
}
if(sys.getVal('autoresponse') === true) {
autoresponse = true;
} else {
autoresponse = false;
}
if(sys.getVal('friendsflash') === "true") {
friendsflash = true;
} else {
friendsflash = false;
}
if(sys.getVal('checkversion') === "true") {
checkversion = "true";
} else {
checkversion = "false";
}
clientbotname = "+ClientBot";
if(sys.getVal('clientbotname').length > 0) {
clientbotname = sys.getVal('clientbotname');
}
clientbotcolour = "#3DAA68";
if(sys.getVal('clientbotcolour').length > 0) {
clientbotcolour = sys.getVal('clientbotcolour');
}
clientbotstyle = "<b>";
if(sys.getVal('clientbotstyle').length > 0) {
clientbotstyle = sys.getVal('clientbotstyle');
}
greentext = '#789922';
if(sys.getVal('greentext').length > 0) {
greentext = sys.getVal('greentext');
}
fontcolour = "#000000";
if(sys.getVal('fontcolour').length > 0) {
fontcolour = sys.getVal('fontcolour');
}
fonttype = "";
if(sys.getVal('fonttype').length > 0) {
fonttype = sys.getVal('fonttype');
}
fontsize = 3;
if(sys.getVal('fontsize').length > 0) {
fontsize = sys.getVal('fontsize');
}
fontstyle = "";
if(sys.getVal('fontstyle').length > 0) {
fontstyle = sys.getVal('fontstyle');
}
commandsymbol = "~";
if(sys.getVal('commandsymbol').length > 0) {
commandsymbol = sys.getVal('commandsymbol');
}
hilight = "BACKGROUND-COLOR: #ffcc00";
if(sys.getVal('hilight').length > 0) {
hilight = sys.getVal('hilight');
}
armessage = sys.getVal('armessage');
arstart = sys.getVal('arstart');
arend = sys.getVal('arend');
artype = sys.getVal('artype');
stalkwords = [];
friends = [];
ignore = [];
logchannel = [];
fchannel = [];
if(sys.getVal('stalkwords') !== "") {
var nstalkwords = sys.getVal('stalkwords').split(",");
stalkwords = nstalkwords.concat(stalkwords);
stalkwords = eliminateDuplicates(stalkwords);
}
if(sys.getVal('friends') !== "") {
var nfriends = sys.getVal('friends').split(",");
friends = nfriends.concat(friends);
friends = eliminateDuplicates(friends);
}
if(sys.getVal('ignore') !== "") {
var nignore = sys.getVal('ignore').split(",");
ignore = nignore.concat(ignore);
ignore = eliminateDuplicates(ignore);
}
if(sys.getVal('logchannel') !== "") {
var nlogchannel = sys.getVal('logchannel').split(",");
logchannel = nlogchannel.concat(logchannel);
logchannel = eliminateDuplicates(logchannel);
}
if(sys.getVal('fchannel') !== "") {
var nfchannel = sys.getVal('fchannel').split(",");
fchannel = nfchannel.concat(fchannel);
fchannel = eliminateDuplicates(fchannel);
}
auth_symbol = [];
for(var x = 0; x < 5; x++) {
if(sys.getVal('auth: ' + x).length > 0) {
auth_symbol[x] = sys.getVal('auth: ' + x);
continue;
}
if(x === 0 || x === 4) {
auth_symbol[x] = "";
continue;
}
auth_symbol[x] = "+";
}
auth_style = [];
for(var x = 0; x < 5; x++) {
if(sys.getVal('auths: ' + x).length > 0) {
auth_style[x] = sys.getVal('auths: ' + x);
continue;
}
if(x === 0 || x === 4) {
auth_style[x] = "<b>";
continue;
}
auth_style[x] = "<i><b>";
}
playerswarn = [];
channelusers = [];
if(sys.isSafeScripts() !== true) {
checkScriptVersion();
}
}
function checkScriptVersion(bool) { //checks the current script version with the one saved on Github, if the versions do not match, then it gives a warning
var checkscript, version;
var regex = /"([^"]*)"/g;
if(bool === undefined) {
bool = false;
}
if(checkversion === "false" && bool === false) {
return;
}
sys.webCall(script_url, function (resp) {
if(resp.length === 0) {
sendBotMessage("There was an error accessing the script, paste the contents of (link) into your PO folder and restart, or wait for a client update", undefined, "https://github.com/downloads/coyotte508/pokemon-online/ssl.zip");
return;
}
checkscript = resp.split('\n');
for(var x in checkscript) {
if(checkscript[x].substr(0, 14) === "Script_Version") {
version = String(checkscript[x].match(regex));
}
}
if(version === undefined) {
sendBotMessage('There was an error with the version, please report to Crystal Moogle');
return;
}
version = version.replace(/"/g, "");
var type = {
"0": "Major Release (huge changes)",
"1": "Minor Release (new features)",
"2": "Bug fixes/Minor Update"
};
if(version !== Script_Version) {
var typeno;
var nversion = version.split('.');
var cversion = Script_Version.split('.');
for(var x in nversion) {
if(nversion[x] !== cversion[x]) {
typeno = x;
break;
}
}
if(typeno === undefined) { //this shouldn't ever happen though
return;
}
sendBotMessage("A client script update is avaiable, type: " + type[typeno] + ". Use " + commandsymbol + "updatescripts. Use " + commandsymbol + "changelog " + version + " to see the changes", undefined, script_url); //TODO make sure the script actually is a new version, rather than a previous version
return;
}
if(bool === true) {
sendBotMessage("No update detected");
}
});
}
function nameCheck(string) { //adapted from the PO Source Code
if(string.length > 20) {
return false;
}
if(string.lengh === 0) {
return false;
}
if(isPunct(string[0]) !== true && isAlnum(string[0]) !== true) {
return false;
}
var spaced = false;
var punct = false;
for(var x = 0; x < string.length; x++) {
if(string[x] === '\n' || string[x] === '%' || string[x] === '*' || string[x] === '<' || string[x] === ':' || string[x] === '(' || string[x] === ')' || string[x] === ';') {
return false;
}
if(isPunct(string[x])) {
if(punct === true) {
//Error: two punctuations are not separated by a letter/number
return false;
}
punct = true;
spaced = false;
} else if(string[x] === ' ') {
if(spaced === true) {
//Error: two spaces are following
return false;
}
spaced = true;
} else if(isAlnum(string[x])) {
//we allow another punct & space
punct = false;
spaced = false;
}
}
if(string.length === 1 && isPunct(string[0])) {
return "fixup";
}
if(isPunct(string[string.length - 1]) !== true && isAlnum(string[string.length - 1]) !== true) {
return "fixup";
}
return true;
}
function fixup(input) {
if(input.length > 0 && input[input.length - 1] === ' ') {
return input.substr(0, input.length - 1);
}
}
// Test for punctuation characters
function isPunct(i) {
return(isGraph(i) && !(isAlnum(i)));
}
// Test for printable characters (only good up to char 127)
function isGraph(i) {
var myCharCode = i.charCodeAt(0);
if((myCharCode > 32) && (myCharCode < 127)) {
return true;
}
return false;
}
// Test for letters and digits
function isAlnum(i) {
return(isDigit(i) || isAlpha(i));
}
// Test for digits
function isDigit(i) {
var myCharCode = i.charCodeAt(0);
if((myCharCode > 47) && (myCharCode < 58)) {
return true;
}
return false;
}
// Test for letters (only good up to char 127)
function isAlpha(i) {
var myCharCode = i.charCodeAt(0);
if(((myCharCode > 64) && (myCharCode < 91)) || ((myCharCode > 96) && (myCharCode < 123))) {
return true;
}
return false;
}
function eliminateDuplicates(arr) { //stolen from http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/ eliminates any duplicates that are in an array
var i,
len = arr.length,
out = [],
obj = {};
for(i = 0; i < len; i++) {
obj[arr[i]] = 0;
}
for(i in obj) {
out.push(i);
}
return out;
}
function saveToLog(message, channel) { //saves messages to a log file
var logging = false;
for(var x in logchannel) {
if(client.channelName(channel).toLowerCase() === logchannel[x].toLowerCase()) {
logging = true;
break;
}
}
if(logging === false) {
return;
}
var time = new Date();
var h = time.getHours();
var m = time.getMinutes();
var s = time.getSeconds();
var d = time.getDate();
var mo = parseInt(time.getMonth() + 1, 10);
var y = time.getFullYear();
var date = d + "-" + mo + "-" + y;
m = checkTime(m);
s = checkTime(s);
var timestamp = h + ":" + m + ":" + s;
sys.appendToFile("Channel Logs/" + client.channelName(channel) + " " + date + ".txt", "(" + timestamp + ") " + message + "\n");
}
function checkTime(i) { //adds a 0 in front of one digit minutes/seconds
if(i < 10) {
i = "0" + i;
}
return i;
}
function stripHTML(string) {
var regex = /(<([^>]+)>)/ig;
string = string.replace(regex, "");
return string;
}
function getName(string, type) { //gets the name from rainbow/me messages
var name = "";
if(type === "rainbow") {
string = stripHTML(string);
var pos = string.indexOf(': ');
if(pos !== -1) {
name = string.substring(0, pos);
if(name[0] === "+") { //auth symbol is + here rather than user defined, since the PO Server Scripts print "+" out automatically for auth
name = name.substr(1);
}
}
}
if(type === "me") {
name = string.substring(string.indexOf('<b>') + 3, string.indexOf('</b>')); //this is assuming it's used on PO Server Scripts, or any scripts that use the same /me system
}
return name;
}
function sendBotMessage(message, channel, link) { //sends a mesage with the bot name in front of it
if(channel === undefined) {
channel = client.currentChannel();
}
message = html_escape(message);
if(link === "<ping/>") {
message = message.replace(/<ping\/>/g, link);
}
if(message.indexOf("(link)") !== -1 && link !== undefined) {
message = message.replace(/\(link\)/g, "<a href ='" + link + "'>" + link + "</a>");
}
client.printChannelMessage("<font color = '" + html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + html_escape(clientbotname) + ":" + tagend(clientbotstyle) + "</font> " + message, channel, true);
return;
}
function html_escape(text) { //escapes any characters that won't appear correctly in HTMLmessages
var m = String(text);
if(m.length > 0) {
var amp = "&am" + "p;";
var lt = "&l" + "t;";
var gt = "&g" + "t;";
return m.replace(/&/g, amp).replace(/</g, lt).replace(/>/g, gt);
} else {
return "";
}
}
function tagend(string) { //automatically creates an end tag from a html tagsent to it
var newstring = string.replace(/</g, "</");
return newstring;
}
function awayFunction() { //makes the user go away if needed
if(client.ownId() === -1) { //this shouldn't happen due to Network.playerLogin but people have been complaining of crashes so gonna see if this helps
return;
}
if(sys.getVal("idle") === "true") {
client.goAway(true);
} else {
client.goAway(false);
}
}
function stalkWordCheck(string, playname, bot, channel) { //adds flashes to names/stalkwords
var ownName = html_escape(client.ownName());
var newstring = "";
if(string.toLowerCase().indexOf(ownName.toLowerCase()) !== -1 && playname !== ownName && flash !== false && bot === false && fchannel.indexOf(client.channelName(channel)) === -1) {
var name = new RegExp("\\b" + ownName + "\\b", "i");
newstring = string.replace(name, "<span style='" + hilight + "'>" + client.ownName() + "</span>");
if(newstring !== string) {
string = newstring.replace(newstring, "<i> " + newstring + "</i><ping/>");
}
}
var regex = new RegExp(sys.md5(client.ownName()), "gi");
string = string.replace(regex, client.ownName());
for(var x in stalkwords) {
var stalk = new RegExp("\\b" + stalkwords[x] + "\\b", "i");
var stalks = string.match(stalk);
if(string.toLowerCase().search(stalk) !== -1 && playname !== client.ownName() && flash !== false && bot === false && fchannel.indexOf(client.channelName(channel)) === -1) {
newstring = string.replace(stalk, "<span style='" + hilight + "'>" + stalks + "</span>");
if(newstring !== string) {
string = newstring.replace(newstring, "<i> " + newstring + "</i><ping/>");
}
}
regex = new RegExp(sys.md5(stalkwords[x]), "gi");
string = string.replace(regex, stalkwords[x]);
}
return string;
}
function htmllinks(text) { //makes sure links get linked!
var exp = /(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\(\)\[\]\/%?=~_|!:,.;']*[\-A-Z0-9+&@#\/\(\)\[\]%=~_|'])/ig;
var found = text.match(exp);
var newtext;
var newfound;
for(var x in found) {
newfound = found[x].replace(/\//g, sys.md5('/')).replace(/_/g, sys.md5('_'));
for(var y in stalkwords) {
var regex = new RegExp(stalkwords[y], "gi");
var regex1 = new RegExp(client.ownName(), "gi");
newfound = newfound.replace(regex, sys.md5(stalkwords[y])).replace(regex1, sys.md5(client.ownName()));
}
newtext = ("<a href ='" + newfound + "'>" + newfound + "</a>").replace(/&/gi, "&");
text = text.replace(found[x], newtext);
}
return encodeURIComponent(text).replace(/%20/g, " ");
}
function addExtras(text, playname, bot, channel) { //adds stalkwords/links/enriched text etc
text = htmllinks(text);
text = enrichedText(text);
text = decodeURIComponent(text);
text = client.channel(channel).addChannelLinks(text);
text = greenText(text);
text = stalkWordCheck(text, playname, bot, channel);
var md5 = new RegExp(sys.md5('/'), "g");
var md51 = new RegExp(sys.md5('_'), "g");
text = text.replace(md5, '/').replace(md51, "_");
return text;
}
function enrichedText(text) { //applies the enriched text, adapted from the PO 1.0.60 source
if(etext === false) {
return text;
}
var expi = new RegExp("%2F(\\S+)%2F(?![^\\s<]*>)", "g");
text = text.replace(expi, "<i>$1</i>");
var expii = new RegExp("%5C(\\S+)%5C(?![^\\s<]*>)", "g");
text = text.replace(expii, "<i>$1</i>");
var expb = new RegExp("\\*(\\S+)\\*(?![^\\s<]*>)", "g");
text = text.replace(expb, "<b>$1</b>");
var expu = new RegExp("_(\\S+)_(?![^\\s<]*>)", "g");
text = text.replace(expu, "<u>$1</u>");
return text;
}
function greenText(text) { //applies greentext
if(text.substr(0, 4) === ">" && tgreentext === "true") {
text = "<font color = '" + greentext + "'>" + text + "</font>";
} else {
text = "<font color = '" + fontcolour + "'>" + text;
}
return text;
}
function isSafeScripts() { //checks if safe scripts is on and if it is it sends a message
if(sys.isSafeScripts()) {
sendBotMessage("You have safescripts on, you will not be able to update your scripts through the internet, though it should help against any harmful scripts, to turn it off, untick the box in the Script Window");
return true;
}
return false;
}
function sendMessage(message, channel) { //sends a message to the user
if(channel === undefined) {
channel = client.currentChannel();
}
client.printChannelMessage(message, channel, false);
return;
}
function ignoreCheck(name) { //checks if ignored, this is used since it's possible to bypass the autoignore function by logging in via an alt then switching names
for(var i in ignore) {
if(name.toLowerCase() === ignore[i].toLowerCase()) {
client.ignore(client.id(name), true);
}
}
if(client.isIgnored(client.id(name))) {
return true;
}
return false;
}
function sendHtmlMessage(message, channel) { //sends a html message to the user
if(channel === undefined) {
channel = client.currentChannel();
}
client.printChannelMessage(message, channel, true);
return;
}
function commandHandler(command, commandData, channel) {
if(command === "commandlist" || command === "commandslist") { //handles all the commands
sys.stopEvent();
sendMessage("*** Client Commands ***");
sendMessage(commandsymbol + "etext on/off: Allows you to turn Enriched text on/off");
sendMessage(commandsymbol + "greentext on/off: Allows you to turn greentext on/off");
sendMessage(commandsymbol + "greentextcolo(u)r colour: Allows you to change your greentext colour");
sendMessage(commandsymbol + "idle on/off: Allows you to turn auto-idle on/off");
sendMessage(commandsymbol + "goto channel: Allows you to switch to that channel (joins if you're not in that channel)");
sendMessage(commandsymbol + "reconnect: Allows you to reconnect to the server (Does not work if kicked/IP changes)");
sendMessage(commandsymbol + "changename: Allows you to change your name");
sendMessage(commandsymbol + "stalkwords: Allows you to view your current stalkwords");
sendMessage(commandsymbol + "[add/remove]stalkword word: Allows you to add/remove stalkwords");
sendMessage(commandsymbol + "flash on/off:channel: Allows you to turn flashes on/off. Channel is an optional parameter to turn flashes off for one channel");
sendMessage(commandsymbol + "friends: Allows you to view your current friends and their online status");
sendMessage(commandsymbol + "[add/remove]friend friend: Allows you to add/remove friends");
sendMessage(commandsymbol + "friendflash on/off: Allows you turn friend flashes on/off");
sendMessage(commandsymbol + "ignorelist: Allows you to view your autoignore list");
sendMessage(commandsymbol + "[add/remove]ignore user: Allows you to add/remove people from your ignore list");
sendMessage(commandsymbol + "logchannels: Allows you to view your log channels");
sendMessage(commandsymbol + "[add/remove]logchannel channel: Allows you to add/remove channels from the channels you log");
sendMessage(commandsymbol + "changebotcolo(u)r colour: Allows you to change the bot's (client and server) colour");
sendMessage(commandsymbol + "changebotname name: Allows you to change clientbot's name");
sendMessage(commandsymbol + "changebotstyle htmltag: Allows you to change the style of the client bot (start tags only)");
sendMessage(commandsymbol + "resetbot: Allows you to reset the bot to its default values");
sendMessage(commandsymbol + "checkversion: Allows you to check for updates");
sendMessage(commandsymbol + "updatealert on/off: Allows you to get automatically alerted about new versions");
sendMessage(commandsymbol + "changelog version: Allows you to view the changelog");
sendMessage(commandsymbol + "versions: Allows you to view the current versions");
sendMessage(commandsymbol + "updatescripts: Allows you to updatescripts");
sendMessage(commandsymbol + "authsymbols auth:symbol: Allows you to change authsymbols. If symbol is left blank, then it removes the current auth symbol");
sendMessage(commandsymbol + "authstyle auth:htmltag: Allows you to change the name style of auth. Make sure to use start tags only. If htmltag is left blank, then it will remove the current style");
sendMessage(commandsymbol + "highlight colour: Allows you to change the colour of the highlight when flashed");
sendMessage(commandsymbol + "commandsymbol symbol: Allows you to change the command symbol");
sendMessage(commandsymbol + "armessage: Sets your autoresponse message");
sendMessage(commandsymbol + "artype [command/time]: Sets how to activate your autoresponse, time does it between certain hours, command activates it by command");
sendMessage(commandsymbol + "ar[on/off]: Turns your autoresponse on/off if type if command");
sendMessage(commandsymbol + "artime hour1:hour2: Sets your autoresponse to activate between hour1 and hour2");
sendMessage(commandsymbol + "fontcommands: Shows you the font command details");
sendMessage(commandsymbol + "damagecalc [s]atk:move power:modifier:[s]def:HP: Basic damage calculator");
sendMessage("Explanation: [s]atk is the attacking pokémon's exact stat (not base), move power is the move's base power, modifier is any modifiers that need to be added (e.g. life orb is 1.3), HP/[s]def is the defending pokémon's exact HP/Def stats (not base)");
sendMessage("Example: " + commandsymbol + "damagecalc 100:100:1.3:100:100 will show you the result of a pokémon with 100 [s]atk, with Life Orb using a 100bp move against a pokémon with 100HP/[s]def");
sendMessage("");
sendBotMessage('If you ever forget your command symbol, type reset symbol to revert it back to "~"');
return;
}
if(command === "fontcommands") {
sys.stopEvent();
sendMessage("*** Font Command Details ***");
sendMessage("Command: " + commandsymbol + "font type:modifier");
sendMessage("Type: Types are 'colo(u)r', 'style', 'type', 'size'");
sendMessage("Colour: Defines the colour of the font");
sendMessage("Style: Defines the style of the font (bold/italics/underline)");
sendMessage("Type: Defines the font face");
sendMessage("Size: Defines the font size");
sendMessage("Modifier: Modifiers vary from types. Colour modifiers are any valid colour. Style is any valid HTML start tag. Type is any type of font face. Size is any number");
sendMessage("Example: " + commandsymbol + "font color:red, will make all text red");
return;
}
if(command === "etext") {
sys.stopEvent();
if(commandData === "on") {
etext = true;
sys.saveVal('etext', true);
sendBotMessage("You turned Enriched text on!");
return;
}
if(commandData === "off") {
etext = false;
sys.saveVal('etext', false);
sendBotMessage("You turned Enriched text off!");
return;
}
sendBotMessage("Please use on/off");
}
if(command === "greentext") {
sys.stopEvent();
if(commandData === "on") {
tgreentext = "true";
sys.saveVal('tgreentext', true);
sendBotMessage("You turned greentext on!");
return;
}
if(commandData === "off") {
tgreentext = "false";
sys.saveVal('tgreentext', false);
sendBotMessage("You turned greentext off!");
return;
}
sendBotMessage("Please use on/off");
}
if(command === "idle") {
sys.stopEvent();
if(commandData === "on") {
client.goAway(true);
sys.saveVal('idle', true);
sendBotMessage("You turned auto-idling on!");
return;
}
if(commandData === "off") {
client.goAway(false);
sys.saveVal('idle', false);
sendBotMessage("You turned auto-idling off!");
return;
}
sendBotMessage("Please use on/off");
}
if(command === "checkversion") {
sys.stopEvent();
if(isSafeScripts()) {
return;
}
sendBotMessage("Checking script version please wait. (Current Version: " + Script_Version + ")");
checkScriptVersion(true);
return;
}
if(command === "updatealert") {
sys.stopEvent();
if(isSafeScripts()) {
return;
}
if(commandData === "on") {
checkversion = true;
sys.saveVal('checkversion', true);
sendBotMessage("You now get alerted about new versions");
checkScriptVersion();
return;
}
if(commandData === "off") {
checkversion = false;
sys.saveVal('checkversion', false);
sendBotMessage("You no longer get alerted about new versions");
return;
}
sendBotMessage("Please use on/off");
}
if(command === "goto") {
sys.stopEvent();
var channela = commandData.toLowerCase();
var channels = client.channelNames();
for(var x in channels) {
if(channela === channels[x].toLowerCase()) {
channela = channels[x];
if(!client.hasChannel(client.channelId(channela))) {
client.join(channela);
return;
}
client.activateChannel(channela);
return;
}
}
sendBotMessage("That is not a channel!");
}
if(command === "reconnect") {
sys.stopEvent();
client.reconnect();
return;
}
if(command === "stalkwords") {
sys.stopEvent();
sendBotMessage("Your stalkwords are: " + stalkwords);
}
if(command === "addstalkword") {
sys.stopEvent();
var nstalkwords = commandData;
if(nstalkwords.search(/, /g) !== -1 || nstalkwords.search(/ ,/g) !== -1) {
nstalkwords = nstalkwords.replace(/, /g, ",").replace(/ ,/g, ",");
}
nstalkwords = nstalkwords.split(",");
stalkwords = eliminateDuplicates(nstalkwords.concat(stalkwords));
sys.saveVal('stalkwords', stalkwords.toString());
sendBotMessage("You added " + commandData + " to your stalkwords!");
}
if(command === "removestalkword") {
sys.stopEvent();
commandData = commandData.toLowerCase();
for(var x in stalkwords) {
if(stalkwords[x].toLowerCase() === commandData) {
stalkwords.splice(x, 1);
sys.saveVal('stalkwords', stalkwords.toString());
sendBotMessage("You removed " + commandData + " from your stalkwords!");
return;
}
}
sendBotMessage("" + commandData + " is not a stalkword!");
}
if(command === "flash" || command === "flashes") {
sys.stopEvent();
commandData = commandData.split(':');
if(commandData.length < 2 || commandData[1] === "") {
if(commandData[0] === "on") {
flash = true;
sys.saveVal('flash', true);
sendBotMessage("You turned flashes on!");
return;
} else {
flash = false;
sys.saveVal('flash', false);
sendBotMessage("You turned flashes off!");
return;
}
}
var nfchannel = commandData[1];
if(commandData[0] === "off") {
if(nfchannel.search(/, /g) !== -1 || nfchannel.search(/ ,/g) !== -1) {
nfchannel = nfchannel.replace(/, /g, ",").replace(/ ,/g, ",");
}
nfchannel = nfchannel.split(",");
fchannel = eliminateDuplicates(nfchannel.concat(fchannel));
sys.saveVal('fchannel', fchannel.toString());
sendBotMessage("You won't be flashed in " + commandData[1]);
} else {
commandData[1] = commandData[1].toLowerCase();
for(var x in fchannel) {
if(fchannel[x].toLowerCase() === commandData[1]) {
fchannel.splice(x, 1);
sys.saveVal('fchannel', fchannel.toString());
sendBotMessage("You will be flashed in " + commandData[1]);
return;
}
}
}
}
if(command === "friends") {
sys.stopEvent();
var check = [];
for(var x in friends) {
if(client.id(friends[x]) !== -1) {
check.push("<a href='po:pm/" + client.id(friends[x]) + "'>" + friends[x] + "</a> <font color='green'>(online)</font>");
continue;
}
check.push(friends[x] + " <font color='red'>(offline)</font>");
}
sendHtmlMessage("<font color = '" + html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + html_escape(clientbotname) + ":" + tagend(clientbotstyle) + "</font> Your friends are: " + check);
return;
}
if(command === "addfriend") {
sys.stopEvent();
var nfriends = commandData;
if(nfriends.search(/, /g) !== -1 || nfriends.search(/ ,/g) !== -1) {
nfriends = nfriends.replace(/, /g, ",").replace(/ ,/g, ",");
}
nfriends = nfriends.split(",");
friends = eliminateDuplicates(nfriends.concat(friends));
sys.saveVal('friends', friends.toString());
sendBotMessage("You added " + commandData + " to your friends!");
}
if(command === "removefriend") {
sys.stopEvent();
commandData = commandData.toLowerCase();
for(var x in friends) {
if(friends[x].toLowerCase() === commandData) {
friends.splice(x, 1);
sys.saveVal('friends', friends.toString());
sendBotMessage("You removed " + commandData + " from your friends!");
return;
}
}
sendBotMessage(commandData + " is not a friend!");
}
if(command === "friendflash" || command === "friendsflash") {
sys.stopEvent();
if(commandData === "on") {
friendsflash = true;
sys.saveVal('friendsflash', true);
sendBotMessage("You turned friend flashes on!");
return;
} else {
friendsflash = false;
sys.saveVal('friendsflash', false);
sendBotMessage("You turned friend flashes off!");
}
return;
}
if(command === "ignorelist") {
sys.stopEvent();
sendBotMessage("Your ignorelist is: " + ignore);
}
if(command === "addignore") {
sys.stopEvent();
if(commandData === client.ownName()) {
return;
}
var nignore = commandData;
if(nignore.search(/, /g) !== -1 || nignore.search(/ ,/g) !== -1) {
nignore = nignore.replace(/, /g, ",").replace(/ ,/g, ",");
}
nignore = nignore.split(",");
ignore = eliminateDuplicates(nignore.concat(ignore));
sys.saveVal('ignore', ignore.toString());
if(client.id(commandData) !== -1) {
client.ignore(client.id(commandData), true);
}
sendBotMessage("You added " + commandData + " to your ignorelist!");
}
if(command === "removeignore") {
sys.stopEvent();
commandData = commandData.toLowerCase();
for(var x in ignore) {
if(ignore[x].toLowerCase() === commandData) {
ignore.splice(x, 1);
sys.saveVal('ignore', ignore.toString());
if(client.id(commandData) !== -1) {
client.ignore(client.id(commandData), false);
}
sendBotMessage("You removed " + commandData + " from your ignorelist!");
return;
}
}
sendBotMessage(commandData + " is not on the ignorelist!");
}
if(command === "changebotname") {
sys.stopEvent();
if(commandData === undefined) {
return;
}
clientbotname = commandData;
sendBotMessage(clientbotname + " is now your clientbot's name!");
sys.saveVal("clientbotname", clientbotname);
return;
}
if(command === "changebotstyle") {
sys.stopEvent();
if(commandData === undefined) {
clientbotstyle = "";
sendBotMessage("You removed your client bot style!");
sys.saveVal("clientbotstyle", clientbotstyle);
return;
}
clientbotstyle = commandData;
sendBotMessage(clientbotstyle + " is now your clientbot's style!");
sys.saveVal("clientbotstyle", clientbotstyle);
return;
}
if(command === "changebotcolour" || command === "changebotcolor") {
sys.stopEvent();
if(commandData === undefined) {
return;
}
clientbotcolour = commandData;
sendBotMessage(clientbotcolour + " is now your clientbot's colour!");
sys.saveVal("clientbotcolour", clientbotcolour);
return;
}
if(command === "greentextcolor" || command === "greentextcolour") {
sys.stopEvent();
if(commandData === undefined || commandData === "") {
greentext = '#789922';
sendBotMessage(greentext + " is now your greentext colour!");
sys.saveVal("greentext", greentext);
return;
}
greentext = commandData;
sendBotMessage(greentext + " is now your greentext colour!");
sys.saveVal("greentext", greentext);
return;
}
if(command === "resetbot") {
sys.stopEvent();
clientbotcolour = "#3DAA68";
clientbotname = "+ClientBot";
sys.saveVal("clientbotcolour", clientbotcolour);
sys.saveVal("clientbotname", clientbotname);
sendBotMessage("You reset your bot to default values");
return;
}
if(command === "font") {
sys.stopEvent();
if(commandData === undefined) {
return;
}
var type = commandData.split(":");
if(type.length < 1) {
sendBotMessage('Usage is ' + commandsymbol + 'font type:modifier');
return;
}
var modifier = type[1];
var types = ["colour", "color", "style", "type", "size"];
if(types.indexOf(type[0]) === -1) {
sendBotMessage('Invalid type, valid types are: colo(u)r, style, type, size');
return;
}
if(type[0] === "colour" || type[0] === "color") {
if(modifier === undefined || modifier === "") {
modifier = "#000000";
fontcolour = modifier;
sys.saveVal('fontcolour', modifier);
sendBotMessage("You changed your font colour to the default");
return;
}
fontcolour = modifier;
sys.saveVal('fontcolour', modifier);
sendBotMessage("You changed your font colour to: " + modifier);
return;
}
if(type[0] === "style") {
if(modifier === undefined || modifier === "") {
modifier = "";
fontstyle = modifier;
sys.saveVal('fontstyle', modifier);
sendBotMessage("You changed your font style to the default");
return;
}
if(modifier.indexOf('</') !== -1) {
sendBotMessage("End tags are not needed, please only use start ones");
return;
}
fontstyle = modifier;
sys.saveVal('fontstyle', modifier);
sendBotMessage("You changed your font style to: " + modifier);
return;
}
if(type[0] === "type") {
if(modifier === undefined || modifier === "") {
modifier = "";
fonttype = modifier;
sys.saveVal('fonttype', modifier);
sendBotMessage("You changed your font type to the default");
return;
}
fonttype = modifier;
sys.saveVal('fonttype', modifier);
sendBotMessage("You changed your font to: " + modifier);
return;
}
if(type[0] === "size") {
if(modifier === undefined || modifier === "" || isNaN(parseInt(modifier, 10))) {
modifier = 3;
fontsize = modifier;
sys.saveVal('fontsize', modifier);
sendBotMessage("You changed your font size to the default");
return;
}
fontsize = modifier;
sys.saveVal('fontsize', modifier);
sendBotMessage("You changed your font size to: " + modifier);
return;
}
}
if(command === "changename") {
sys.stopEvent();
var valid = nameCheck(commandData);
if(valid === "fixup") {
commandData = fixup(commandData);
valid = nameCheck(commandData);
}
if(valid === false) {
sendBotMessage("Invalid Name"); //TODO: Specify what's exactly wrong with the name
return;
}
try {
client.changeName(commandData);
sendBotMessage("You changed your name to " + commandData);
} catch(e) {
if(e === "TypeError: Result of expression 'client.changeName' [undefined] is not a function.") {
sendBotMessage("You need to update your client to Version 2.0.06 or above to use this command");
}
}
return;
}
if(command === "changelog") {
sys.stopEvent();
if(isSafeScripts()) {
return;
}
var changelog = sys.synchronousWebCall("https://raw.github.com/gist/3189629/ChangeLog.json");
if(changelog.length < 1) {
sendBotMessage("Error retrieving file");
return;
}
changelog = JSON.parse(changelog);
if(changelog.versions[commandData] === undefined) {
sendBotMessage("Version does not exist! Use " + commandsymbol + "versions to check versions");
return;
}
var details = changelog.versions[commandData].split('\n');
sendBotMessage("Details for version: " + commandData);
for(var x in details) {
sendBotMessage(details[x]);
}
return;
}
if(command === "versions") {
sys.stopEvent();