View difference between Paste ID: M1ykymgr and BxfnR0rN
SHOW: | | - or go back to the newest paste.
1
/*
2
 Client Scripts
3
 Make sure you check ~commandslist for a list of commands
4
 Safe Scripts are pretty much required to be off
5
 Currently needs PO Version 2.0.10 to run correctly
6
 Report bugs here: http://pokemon-online.eu/forums/showthread.php?15079 and read over the thread to check for anything
7
 */
8
//these things below shouldn't be touched unless you know what you're doing~
9
/*jshint "laxbreak":true,"shadow":true,"undef":true,"evil":true,"trailing":true,"proto":true,"withstmt":true*/
10
/*global sys,client */
11
12
	var keywords = new Array();
13
	var responses = new Array();
14
	var blacklist = new Array();
15
16
	var letOthersDefine = false;
17
	
18
	var loaded = false;
19
	
20
	function saveResponses(silent)
21
	{
22
		if (silent == undefined)
23
			silent = false;
24
			
25
		var write = "";
26
		
27
		for (var i = 0; i < keywords.length; i++)
28
		{
29
			write += keywords[i] + ";;" + responses[i] + "\r\n";
30
		}
31
		
32
		write = write.substr(0, write.length - 2);
33
			
34
		writeFile("responses.txt", write);
35
		
36
		if (blacklist.length > 0)
37
			writeFile("responsesBlacklist.txt", blacklist.join("\r\n"));
38
		else
39
			writeFile("responsesBlacklist.txt", "");
40
		
41
		if (!silent)
42
			printMessage("Saved!");
43
	}
44
	
45
	function sendPM(user, message)
46
	{
47
		client.network().sendPM(client.id(user), message);
48
	}
49
	
50
	function loadResponses(silent)
51
	{
52
		if (silent == undefined)
53
			silent = false;
54
			
55
		keywords = new Array();
56
		responses = new Array();
57
		
58
59-
		blacklist = readFile("responsesBlacklist.txt").split("\r\n");
59+
		blacklist = readFile("responsesBlacklist.txt");
60
		
61
		if (blacklist == "" || blacklist == undefined)
62
		{
63
			blacklist = ["Tohjo Falls", "Tournaments", "Hangman", "Mafia", "Trivia"];
64
			writeFile("responsesBlacklist.txt", blacklist.join("\r\n"));
65
		}
66
		else
67
		{
68
			blacklist = blacklist.split("\r\n");
69
		}
70
		
71
		var txt = readFile("responses.txt");
72
		
73
		if (txt == "" || txt == undefined)
74
		{
75
			writeFile("responses.txt", "");
76
		}
77
		
78
		
79
		if (txt != null && txt.length > 3)
80
		{
81
			var lines = txt.split("\r\n");
82
			
83
			for (var i = 0; i < lines.length; i++)
84
			{
85
				keywords.push(lines[i].split(";;")[0]);
86
				responses.push(lines[i].substr(lines[i].indexOf(";;") + 2));
87
			}
88
			
89
			if (!silent)
90
				printMessage("Loaded!");
91
		}
92
		else
93
		{
94
			//printMessage("An error occurred. (Maybe there's nothing to load?)");
95
		}
96
	}
97
	
98
	function getMessage(message)
99
	{
100
		return message.substr(message.indexOf(':') + 2).toLowerCase();
101
	}
102
103
	function getExactMessage(message)
104
	{
105
		return message.substr(message.indexOf(':') + 2);
106
	}
107
108
	function getUser(message)
109
	{
110
		return message.split(":")[0];
111
	}
112
		
113
	function compare(item1, item2)
114
	{
115
		return item1.toLowerCase() == item2.toLowerCase();
116
	}
117
118
	function startsWith(message, str)
119
	{
120
		return compare(message.substr(0, str.length), str);
121
	}
122
123
	function readFile(fileName)
124
	{
125
		return sys.getFileContent(fileName);
126
	}
127
128
	function writeFile(fileName, content)
129
	{
130
		sys.writeToFile(fileName, content);
131
	}
132
133
	function contains(message, str)
134
	{
135
		return message.indexOf(str) != -1;
136
	}
137
	
138
function esc(response, user)
139
{
140
	return response.replace(/\[user\]/g, user).replace(/\[me\]/g, client.ownName());
141
}
142
143
	function tryKeyword(message, channel, user)
144
	{
145
		if (!loaded)
146
		{
147
			loadResponses(true);
148
			loaded = true;
149
		}
150
		
151
		if (keywords.indexOf(message) >= 0)
152
		{
153
			var response = esc(responses[keywords.indexOf(message)], user);
154
			
155
			if (contains(response, ";;"))
156
			{
157
				response = response.split(";;")[sys.rand(0, response.split(";;").length)];
158
			}
159
			
160
			if (blacklist.indexOf(client.channelName(channel).toLowerCase()) == -1
161
				&& !compare(message, response))
162
			{
163
				say(response, channel);
164
			}
165
		}
166
	}
167
	
168
169
	function addResponse(keyword, response)
170
	{
171
		if (keywords.indexOf(keyword) >= 0)
172
		{
173
			responses[keywords.indexOf(keyword)] += ";;" + response;
174
		}
175
		else
176
		{
177
			keywords.push(keyword.toLowerCase());
178
			responses.push(response);
179
		}
180
		
181
		saveResponses(true);
182
	}
183
184
	function removeResponse(keyword, response)
185
	{
186
		if (keywords.indexOf(keyword) >= 0)
187
		{
188
			var _response = responses[keywords.indexOf(keyword)];
189
			
190
			if (contains(_response, ";;"))
191
			{
192
				var lines = _response.split(";;");
193
				
194
				if (lines.indexOf(response) == -1)
195
					return false;
196
				
197
				var ret = "";
198
				
199
				for (var i = 0; i < lines.length; i++)
200
				{
201
					if (!compare(response, lines[i]))
202
					{
203
						ret += lines[i] + ";;";
204
					}
205
				}
206
				
207
				ret = ret.substr(0, ret.length - 2);
208
				responses[keywords.indexOf(keyword)] = ret;
209
			}
210
			else
211
			{
212
				var w = keywords.indexOf(keyword);
213
				keywords.splice(w, 1);
214
				responses.splice(w, 1);
215
			}
216
			
217
			saveResponses(true);
218
			return true;
219
		}
220
		else
221
		{
222
			return false;
223
		}
224
	}
225
226
var script_url = "https://raw.github.com/CrystalMoogle/PO-User-Scripts/master/"; //where the script is stored
227
var scriptsFolder = "ClientScripts"; //replace with undefined if you don't want a folder
228
var global = this;
229
var poScript, Script_Version, initCheck, repoFolder, 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, src, Utilities, Commands, autoidle, nochallenge, Plugins, userplugins, weightData, playerswarn, youtube;
230
var pluginFiles = [];
231
String.prototype.format = function () {
232
	var formatted = this;
233
	for (var i = 0; i < arguments.length; i++) {
234
		var regexp = new RegExp('\\{' + i + '\\}', 'gi');
235
		formatted = formatted.replace(regexp, arguments[i]);
236
	}
237
	return formatted;
238
};
239
Utilities = ({
240
	loadSettings: function loadSettings(json, defaultUsed, silent) {
241
		cleanFile('memory.json');
242
		try {
243
			var settings;
244
			if (json === undefined) {
245
				if (sys.getFileContent('memory.json') === "") {
246
					sendBotMessage('File not found, loaded from old settings');
247
					this.loadFromRegistry();
248
				}
249
				settings = JSON.parse(sys.getFileContent('memory.json'));
250
			}
251
			else {
252
				settings = JSON.parse(json);
253
			}
254
			etext = settings.etext;
255
			nochallenge = settings.nochallenge;
256
			autoidle = settings.autoidle;
257
			tgreentext = settings.tgreentext;
258
			flash = settings.flash;
259
			youtube = settings.youtube;
260
			autoresponse = settings.autoresponse;
261
			friendsflash = settings.friendsflash;
262
			checkversion = settings.checkversion;
263
			clientbotname = settings.clientbotname;
264
			clientbotcolour = settings.clientbotcolour;
265
			clientbotstyle = settings.clientbotstyle;
266
			greentext = settings.greentext;
267
			fontcolour = settings.fontcolour;
268
			fonttype = settings.fonttype;
269
			fontsize = settings.fontsize;
270
			fontstyle = settings.fontstyle;
271
			commandsymbol = settings.commandsymbol;
272
			hilight = settings.hilight;
273
			armessage = settings.armessage;
274
			arstart = settings.arstart;
275
			arend = settings.arend;
276
			artype = settings.artype;
277
			userplugins = settings.userplugins;
278
			stalkwords = settings.stalkwords;
279
			friends = settings.friends;
280
			ignore = settings.ignore;
281
			logchannel = settings.logchannel;
282
			fchannel = settings.fchannel;
283
			auth_symbol = settings.auth_symbol;
284
			auth_style = settings.auth_style;
285
			if (silent === false) {
286
				sendBotMessage("Settings loaded");
287
			}
288
		}
289
		catch (e) {
290
			sendBotMessage("Error with your settings: " + e);
291
			if (defaultUsed !== true) {
292
				sendBotMessage("Loading default settings");
293
				this.loadDefaultSettings();
294
			}
295
		}
296
	},
297
298
	loadDefaultSettings: function loadDefaultSettings() {
299
		var json = {
300
			"etext": false,
301
			"autoidle": false,
302
			"nochallenge": false,
303
			"tgreentext": false,
304
			"flash": true,
305
			"autoresponse": false,
306
			"friendsflash": false,
307
			"checkversion": false,
308
			"youtube": false,
309
			"clientbotname": "+ClientBot",
310
			"clientbotcolour": "#3DAA68",
311
			"clientbotstyle": "<b>",
312
			"greentext": "#789922",
313
			"fontcolour": "#000000",
314
			"fonttype": "",
315
			"fontsize": 3,
316
			"fontstyle": "",
317
			"commandsymbol": "~",
318
			"hilight": "BACKGROUND-COLOR: #ffcc00",
319
			"armessage": "I am currently unavailable!",
320
			"arstart": "",
321
			"arend": "",
322
			"artype": "command",
323
			"userplugins": [],
324
			"stalkwords": [],
325
			"friends": [],
326
			"ignore": [],
327
			"logchannel": [],
328
			"fchannel": [],
329
			"auth_symbol": {
330
				"0": "",
331
				"1": "+",
332
				"2": "+",
333
				"3": "+",
334
				"4": ""
335
			},
336
			"auth_style": {
337
				"0": "<b>",
338
				"1": "<b><i>",
339
				"2": "<b><i>",
340
				"3": "<b><i>",
341
				"4": "<b>"
342
			}
343
		};
344
		this.loadSettings(JSON.stringify(json), true);
345
	},
346
347
	loadFromRegistry: function loadFromRegistry() { //kinda needed because compatability sucks
348
		etext = Boolean(sys.getVal('etext'));
349
		autoidle = Boolean(sys.getVal('idle'));
350
		nochallenge = false;
351
		youtube = false;
352
		tgreentext = Boolean(sys.getVal('tgreentext'));
353
		autoresponse = Boolean(sys.getVal('autoresponse'));
354
		friendsflash = Boolean(sys.getVal('friendsflash'));
355
		checkversion = Boolean(sys.getVal('checkversion'));
356
		clientbotname = "+ClientBot";
357
		if (sys.getVal('flash') === "false") { //making sure flash is on always unless specified to not be
358
			flash = false;
359
		}
360
		else {
361
			flash = true;
362
		}
363
		if (sys.getVal('clientbotname')
364
			.length > 0) {
365
			clientbotname = sys.getVal('clientbotname');
366
		}
367
		clientbotcolour = "#3DAA68";
368
		if (sys.getVal('clientbotcolour')
369
			.length > 0) {
370
			clientbotcolour = sys.getVal('clientbotcolour');
371
		}
372
		clientbotstyle = "<b>";
373
		if (sys.getVal('clientbotstyle')
374
			.length > 0) {
375
			clientbotstyle = sys.getVal('clientbotstyle');
376
		}
377
		greentext = '#789922';
378
		if (sys.getVal('greentext')
379
			.length > 0) {
380
			greentext = sys.getVal('greentext');
381
		}
382
		fontcolour = "#000000";
383
		if (sys.getVal('fontcolour')
384
			.length > 0) {
385
			fontcolour = sys.getVal('fontcolour');
386
		}
387
		fonttype = "";
388
		if (sys.getVal('fonttype')
389
			.length > 0) {
390
			fonttype = sys.getVal('fonttype');
391
		}
392
		fontsize = 3;
393
		if (sys.getVal('fontsize')
394
			.length > 0) {
395
			fontsize = sys.getVal('fontsize');
396
		}
397
		fontstyle = "";
398
		if (sys.getVal('fontstyle')
399
			.length > 0) {
400
			fontstyle = sys.getVal('fontstyle');
401
		}
402
		commandsymbol = "~";
403
		if (sys.getVal('commandsymbol')
404
			.length > 0) {
405
			commandsymbol = sys.getVal('commandsymbol');
406
		}
407
		hilight = "BACKGROUND-COLOR: #ffcc00";
408
		if (sys.getVal('hilight')
409
			.length > 0) {
410
			hilight = sys.getVal('hilight');
411
		}
412
		armessage = sys.getVal('armessage');
413
		arstart = sys.getVal('arstart');
414
		arend = sys.getVal('arend');
415
		artype = sys.getVal('artype');
416
		userplugins = [];
417
		stalkwords = [];
418
		friends = [];
419
		ignore = [];
420
		logchannel = [];
421
		fchannel = [];
422
		if (sys.getVal('stalkwords') !== "") {
423
			var nstalkwords = sys.getVal('stalkwords')
424
				.split(",");
425
			stalkwords = nstalkwords.concat(stalkwords);
426
			stalkwords = this.eliminateDuplicates(stalkwords);
427
		}
428
		if (sys.getVal('friends') !== "") {
429
			var nfriends = sys.getVal('friends')
430
				.split(",");
431
			friends = nfriends.concat(friends);
432
			friends = this.eliminateDuplicates(friends);
433
		}
434
		if (sys.getVal('ignore') !== "") {
435
			var nignore = sys.getVal('ignore')
436
				.split(",");
437
			ignore = nignore.concat(ignore);
438
			ignore = this.eliminateDuplicates(ignore);
439
		}
440
		if (sys.getVal('logchannel') !== "") {
441
			var nlogchannel = sys.getVal('logchannel')
442
				.split(",");
443
			logchannel = nlogchannel.concat(logchannel);
444
			logchannel = this.eliminateDuplicates(logchannel);
445
		}
446
		if (sys.getVal('fchannel') !== "") {
447
			var nfchannel = sys.getVal('fchannel')
448
				.split(",");
449
			fchannel = nfchannel.concat(fchannel);
450
			fchannel = this.eliminateDuplicates(fchannel);
451
		}
452
		auth_symbol = [];
453
		for (var x = 0; x < 5; x++) {
454
			if (sys.getVal('auth: ' + x)
455
				.length > 0) {
456
				auth_symbol[x] = sys.getVal('auth: ' + x);
457
				continue;
458
			}
459
			if (x === 0 || x === 4) {
460
				auth_symbol[x] = "";
461
				continue;
462
			}
463
			auth_symbol[x] = "+";
464
		}
465
		auth_style = [];
466
		for (var x = 0; x < 5; x++) {
467
			if (sys.getVal('auths: ' + x)
468
				.length > 0) {
469
				auth_style[x] = sys.getVal('auths: ' + x);
470
				continue;
471
			}
472
			if (x === 0 || x === 4) {
473
				auth_style[x] = "<b>";
474
				continue;
475
			}
476
			auth_style[x] = "<i><b>";
477
		}
478
		this.saveSettings();
479
	},
480
481
	saveSettings: function saveSettings() {
482
		var settings = {};
483
		settings.etext = etext;
484
		settings.autoidle = autoidle;
485
		settings.nochallenge = nochallenge;
486
		settings.tgreentext = tgreentext;
487
		settings.flash = flash;
488
		settings.youtube = youtube;
489
		settings.autoresponse = autoresponse;
490
		settings.friendsflash = friendsflash;
491
		settings.checkversion = checkversion;
492
		settings.clientbotname = clientbotname;
493
		settings.clientbotcolour = clientbotcolour;
494
		settings.clientbotstyle = clientbotstyle;
495
		settings.greentext = greentext;
496
		settings.fontcolour = fontcolour;
497
		settings.fonttype = fonttype;
498
		settings.fontsize = fontsize;
499
		settings.fontstyle = fontstyle;
500
		settings.commandsymbol = commandsymbol;
501
		settings.hilight = hilight;
502
		settings.armessage = armessage;
503
		settings.arstart = arstart;
504
		settings.arend = arend;
505
		settings.artype = artype;
506
		settings.userplugins = userplugins;
507
		settings.stalkwords = stalkwords;
508
		settings.friends = friends;
509
		settings.ignore = ignore;
510
		settings.logchannel = logchannel;
511
		settings.fchannel = fchannel;
512
		settings.auth_symbol = auth_symbol;
513
		settings.auth_style = auth_style;
514
		if(!sys.isSafeScripts()) {
515
			sys.writeToFile('memory.json', JSON.stringify(settings));
516
		}
517
	},
518
519
	eliminateDuplicates: function eliminateDuplicates(arr) { //stolen from http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/ eliminates any duplicates that are in an array
520
		var len = arr.length;
521
		var out = [];
522
		var obj = {};
523
		for (var i = 0; i < len; i++) {
524
			obj[arr[i]] = 0;
525
		}
526
		for (var i in obj) {
527
			if (obj.hasOwnProperty(i)) {
528
				out.push(i);
529
			}
530
		}
531
		return out;
532
	},
533
534
	isPunct: function isPunct(i) {
535
		return (this.isGraph(i) && !(this.isAlnum(i)));
536
	},
537
538
	isGraph: function isGraph(i) {
539
		var myCharCode = i.charCodeAt(0);
540
		return (myCharCode > 32) && (myCharCode < 127);
541
	},
542
543
	isAlnum: function isAlnum(i) {
544
		return (this.isDigit(i) || this.isAlpha(i));
545
	},
546
547
	isDigit: function isDigit(i) {
548
		var myCharCode = i.charCodeAt(0);
549
		return (myCharCode > 47) && (myCharCode < 58);
550
	},
551
552
	isAlpha: function isAlpha(i) {
553
		var myCharCode = i.charCodeAt(0);
554
		return ((myCharCode > 64) && (myCharCode < 91)) || ((myCharCode > 96) && (myCharCode < 123));
555
	},
556
557
	stripHTML: function stripHTML(string) {
558
		var regex = /(<([^>]+)>)/ig;
559
		string = string.replace(regex, "");
560
		return string;
561
	},
562
563
	html_escape: function html_escape(text) { //escapes any characters that won't appear correctly in HTMLmessages
564
		var m = String(text);
565
		if (m.length > 0) {
566
			var amp = "&am" + "p;";
567
			var lt = "&l" + "t;";
568
			var gt = "&g" + "t;";
569
			return m.replace(/&/g, amp)
570
				.replace(/</g, lt)
571
				.replace(/>/g, gt);
572
		}
573
		else {
574
			return "";
575
		}
576
	},
577
578
	tagend: function tagend(string) { //automatically creates an end tag from a html tagsent to it
579
		if (string === undefined) {
580
			return "";
581
		}
582
		return string.replace(/</g, "</");
583
	},
584
585
	checkVersion: function checkVersion(version) {
586
		var currentVersion = sys.version().replace(/\./g, "").length === 4 ? sys.version().replace(/\./g, "") : sys.version().replace(/\./g, "")*10;
587
		return currentVersion >= version;
588
	}
589
});
590
591
Commands = ({
592
	commandHandler: function commandHandler(command, commandData, channel) {
593
		if (command === "commandlist" || command === "commandslist") {
594
			sys.stopEvent();
595
			sendMessage("*** Client Commands ***");
596
			sendMessage(commandsymbol + "commandsymbol symbol: Allows you to change the command symbol");
597
			sendMessage(commandsymbol + "idle on/off: Allows you to turn auto-idle on/off");
598
			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");
599
			sendMessage(commandsymbol + "ignorechallenges on/off: Allows you to ignore all challenges without idling");
600
			sendMessage(commandsymbol + "ytlinks on/off: Converts Youtube links into their titles (Warning: May cause lag)");
601
			sendMessage(commandsymbol + "goto channel: Allows you to switch to that channel (joins if you're not in that channel)");
602
			sendMessage(commandsymbol + "reconnect: Allows you to reconnect to the server");
603
			sendMessage(commandsymbol + "pm name: Allows you to start a PM with a user");
604
			sendMessage(commandsymbol + "changename: Allows you to change your name");
605
			sendMessage(commandsymbol + "stalkwords: Allows you to view your current stalkwords");
606
			sendMessage(commandsymbol + "[add/remove]stalkword word: Allows you to add/remove stalkwords");
607
			sendMessage(commandsymbol + "logchannels: Allows you to view your log channels");
608
			sendMessage(commandsymbol + "[add/remove]logchannel channel: Allows you to add/remove channels from the channels you log");
609
			sendMessage(commandsymbol + "pokedex pokemon:level:gen: Shows you details about a pokemon. Gen/level are optional parameters to view the pokemon in different gens/at different levels");
610
			sendMessage(commandsymbol + "formatcommands: Shows the formatting comands (e.g. enriched text, auth symbols)");
611
			sendMessage(commandsymbol + "scriptcommands: Shows commands related to the scripts (e.g. versions, updatescripts)");
612
			sendMessage(commandsymbol + "socialcommands: Shows commands related to social aspects (e.g. friendslist, ignorelist)");
613
			sendMessage(commandsymbol + "fontcommands: Shows you the font command details");
614
			var pluginhelps = getPlugins("help-string");
615
			for (var module in pluginhelps) {
616
				if (pluginhelps.hasOwnProperty(module)) {
617
					var help = typeof pluginhelps[module] === "string" ? [pluginhelps[module]] : pluginhelps[module];
618
					for (var i = 0; i < help.length; ++i) {
619
						sendMessage(commandsymbol + help[i]);
620
					}
621
				}
622
			}
623
			sendMessage(commandsymbol + "damagecalc [s]atk:move power:modifier:[s]def:HP: Basic damage calculator");
624
			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)");
625
			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");
626
			sendMessage("");
627
			sendBotMessage('If you ever forget your command symbol, type "reset symbol" (no quotes) to revert it back to "~"');
628
			return;
629
		}
630
		if (command === "formatcommands") {
631
			sys.stopEvent();
632
			sendMessage("*** Formatting Commands ***");
633
			sendMessage(commandsymbol + "etext on/off: Allows you to turn Enriched text on/off");
634
			sendMessage(commandsymbol + "greentext on/off: Allows you to turn greentext on/off");
635
			sendMessage(commandsymbol + "greentextcolo(u)r colour: Allows you to change your greentext colour");
636
			sendMessage(commandsymbol + "highlight colour: Allows you to change the colour of the highlight when flashed");
637
			sendMessage(commandsymbol + "changebotcolo(u)r colour: Allows you to change the bot's (client and server) colour");
638
			sendMessage(commandsymbol + "changebotname name: Allows you to change clientbot's name");
639
			sendMessage(commandsymbol + "changebotstyle htmltag: Allows you to change the style of the client bot (start tags only)");
640
			sendMessage(commandsymbol + "resetbot: Allows you to reset the bot to its default values");
641
			sendMessage(commandsymbol + "authsymbols auth:symbol: Allows you to change authsymbols. If symbol is left blank, then it removes the current auth symbol");
642
			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");
643
			return;
644
		}
645
		if (command === "scriptcommands") {
646
			sys.stopEvent();
647
			sendMessage("*** Script Commands ***");
648
			sendMessage(commandsymbol + "updatescripts: Allows you to updatescripts");
649
			//sendMessage(commandsymbol + "updatetierinfo: Allows you to update the tier info used in pokedex. Use this after tier changes on the main server");
650
			sendMessage(commandsymbol + "versions: Allows you to view the current versions");
651
			sendMessage(commandsymbol + "changelog version: Allows you to view the changelog");
652
			sendMessage(commandsymbol + "checkversion: Allows you to check for updates");
653
			sendMessage(commandsymbol + "updatealert on/off: Allows you to get automatically alerted about new versions");
654
			return;
655
		}
656
		if (command === "socialcommands") {
657
			sys.stopEvent();
658
			sendMessage("*** Social Commands ***");
659
			sendMessage(commandsymbol + "friends: Allows you to view your current friends and their online status");
660
			sendMessage(commandsymbol + "[add/remove]friend friend: Allows you to add/remove friends");
661
			sendMessage(commandsymbol + "friendflash on/off: Allows you turn friend flashes on/off");
662
			sendMessage(commandsymbol + "ignorelist: Allows you to view your autoignore list");
663
			sendMessage(commandsymbol + "[add/remove]ignore user: Allows you to add/remove people from your ignore list");
664
			sendMessage(commandsymbol + "armessage: Sets your autoresponse message");
665
			sendMessage(commandsymbol + "artype [command/time]: Sets how to activate your autoresponse, time does it between certain hours, command activates it by command");
666
			sendMessage(commandsymbol + "ar[on/off]: Turns your autoresponse on/off if type if command");
667
			sendMessage(commandsymbol + "artime hour1:hour2: Sets your autoresponse to activate between hour1 and hour2");
668
			return;
669
		}
670
		if (command === "fontcommands") {
671
			sys.stopEvent();
672
			sendMessage("*** Font Command Details ***");
673
			sendMessage("Command: " + commandsymbol + "font type:modifier");
674
			sendMessage("Type: Types are 'colo(u)r', 'style', 'type', 'size'");
675
			sendMessage("Colour: Defines the colour of the font");
676
			sendMessage("Style: Defines the style of the font (bold/italics/underline)");
677
			sendMessage("Type: Defines the font face");
678
			sendMessage("Size: Defines the font size");
679
			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");
680
			sendMessage("Example: " + commandsymbol + "font color:red, will make all text red");
681
			return;
682
		}
683
		if (command === "etext") {
684
			sys.stopEvent();
685
			if (commandData === "on") {
686
				etext = true;
687
				Utilities.saveSettings();
688
				sendBotMessage("You turned Enriched text on!");
689
				return;
690
			}
691
			if (commandData === "off") {
692
				etext = false;
693
				Utilities.saveSettings();
694
				sendBotMessage("You turned Enriched text off!");
695
				return;
696
			}
697
			sendBotMessage("Please use on/off");
698
		}
699
		if (command === "greentext") {
700
			sys.stopEvent();
701
			if (commandData === "on") {
702
				tgreentext = true;
703
				Utilities.saveSettings();
704
				sendBotMessage("You turned greentext on!");
705
				return;
706
			}
707
			if (commandData === "off") {
708
				tgreentext = false;
709
				Utilities.saveSettings();
710
				sendBotMessage("You turned greentext off!");
711
				return;
712
			}
713
			sendBotMessage("Please use on/off");
714
		}
715
		if (command === "idle") {
716
			sys.stopEvent();
717
			if (commandData === "on") {
718
				client.goAway(true);
719
				autoidle = true;
720
				Utilities.saveSettings();
721
				sendBotMessage("You turned auto-idling on!");
722
				return;
723
			}
724
			if (commandData === "off") {
725
				client.goAway(false);
726
				autoidle = false;
727
				Utilities.saveSettings();
728
				sendBotMessage("You turned auto-idling off!");
729
				return;
730
			}
731
			sendBotMessage("Please use on/off");
732
		}
733
		if (command === "ignorechallenges") {
734
			sys.stopEvent();
735
			if (commandData === "on") {
736
				nochallenge = true;
737
				Utilities.saveSettings();
738
				sendBotMessage("You are ignoring all challenges");
739
				return;
740
			}
741
			if (commandData === "off") {
742
				nochallenge = false;
743
				Utilities.saveSettings();
744
				sendBotMessage("You are no longer ignoring challenges");
745
				return;
746
			}
747
			sendBotMessage("Please use on/off");
748
		}
749
		if (command  === "ytlinks") {
750
			sys.stopEvent();
751
			if (commandData === "on") {
752
				youtube = true;
753
				Utilities.saveSettings();
754
				sendBotMessage("Youtube links will automatically convert to titles");
755
				return;
756
			}
757
			if (commandData === "off") {
758
				youtube = false;
759
				Utilities.saveSettings();
760
				sendBotMessage("Youtube links will display as links instead of titles");
761
				return;
762
			}
763
			sendBotMessage("Please use on/off");
764
		}
765
		if (command === "checkversion") {
766
			sys.stopEvent();
767
			if (isSafeScripts()) {
768
				return;
769
			}
770
			sendBotMessage("Checking script version please wait. (Current Version: " + Script_Version + ")");
771
			checkScriptVersion(true);
772
			return;
773
		}
774
		if (command === "updatealert") {
775
			sys.stopEvent();
776
			if (isSafeScripts()) {
777
				return;
778
			}
779
			if (commandData === "on") {
780
				checkversion = true;
781
				Utilities.saveSettings();
782
				sendBotMessage("You now get alerted about new versions");
783
				checkScriptVersion();
784
				return;
785
			}
786
			if (commandData === "off") {
787
				checkversion = false;
788
				Utilities.saveSettings();
789
				sendBotMessage("You no longer get alerted about new versions");
790
				return;
791
			}
792
			sendBotMessage("Please use on/off");
793
		}
794
		if (command === "goto") {
795
			sys.stopEvent();
796
			var channela = commandData.toLowerCase();
797
			var channels = client.channelNames();
798
			for (var x in channels) {
799
				if (channels.hasOwnProperty(x)) {
800
					if (channela === channels[x].toLowerCase()) {
801
						channela = channels[x];
802
						if (!client.hasChannel(client.channelId(channela))) {
803
							client.join(channela);
804
							return;
805
						}
806
						client.activateChannel(channela);
807
						return;
808
					}
809
				}
810
			}
811
			sendBotMessage("That is not a channel!");
812
		}
813
		if (command === "reconnect") {
814
			sys.stopEvent();
815
			client.reconnect();
816
			return;
817
		}
818
		if (command === "pm") {
819
			sys.stopEvent();
820
			var id = client.id(commandData);
821
			if (id === client.ownId()) {
822
				return;
823
			}
824
			client.startPM(id);
825
			return;
826
		}
827
		if (command === "stalkwords") {
828
			sys.stopEvent();
829
			sendBotMessage("Your stalkwords are: " + stalkwords);
830
		}
831
		if (command === "addstalkword") {
832
			sys.stopEvent();
833
			var nstalkwords = commandData;
834
			if (nstalkwords.search(/, /g) !== -1 || nstalkwords.search(/ ,/g) !== -1) {
835
				nstalkwords = nstalkwords.replace(/, /g, ",")
836
					.replace(/ ,/g, ",");
837
			}
838
			nstalkwords = nstalkwords.split(",");
839
			stalkwords = Utilities.eliminateDuplicates(nstalkwords.concat(stalkwords));
840
			Utilities.saveSettings();
841
			sendBotMessage("You added " + commandData + " to your stalkwords!");
842
		}
843
		if (command === "removestalkword") {
844
			sys.stopEvent();
845
			commandData = commandData.toLowerCase();
846
			for (var x = 0; x < stalkwords.length; x++) {
847
				if (stalkwords[x].toLowerCase() === commandData) {
848
					stalkwords.splice(x, 1);
849
					Utilities.saveSettings();
850
					sendBotMessage("You removed " + commandData + " from your stalkwords!");
851
					return;
852
				}
853
			}
854
			sendBotMessage("" + commandData + " is not a stalkword!");
855
		}
856
		if (command === "flash" || command === "flashes") {
857
			sys.stopEvent();
858
			commandData = commandData.split(':');
859
			if (commandData.length < 2 || commandData[1] === "") {
860
				if (commandData[0] === "on") {
861
					flash = true;
862
					Utilities.saveSettings();
863
					sendBotMessage("You turned flashes on!");
864
					return;
865
				}
866
				else {
867
					flash = false;
868
					Utilities.saveSettings();
869
					sendBotMessage("You turned flashes off!");
870
					return;
871
				}
872
			}
873
			var nfchannel = commandData[1];
874
			if (commandData[0] === "off") {
875
				if (nfchannel.search(/, /g) !== -1 || nfchannel.search(/ ,/g) !== -1) {
876
					nfchannel = nfchannel.replace(/, /g, ",")
877
						.replace(/ ,/g, ",");
878
				}
879
				nfchannel = nfchannel.split(",");
880
				fchannel = Utilities.eliminateDuplicates(nfchannel.concat(fchannel));
881
				Utilities.saveSettings();
882
				sendBotMessage("You won't be flashed in " + commandData[1]);
883
			}
884
			else {
885
				commandData[1] = commandData[1].toLowerCase();
886
				for (var x = 0; x < fchannel.length; x++) {
887
					if (fchannel[x].toLowerCase() === commandData[1]) {
888
						fchannel.splice(x, 1);
889
						Utilities.saveSettings();
890
						sendBotMessage("You will be flashed in " + commandData[1]);
891
						return;
892
					}
893
				}
894
			}
895
		}
896
		if (command === "friends") {
897
			sys.stopEvent();
898
			var check = [];
899
			for (var x = 0; x < friends.length; x++) {
900
				if (client.id(friends[x]) !== -1) {
901
					check.push("<a href='po:pm/" + client.id(friends[x]) + "'>" + friends[x] + "</a> <font color='green'>(online)</font>");
902
					continue;
903
				}
904
				check.push(friends[x] + " <font color='red'>(offline)</font>");
905
			}
906
			sendHtmlMessage("<font color = '" + Utilities.html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + Utilities.html_escape(clientbotname) + ":" + Utilities.tagend(clientbotstyle) + "</font> Your friends are: " + check);
907
			return;
908
		}
909
		if (command === "addfriend") {
910
			sys.stopEvent();
911
			var nfriends = commandData;
912
			if (nfriends.search(/, /g) !== -1 || nfriends.search(/ ,/g) !== -1) {
913
				nfriends = nfriends.replace(/, /g, ",")
914
					.replace(/ ,/g, ",");
915
			}
916
			nfriends = nfriends.split(",");
917
			friends = Utilities.eliminateDuplicates(nfriends.concat(friends));
918
			Utilities.saveSettings();
919
			sendBotMessage("You added " + commandData + " to your friends!");
920
		}
921
		if (command === "removefriend") {
922
			sys.stopEvent();
923
			commandData = commandData.toLowerCase();
924
			for (var x = 0; x < friends.length; x++) {
925
				if (friends[x].toLowerCase() === commandData) {
926
					friends.splice(x, 1);
927
					Utilities.saveSettings();
928
					sendBotMessage("You removed " + commandData + " from your friends!");
929
					return;
930
				}
931
			}
932
			sendBotMessage(commandData + " is not a friend!");
933
		}
934
		if (command === "friendflash" || command === "friendsflash") {
935
			sys.stopEvent();
936
			if (commandData === "on") {
937
				friendsflash = true;
938
				Utilities.saveSettings();
939
				sendBotMessage("You turned friend flashes on!");
940
				return;
941
			}
942
			else {
943
				friendsflash = false;
944
				Utilities.saveSettings();
945
				sendBotMessage("You turned friend flashes off!");
946
			}
947
			return;
948
		}
949
		if (command === "ignorelist") {
950
			sys.stopEvent();
951
			sendBotMessage("Your ignorelist is: " + ignore);
952
		}
953
		if (command === "addignore") {
954
			sys.stopEvent();
955
			if (commandData === client.ownName()) {
956
				return;
957
			}
958
			var nignore = commandData;
959
			if (nignore.search(/, /g) !== -1 || nignore.search(/ ,/g) !== -1) {
960
				nignore = nignore.replace(/, /g, ",")
961
					.replace(/ ,/g, ",");
962
			}
963
			nignore = nignore.split(",");
964
			ignore = Utilities.eliminateDuplicates(nignore.concat(ignore));
965
			Utilities.saveSettings();
966
			if (client.id(commandData) !== -1) {
967
				client.ignore(client.id(commandData), true);
968
			}
969
			sendBotMessage("You added " + commandData + " to your ignorelist!");
970
		}
971
		if (command === "removeignore") {
972
			sys.stopEvent();
973
			commandData = commandData.toLowerCase();
974
			for (var x = 0; x < ignore.length; x++) {
975
				if (ignore[x].toLowerCase() === commandData) {
976
					ignore.splice(x, 1);
977
					Utilities.saveSettings();
978
					if (client.id(commandData) !== -1) {
979
						client.ignore(client.id(commandData), false);
980
					}
981
					sendBotMessage("You removed " + commandData + " from your ignorelist!");
982
					return;
983
				}
984
			}
985
			sendBotMessage(commandData + " is not on the ignorelist!");
986
		}
987
		if (command === "changebotname") {
988
			sys.stopEvent();
989
			if (commandData === undefined) {
990
				return;
991
			}
992
			clientbotname = commandData;
993
			sendBotMessage(clientbotname + " is now your clientbot's name!");
994
			Utilities.saveSettings();
995
			return;
996
		}
997
		if (command === "changebotstyle") {
998
			sys.stopEvent();
999
			if (commandData === undefined) {
1000
				clientbotstyle = "";
1001
				sendBotMessage("You removed your client bot style!");
1002
				Utilities.saveSettings();
1003
				return;
1004
			}
1005
			clientbotstyle = commandData;
1006
			sendBotMessage(clientbotstyle + " is now your clientbot's style!");
1007
			Utilities.saveSettings();
1008
			return;
1009
		}
1010
		if (command === "changebotcolour" || command === "changebotcolor") {
1011
			sys.stopEvent();
1012
			if (commandData === undefined) {
1013
				return;
1014
			}
1015
			clientbotcolour = commandData;
1016
			sendBotMessage(clientbotcolour + " is now your clientbot's colour!");
1017
			Utilities.saveSettings();
1018
			return;
1019
		}
1020
		if (command === "greentextcolor" || command === "greentextcolour") {
1021
			sys.stopEvent();
1022
			if (commandData === undefined || commandData === "") {
1023
				greentext = '#789922';
1024
				sendBotMessage(greentext + " is now your greentext colour!");
1025
				Utilities.saveSettings();
1026
				return;
1027
			}
1028
			greentext = commandData;
1029
			sendBotMessage(greentext + " is now your greentext colour!");
1030
			Utilities.saveSettings();
1031
			return;
1032
		}
1033
		if (command === "resetbot") {
1034
			sys.stopEvent();
1035
			clientbotcolour = "#3DAA68";
1036
			clientbotname = "+ClientBot";
1037
			clientbotstyle = "<b>";
1038
			Utilities.saveSettings();
1039
			sendBotMessage("You reset your bot to default values");
1040
			return;
1041
		}
1042
		if (command === "font") {
1043
			sys.stopEvent();
1044
			if (commandData === undefined) {
1045
				return;
1046
			}
1047
			var type = commandData.split(":");
1048
			if (type.length < 1) {
1049
				sendBotMessage('Usage is ' + commandsymbol + 'font type:modifier');
1050
				return;
1051
			}
1052
			var modifier = type[1];
1053
			var types = ["colour", "color", "style", "type", "size"];
1054
			if (types.indexOf(type[0]) === -1) {
1055
				sendBotMessage('Invalid type, valid types are: colo(u)r, style, type, size');
1056
				return;
1057
			}
1058
			if (type[0] === "colour" || type[0] === "color") {
1059
				if (modifier === undefined || modifier === "") {
1060
					modifier = "#000000";
1061
					fontcolour = modifier;
1062
					Utilities.saveSettings();
1063
					sendBotMessage("You changed your font colour to the default");
1064
					return;
1065
				}
1066
				fontcolour = modifier;
1067
				Utilities.saveSettings();
1068
				sendBotMessage("You changed your font colour to: " + modifier);
1069
				return;
1070
			}
1071
			if (type[0] === "style") {
1072
				if (modifier === undefined || modifier === "") {
1073
					modifier = "";
1074
					fontstyle = modifier;
1075
					Utilities.saveSettings();
1076
					sendBotMessage("You changed your font style to the default");
1077
					return;
1078
				}
1079
				if (modifier.indexOf('</') !== -1) {
1080
					sendBotMessage("End tags are not needed, please only use start ones");
1081
					return;
1082
				}
1083
				fontstyle = modifier;
1084
				Utilities.saveSettings();
1085
				sendBotMessage("You changed your font style to: " + modifier);
1086
				return;
1087
			}
1088
			if (type[0] === "type") {
1089
				if (modifier === undefined || modifier === "") {
1090
					modifier = "";
1091
					fonttype = modifier;
1092
					Utilities.saveSettings();
1093
					sendBotMessage("You changed your font type to the default");
1094
					return;
1095
				}
1096
				fonttype = modifier;
1097
				Utilities.saveSettings();
1098
				sendBotMessage("You changed your font to: " + modifier);
1099
				return;
1100
			}
1101
			if (type[0] === "size") {
1102
				if (modifier === undefined || modifier === "" || isNaN(parseInt(modifier, 10))) {
1103
					modifier = 3;
1104
					fontsize = modifier;
1105
					Utilities.saveSettings();
1106
					sendBotMessage("You changed your font size to the default");
1107
					return;
1108
				}
1109
				fontsize = modifier;
1110
				Utilities.saveSettings();
1111
				sendBotMessage("You changed your font size to: " + modifier);
1112
				return;
1113
			}
1114
		}
1115
		if (command === "changename") {
1116
			sys.stopEvent();
1117
			try {
1118
				commandData = nameCheck(commandData);
1119
			}
1120
			catch (e) {
1121
				sendBotMessage("Invalid Name: " + e);
1122
				return;
1123
			}
1124
			try {
1125
				client.changeName(commandData);
1126
				sendBotMessage("You changed your name to " + commandData);
1127
			}
1128
			catch (e) {
1129
				if (e.toString() === "TypeError: Result of expression 'client.changeName' [undefined] is not a function.") {
1130
					sendBotMessage("You need to update your client to Version 2.0.06 or above to use this command");
1131
				}
1132
			}
1133
			return;
1134
		}
1135
		if (command === "changelog") {
1136
			sys.stopEvent();
1137
			if (isSafeScripts()) {
1138
				return;
1139
			}
1140
			var changelog = sys.synchronousWebCall(script_url + "changelog.json");
1141
			if (changelog.length < 1) {
1142
				sendBotMessage("Error retrieving file");
1143
				return;
1144
			}
1145
			changelog = JSON.parse(changelog);
1146
			if (changelog.versions[commandData] === undefined) {
1147
				sendBotMessage("Version does not exist! Use " + commandsymbol + "versions to check versions");
1148
				return;
1149
			}
1150
			var details = changelog.versions[commandData].split('\n');
1151
			sendBotMessage("Details for version: " + commandData);
1152
			for (var x = 0; x < details.length; x++) {
1153
				sendBotMessage(details[x]);
1154
			}
1155
			return;
1156
		}
1157
		if (command === "versions") {
1158
			sys.stopEvent();
1159
			var version = [];
1160
			if (isSafeScripts()) {
1161
				return;
1162
			}
1163
			var changelog = sys.synchronousWebCall(script_url + "changelog.json");
1164
			if (changelog.length < 1) {
1165
				sendBotMessage("Error retrieving file");
1166
				return;
1167
			}
1168
			changelog = JSON.parse(changelog);
1169
			for (var x in changelog.versions) {
1170
				if (changelog.versions.hasOwnProperty(x)) {
1171
					version.push(" " + x);
1172
				}
1173
			}
1174
			sendBotMessage('Versions of this script are: ' + version);
1175
			return;
1176
		}
1177
		if (command === "updatescripts") {
1178
			sys.stopEvent();
1179
			sendBotMessage("No.");
1180
			return;
1181
		}
1182
		/*if (command === "updatetierinfo") {
1183
			sys.stopEvent();
1184
			if (isSafeScripts()) {
1185
				return;
1186
			}
1187
			sendBotMessage("Fetching tier info...");
1188
			sys.webCall("https://gist.github.com/CrystalMoogle/76a72f564d7eb8c509dd/raw/tiers.json", function(resp) {sys.writeToFile('tiers.json', resp); sendBotMessage("Tier info was updated!");});
1189
		}*/
1190
		if (command === "updateplugin") {
1191
			sys.stopEvent();
1192
			if (pluginFiles.indexOf(commandData) !== -1) {
1193
				updateFile(commandData);
1194
				return;
1195
			}
1196
			sendBotMessage("This is not a valid script plugin");
1197
			return;
1198
		}
1199
		if (command === "addplugin") {
1200
			sys.stopEvent();
1201
			if (pluginFiles.indexOf(commandData.split(/\//).pop()) !== -1) {
1202
				updateFile(commandData);
1203
				return;
1204
			}
1205
			pluginFiles = pluginFiles.concat(commandData.split(/\//).pop());
1206
			addPlugin(commandData);
1207
			return;
1208
		}
1209
		if (command === "loadsettings") { //TODO Allow user defined files to be loaded in the future from web or file system
1210
			sys.stopEvent();
1211
			Utilities.loadSettings(undefined, undefined, false);
1212
			return;
1213
		}
1214
		if (command === "authsymbol" || command === "authsymbols") {
1215
			sys.stopEvent();
1216
			var symbols = commandData.split(":");
1217
			var auth = symbols[0];
1218
			var symbol = symbols[1];
1219
			if (symbols.length > 2 || symbols.length < 1) {
1220
				sendBotMessage("Command usage is: \"" + commandsymbol + "changesymbols number:symbol\"");
1221
				return;
1222
			}
1223
			if (isNaN(parseInt(auth, 10))) {
1224
				sendBotMessage("The first parameter must be a number!");
1225
				return;
1226
			}
1227
			if (auth < 0 || auth > 4) {
1228
				sendBotMessage("Auth must be between 0 and 4");
1229
				return;
1230
			}
1231
			if (symbol === undefined) {
1232
				symbol = "";
1233
			}
1234
			auth_symbol[auth] = symbol;
1235
			Utilities.saveSettings();
1236
			if (symbol === "") {
1237
				sendBotMessage("Auth " + auth + " now has no symbol");
1238
				return;
1239
			}
1240
			sendBotMessage("Auth symbol for auth " + auth + " is " + symbol);
1241
			return;
1242
		}
1243
		if (command === "authstyle") {
1244
			sys.stopEvent();
1245
			var styles = commandData.split(":");
1246
			var auth = styles[0];
1247
			var style = styles[1];
1248
			if (styles.length > 2 || styles.length < 2) {
1249
				sendBotMessage("Command usage is: \"" + commandsymbol + "changestyles number:html\"");
1250
				return;
1251
			}
1252
			if (isNaN(parseInt(auth, 10))) {
1253
				sendBotMessage("The first parameter must be a number!");
1254
				return;
1255
			}
1256
			if (auth < 0 || auth > 4) {
1257
				sendBotMessage("Auth must be between 0 and 4");
1258
				return;
1259
			}
1260
			if (style.indexOf('</') !== -1) {
1261
				sendBotMessage("End tags are not needed, please only use start ones");
1262
				return;
1263
			}
1264
			if (style === undefined) {
1265
				style = "";
1266
			}
1267
			auth_style[auth] = style;
1268
			Utilities.saveSettings();
1269
			if (style === "") {
1270
				sendBotMessage("Auth " + auth + " now has no style");
1271
				return;
1272
			}
1273
			sendBotMessage("Auth style for auth " + auth + " is " + style);
1274
			return;
1275
		}
1276
		if (command === "damagecalc") {
1277
			sys.stopEvent();
1278
			var paras = commandData.split(':');
1279
			if (paras.length !== 5) {
1280
				sendBotMessage("Format is [s]atk:movepower:boosts:[s]def:hp");
1281
				return;
1282
			}
1283
			for (var x = 0; x < paras.length; x++) {
1284
				paras[x] = parseFloat(paras[x]);
1285
				if (isNaN(paras[x])) {
1286
					sendBotMessage('Parameters must be all numbers!');
1287
					return;
1288
				}
1289
			}
1290
			if (paras[2] === 0) {
1291
				paras[2] = 1;
1292
			}
1293
			var calc = (84 * paras[0] * paras[1] * paras[2]) / (paras[3] * paras[4]);
1294
			sendBotMessage(paras[1] + "BP move coming from " + paras[0] + "[s]atk with a " + paras[2] + " modifier on " + paras[4] + "HP and " + paras[3] + "[s]def, does approxmiately " + calc + " damage");
1295
			return;
1296
		}
1297
		if (command === "pokedex") {
1298
			sys.stopEvent();
1299
			if (!Utilities.checkVersion(2008)) {
1300
				sendBotMessage("This command will only work on versions 2.0.08 and higher");
1301
				return;
1302
			}
1303
			if (commandData === undefined) {
1304
				sendBotMessage("Usage is " + commandsymbol + "pokedex pokemon:level:gen (gen/level are optional)");
1305
				return;
1306
			}
1307
			commandData = commandData.split(':');
1308
			if (commandData.length > 3) {
1309
				sendBotMessage("Usage is " + commandsymbol + "pokedex pokemon:level:gen (gen/level are optional)");
1310
				return;
1311
			}
1312
			var pokemon = sys.pokeNum(commandData[0]);
1313
			var gen = parseInt(commandData[2], 10);
1314
			var level = parseInt(commandData[1], 10);
1315
			if (isNaN(gen) || gen > 6 || gen < 1) {
1316
				gen = 6;
1317
			}
1318
			if (isNaN(level) || level > 100 || level < 1) {
1319
				level = 100;
1320
			}
1321
			pokeDex(pokemon, gen, level);
1322
			return;
1323
		}
1324
		if (command === "commandsymbol") {
1325
			sys.stopEvent();
1326
			var symbol = commandData;
1327
			if (symbol === undefined) {
1328
				return;
1329
			}
1330
			if (symbol.length !== 1) {
1331
				sendBotMessage("Must be 1 character long");
1332
				return;
1333
			}
1334
			if (symbol === "!" || symbol === "/") {
1335
				sendBotMessage("Warning: This symbol is the same one used for most server scripts, you can still use it for client scripts, but it may interfere with server ones");
1336
			}
1337
			commandsymbol = symbol;
1338
			Utilities.saveSettings();
1339
			sendBotMessage("Command symbol is set to: " + symbol);
1340
			return;
1341
		}
1342
		if (command === "highlight" || command === "flashcolour") {
1343
			sys.stopEvent();
1344
			if (commandData === undefined) {
1345
				hilight = "BACKGROUND-COLOR: #ffcc00";
1346
				Utilities.saveSettings();
1347
				sendBotMessage("Highlight colour set to the default");
1348
				return;
1349
			}
1350
			hilight = "BACKGROUND-COLOR: " + commandData;
1351
			Utilities.saveSettings();
1352
			sendBotMessage("Highlight colour set to: " + hilight);
1353
			return;
1354
		}
1355
		if (command === "logchannels") {
1356
			sys.stopEvent();
1357
			sendBotMessage("You are logging: " + logchannel);
1358
		}
1359
		if (command === "addlogchannel") {
1360
			sys.stopEvent();
1361
			if (isSafeScripts()) {
1362
				return;
1363
			}
1364
			if (typeof (sys.filesForDirectory('Channel Logs')) === "undefined") {
1365
				sys.makeDir('Channel Logs');
1366
				return;
1367
			}
1368
			var nlogchannel = commandData;
1369
			if (nlogchannel.search(/, /g) !== -1 || nlogchannel.search(/ ,/g) !== -1) {
1370
				nlogchannel = nlogchannel.replace(/, /g, ",")
1371
					.replace(/ ,/g, ",");
1372
			}
1373
			nlogchannel = nlogchannel.split(",");
1374
			logchannel = Utilities.eliminateDuplicates(nlogchannel.concat(logchannel));
1375
			Utilities.saveSettings();
1376
			sendBotMessage("You added " + commandData + " to your log channels!");
1377
		}
1378
		if (command === "removelogchannel") {
1379
			sys.stopEvent();
1380
			commandData = commandData.toLowerCase();
1381
			for (var x = 0; x < logchannel.length; x++) {
1382
				if (logchannel[x].toLowerCase() === commandData) {
1383
					logchannel.splice(x, 1);
1384
					Utilities.saveSettings();
1385
					sendBotMessage("You removed " + commandData + " from your log channels!");
1386
					return;
1387
				}
1388
			}
1389
			sendBotMessage(commandData + " is not a log channel!");
1390
		}
1391
		if (command === "armessage") {
1392
			sys.stopEvent();
1393
			if (commandData === undefined) {
1394
				sendBotMessage('Your current message is: ' + armessage);
1395
				return;
1396
			}
1397
			armessage = commandData;
1398
			Utilities.saveSettings();
1399
			sendBotMessage('You set your auto-respond message to: ' + armessage);
1400
			return;
1401
		}
1402
		if (command === "artype") {
1403
			sys.stopEvent();
1404
			if (commandData === "command") {
1405
				artype = "command";
1406
				Utilities.saveSettings();
1407
				sendBotMessage('Your auto-respond message will be activated by command');
1408
				return;
1409
			}
1410
			if (commandData === "time") {
1411
				artype = "time";
1412
				Utilities.saveSettings();
1413
				sendBotMessage('Your auto-respond message will be activated by time');
1414
				return;
1415
			}
1416
			sendBotMessage('This is not a valid type!');
1417
			return;
1418
		}
1419
		if (command === "artime") {
1420
			sys.stopEvent();
1421
			var time = commandData.split(':');
1422
			if (time.length !== 2) {
1423
				sendBotMessage('Usage of this command is: ' + commandsymbol + 'artime starthour:endhour');
1424
				return;
1425
			}
1426
			if (isNaN(time[0]) || isNaN(time[1]) || time[0] < 0 || time[0] > 24 || time[1] < 0 || time[1] > 24 || time[0] === "" || time[1] === "") {
1427
				sendBotMessage('Make sure both parameters are numbers and are between 0 and 24');
1428
				return;
1429
			}
1430
			arstart = time[0];
1431
			arend = time[1];
1432
			Utilities.saveSettings();
1433
			sendBotMessage('You auto response message will activate between ' + arstart + ':00 and ' + arend + ':00');
1434
			return;
1435
		}
1436
		if (command === "aron") {
1437
			sys.stopEvent();
1438
			if (artype !== "command") {
1439
				return;
1440
			}
1441
			autoresponse = true;
1442
			Utilities.saveSettings();
1443
			sendBotMessage('You turned your auto response on');
1444
			return;
1445
		}
1446
		if (command === "aroff") {
1447
			sys.stopEvent();
1448
			if (artype !== "command") {
1449
				return;
1450
			}
1451
			autoresponse = false;
1452
			Utilities.saveSettings();
1453
			sendBotMessage('You turned your auto response off');
1454
			return;
1455
		}
1456
		if (command === "eval") {
1457
			sys.stopEvent();
1458
			eval(commandData);
1459
			return;
1460
		}
1461
		if (command === "evalp") {
1462
			sys.stopEvent();
1463
			var bindChannel = channel;
1464
			try {
1465
				var res = eval(commandData);
1466
				sendMessage("Got from eval: " + res, bindChannel);
1467
			}
1468
			catch (err) {
1469
				sendMessage("Error in eval: " + err, bindChannel);
1470
			}
1471
		}
1472
	}
1473
});
1474
require = function require(module_name) {
1475
	var module = {};
1476
	module.module = module;
1477
	module.exports = {};
1478
	module.source = module_name;
1479
	with(module) {
1480
		var content = sys.getFileContent(scriptsFolder + "/" + module_name);
1481
		if (content) {
1482
			try {
1483
				eval(sys.getFileContent(scriptsFolder + "/" + module_name));
1484
			}
1485
			catch (e) {
1486
				print("Error loading module " + module_name + ": " + e + (e.lineNumber ? " on line: " + e.lineNumber : ""));
1487
			}
1488
		}
1489
	}
1490
	return module.exports;
1491
};
1492
1493
function print(message) {
1494
	sendMessage(message);
1495
}
1496
1497
function cleanFile(filename) {
1498
	sys.appendToFile(filename, "");
1499
}
1500
1501
function updateFile(filename) {
1502
	var url = script_url + "clientscripts/" + filename;
1503
	if (/^https?:\/\//.test(filename)) {
1504
		url = filename;
1505
	}
1506
	filename = filename.split(/\//).pop();
1507
	sys.webCall(url, function (resp) {
1508
		sys.writeToFile(scriptsFolder + "/" + filename, resp);
1509
		loadPlugins();
1510
		sendBotMessage("Plugin " + filename + " updated!");
1511
	});
1512
}
1513
1514
function checkPlugins() {
1515
	for (var x = 0; x < userplugins.length; x++) {
1516
		if (pluginFiles.indexOf(userplugins[x]) === -1) {
1517
			pluginFiles = pluginFiles.concat(userplugins[x]);
1518
		}
1519
	}
1520
	for (var x = 0; x < pluginFiles.length; x++) {
1521
		cleanFile(scriptsFolder + '/' + pluginFiles[x]);
1522
		if (sys.getFileContent(scriptsFolder + '/' + pluginFiles[x]) === "") {
1523
			updateFile(pluginFiles[x]);
1524
		}
1525
	}
1526
	loadPlugins();
1527
}
1528
1529
function addPlugin(filename) {
1530
	var url = script_url + "clientscripts/" + filename;
1531
	if (/^https?:\/\//.test(filename)) {
1532
		url = filename;
1533
	}
1534
	filename = filename.split(/\//).pop();
1535
	sys.webCall(url, function (resp) {
1536
		sys.writeToFile(scriptsFolder + "/" + filename, resp);
1537
		loadPlugins();
1538
		sendBotMessage("Plugin " + filename + " added!");
1539
	});
1540
	userplugins = userplugins.concat(filename);
1541
	Utilities.saveSettings();
1542
}
1543
1544
function loadPlugins() {
1545
	var plugins = [];
1546
	for (var i = 0; i < pluginFiles.length; ++i) {
1547
		var plugin = require(pluginFiles[i]);
1548
		plugin.source = pluginFiles[i];
1549
		plugins.push(plugin);
1550
	}
1551
	Plugins = plugins;
1552
}
1553
1554
function callPlugins(event) {
1555
	var ret = false;
1556
	var args = Array.prototype.slice.call(arguments, 1);
1557
	for (var i = 0; i < Plugins.length; ++i) {
1558
		if (Plugins[i].hasOwnProperty(event)) {
1559
			try {
1560
				if (Plugins[i][event].apply(Plugins[i], args)) {
1561
					ret = true;
1562
					break;
1563
				}
1564
			}
1565
			catch (e) {
1566
				sendBotMessage('Plugins-error on {0}: {1}'.format(Plugins[i].source, e));
1567
			}
1568
		}
1569
	}
1570
	return ret;
1571
}
1572
1573
function getPlugins(data) {
1574
	var ret = {};
1575
	for (var i = 0; i < Plugins.length; ++i) {
1576
		if (Plugins[i].hasOwnProperty(data)) {
1577
			ret[Plugins[i].source] = Plugins[i][data];
1578
		}
1579
	}
1580
	return ret;
1581
}
1582
1583
function init() { //defines all the variables that are going to be used in the script, uses default if no saved settings are found
1584
	if (sys.isSafeScripts() !== true) {
1585
		Utilities.loadSettings();
1586
		checkScriptVersion();
1587
	}
1588
	else {
1589
		Utilities.loadFromRegistry();
1590
	}
1591
	checkPlugins();
1592
	playerswarn = [];
1593
	initCheck = true;
1594
}
1595
1596
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
1597
	var checkscript, version;
1598
	var regex = /"([^"]*)"/g;
1599
	if (checkversion === false && !bool) {
1600
		return;
1601
	}
1602
	sys.webCall(script_url + 'changelog.json', function (resp) {
1603
		if (resp.length === 0) {
1604
			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");
1605
			return;
1606
		}
1607
		var changelog;
1608
		try {
1609
			changelog = JSON.parse(resp);
1610
		} catch (e) {
1611
			sendBotMessage("Changelog couldn't be read. Error: " + e);
1612
			return;
1613
		}
1614
		version = changelog.latest;
1615
		var type = {
1616
			"0": "Major Release (huge changes)",
1617
			"1": "Minor Release (new features)",
1618
			"2": "Bug fixes/Minor Update"
1619
		};f
1620
		if (version !== Script_Version) {
1621
			var typeno;
1622
			var nversion = version.split('.');
1623
			var cversion = Script_Version.split('.');
1624
			for (var x = 0; x < nversion.length; x++) {
1625
				if (nversion[x] !== cversion[x]) {
1626
					typeno = x;
1627
					break;
1628
				}
1629
			}
1630
			if (typeno === undefined) { //this shouldn't ever happen though
1631
				return;
1632
			}
1633
			sendBotMessage("A client script update is available, type: " + type[typeno] + ". Use " + commandsymbol + "updatescripts to update. Use " + commandsymbol + "changelog " + version + " to see the changes");
1634
			return;
1635
		}
1636
		if (bool) {
1637
			sendBotMessage("No update detected");
1638
		}
1639
	});
1640
}
1641
1642
function nameCheck(string) { //adapted from the PO Source Code
1643
	if (string === undefined) {
1644
		throw "Undefined name";
1645
	}
1646
	if (string.length > 20) {
1647
		throw "Name too long";
1648
	}
1649
	if (string.length === 0) {
1650
		throw "Name not long enough";
1651
	}
1652
	if (Utilities.isPunct(string[0]) !== true && Utilities.isAlnum(string[0]) !== true) {
1653
		throw "Name cannot have start with a non-punctuation or non-alphanumeric character";
1654
	}
1655
	if (string[0] === "+") {
1656
		throw "Cannot use \"+\" at start of names";
1657
	}
1658
	var spaced = false;
1659
	var punct = false;
1660
	for (var x = 0; x < string.length; x++) {
1661
		if (string[x] === '\n' || string[x] === '%' || string[x] === '*' || string[x] === '<' || string[x] === ':' || string[x] === '(' || string[x] === ')' || string[x] === ';') {
1662
			throw "Invalid Character";
1663
		}
1664
		if (Utilities.isPunct(string[x])) {
1665
			if (punct === true) {
1666
				//Error: two punctuations are not separated by a letter/number
1667
				throw "two punctuations are not separated by a letter/number";
1668
			}
1669
			punct = true;
1670
			spaced = false;
1671
		}
1672
		else if (string[x] === ' ') {
1673
			if (spaced === true) {
1674
				//Error: two spaces are following
1675
				throw "two spaces are following";
1676
			}
1677
			spaced = true;
1678
		}
1679
		else if (Utilities.isAlnum(string[x])) {
1680
			//we allow another punct & space
1681
			punct = false;
1682
			spaced = false;
1683
		}
1684
	}
1685
	if (string.length === 1 && Utilities.isPunct(string[0])) {
1686
		return nameCheck(fixup(string));
1687
	}
1688
	if (Utilities.isPunct(string[string.length - 1]) !== true && Utilities.isAlnum(string[string.length - 1]) !== true) {
1689
		return nameCheck(fixup(string));
1690
	}
1691
	return string;
1692
}
1693
1694
function fixup(input) {
1695
	if (input.length > 0 && input[input.length - 1] === ' ') {
1696
		return input.substr(0, input.length - 1);
1697
	}
1698
	return "";
1699
}
1700
1701
function saveToLog(message, channel) { //saves messages to a log file
1702
	if (sys.isSafeScripts()) {
1703
		return;
1704
	}
1705
	var logging = false;
1706
	for (var x = 0; x < logchannel.length; x++) {
1707
		if (client.channelName(channel).toLowerCase() === logchannel[x].toLowerCase()) {
1708
			logging = true;
1709
			break;
1710
		}
1711
	}
1712
	if (logging === false) {
1713
		return;
1714
	}
1715
	if (typeof (sys.filesForDirectory('Channel Logs')) === "undefined") { //in case somehow it ends up in a different folder, or the folder gets removed
1716
		sys.makeDir('Channel Logs');
1717
	}
1718
	var time = new Date();
1719
	var h = time.getHours();
1720
	var m = time.getMinutes();
1721
	var s = time.getSeconds();
1722
	var d = time.getDate();
1723
	var mo = parseInt(time.getMonth() + 1, 10);
1724
	var y = time.getFullYear();
1725
	var date = d + "-" + mo + "-" + y;
1726
	m = checkTime(m);
1727
	s = checkTime(s);
1728
	var timestamp = h + ":" + m + ":" + s;
1729
	sys.appendToFile("Channel Logs/" + client.channelName(channel) + " " + date + ".txt", "(" + timestamp + ") " + message + "\n");
1730
}
1731
1732
function checkTime(i) { //adds a 0 in front of one digit minutes/seconds
1733
	if (i < 10) {
1734
		i = "0" + i;
1735
	}
1736
	return i;
1737
}
1738
1739
function say(message, channel) {
1740
	if (channel === undefined) {
1741
		channel = client.currentChannel();
1742
	}
1743
	client.network().sendChanMessage(channel, message);
1744
}
1745
1746
function getName(string, type) { //gets the name from rainbow/me messages
1747
	var name = "";
1748
	if (type === "rainbow") {
1749
		string = Utilities.stripHTML(string);
1750
		var pos = string.indexOf(': ');
1751
		if (pos !== -1) {
1752
			name = string.substring(0, pos);
1753
			if (name[0] === "+") { //auth symbol is + here rather than user defined, since the PO Server Scripts print "+" out automatically for auth
1754
				name = name.substr(1);
1755
			}
1756
		}
1757
	}
1758
	if (type === "me") {
1759
		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
1760
	}
1761
	return name;
1762
}
1763
1764
function printMessage(message, channel, link) // no html escape :3
1765
{
1766
	if (channel === undefined) {
1767
		channel = client.currentChannel();
1768
	}
1769
	if (link === "<ping/>") {
1770
		message = message.replace(/&lt;ping\/&gt;/g, link);
1771
	}
1772
	if (message.indexOf("(link)") !== -1 && link !== undefined) {
1773
		message = message.replace(/\(link\)/g, "<a href ='" + link + "'>" + link + "</a>");
1774
	}
1775
	client.printChannelMessage("<font color = '" + Utilities.html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + Utilities.html_escape(clientbotname) + ":" + Utilities.tagend(clientbotstyle) + "</font> " + message, channel, true);
1776
}
1777
1778
function sendBotMessage(message, channel, link) { //sends a message with the bot name in front of it
1779
	if (channel === undefined) {
1780
		channel = client.currentChannel();
1781
	}
1782
	message = Utilities.html_escape(message);
1783
	if (link === "<ping/>") {
1784
		message = message.replace(/&lt;ping\/&gt;/g, link);
1785
	}
1786
	if (message.indexOf("(link)") !== -1 && link !== undefined) {
1787
		message = message.replace(/\(link\)/g, "<a href ='" + link + "'>" + link + "</a>");
1788
	}
1789
	client.printChannelMessage("<font color = '" + Utilities.html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + Utilities.html_escape(clientbotname) + ":" + Utilities.tagend(clientbotstyle) + "</font> " + message, channel, true);
1790
}
1791
1792
function awayFunction() { //makes the user go away if needed
1793
	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
1794
		return;
1795
	}
1796
	if (autoidle === true) {
1797
		client.goAway(true);
1798
	}
1799
}
1800
1801
function stalkWordCheck(string, playname, bot, channel) { //adds flashes to names/stalkwords
1802
	var ownName = Utilities.html_escape(client.ownName());
1803
	var newstring = "";
1804
	if (string.toLowerCase().indexOf(ownName.toLowerCase()) !== -1 && playname !== ownName && flash !== false && fchannel.indexOf(client.channelName(channel)) === -1 && channel !== undefined) {
1805
		var name = new RegExp("\\b(" + ownName + ")\\b(?![^\\s<]*>)", "i");
1806
		var names = string.match(name);
1807
		if (names) {
1808
			newstring = (bot ? string : string.replace(name, "<span style='" + hilight + "'>" + names[0] + "</span>"));
1809
			if (newstring !== string) {
1810
				string = newstring.replace(newstring, "<i> " + newstring + "</i><ping/>");
1811
			}
1812
			if (bot) {
1813
				string = string + "<ping/>";
1814
			}
1815
		}
1816
	}
1817
	for (var x = 0; x < stalkwords.length; x++) {
1818
		var stalk = new RegExp("\\b(" + stalkwords[x] + ")\\b(?![^\\s<]*>)", "i");
1819
		var stalks = string.match(stalk);
1820
		if (string.toLowerCase().search(stalk) !== -1 && playname !== client.ownName() && flash !== false && fchannel.indexOf(client.channelName(channel)) === -1 && channel !== undefined) {
1821
			newstring = (bot ? string : string.replace(stalk, "<span style='" + hilight + "'>" + stalks[0] + "</span>"));
1822
			if (newstring !== string) {
1823
				string = newstring.replace(newstring, "<i> " + newstring + "</i><ping/>");
1824
			}
1825
			if (bot) {
1826
				string = string + "<ping/>";
1827
			}
1828
		}
1829
	}
1830
	return string;
1831
}
1832
1833
function htmllinks(text) { //makes sure links get linked!
1834
	var exp = /([a-zA-Z]+:\/\/|www\.)[^\s']+/ig;
1835
	var found = text.match(exp);
1836
	var newtext;
1837
	var newfound;
1838
	for (var x in found) {
1839
		if (found.hasOwnProperty(x)) {
1840
			var link = found[x];
1841
			newfound = found[x].replace(/\//g, sys.md5('/')).replace(/_/g, sys.md5('_'));
1842
			var regex  = /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*).*/;
1843
			if (link.match(regex) && youtube === true) {
1844
				var name = link.match(regex)[link.match(regex).length-1];
1845
				var resp;
1846
				try {
1847
					resp = JSON.parse(sys.synchronousWebCall('https://gdata.youtube.com/feeds/api/videos/'+name+'?alt=json'));
1848
					link = '<span title="Youtube"><img src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAYAAABr5z2BAAABIklEQVQoz53LvUrDUBjG8bOoOammSf1IoBSvoCB4JeIqOHgBLt6AIMRBBQelWurQ2kERnMRBsBUcIp5FJSBI5oQsJVkkUHh8W0o5nhaFHvjBgef/Mq+Q46RJBMkI/vE+aOus956tnEswIZe1LV0QyJ5sE2GzgZfVMtRNIdiDpccEssdlB1mW4bvTwdvWJtRdErM7U+8S/FJykCRJX5qm+KpVce8UMNLRLbulz4iSjTAMh6Iowsd5BeNadp3nUF0VlxAEwZBotXC0Usa4ll3meZdA1iguwvf9vpvDA2wvmKgYGtSud8suDB4TyGr2PF49D/vra9jRZ1BVdknMzgwuCGSnZEObwu6sBnVTCHZiaC7BhFx2PKdxUidiAH/4lLo9Mv0DELVs9qsOHXwAAAAASUVORK5CYII="></span>' + ' ' + '<span title = "'+ Utilities.html_escape(link) + '">' + resp.entry.title.$t + '</span>';
1849
				} catch (e) {
1850
					link = newfound;
1851
				}
1852
			} else {
1853
				link = newfound;
1854
			}
1855
			newtext = ("<a href ='" + newfound + "'>" + link + "</a>").replace(/&amp;/gi, "&");
1856
			text = text.replace(found[x], newtext);
1857
		}
1858
	}
1859
	return text;
1860
}
1861
1862
function addExtras(text, playname, bot, channel) { //adds stalkwords/links/enriched text etc
1863
	text = htmllinks(text);
1864
	text = enrichedText(text);
1865
	if (client.channel(client.currentChannel())) {
1866
		text = client.channel(client.currentChannel()).addChannelLinks(text);
1867
	}
1868
	text = greenText(text);
1869
	text = stalkWordCheck(text, playname, bot, channel);
1870
	var md5 = new RegExp(sys.md5('/'), "g");
1871
	var md51 = new RegExp(sys.md5('_'), "g");
1872
	text = text.replace(md5, '/').replace(md51, "_");
1873
	return text;
1874
}
1875
1876
function enrichedText(text) { //applies the enriched text, adapted from the PO 1.0.60 source
1877
	if (etext === false) {
1878
		return text;
1879
	}
1880
	var expi = new RegExp("/(\\S+)/(?![^\\s<]*>)", "g");
1881
	text = text.replace(expi, "<i>$1</i>");
1882
	var expii = new RegExp("\\\\(\\S+)\\\\(?![^\\s<]*>)", "g");
1883
	text = text.replace(expii, "<i>$1</i>");
1884
	var expb = new RegExp("\\*(\\S+)\\*(?![^\\s<]*>)", "g");
1885
	text = text.replace(expb, "<b>$1</b>");
1886
	var expu = new RegExp("_(\\S+)_(?![^\\s<]*>)", "g");
1887
	text = text.replace(expu, "<u>$1</u>");
1888
	return text;
1889
}
1890
1891
function greenText(text) { //applies greentext
1892
	if (text.substr(0, 4) === "&gt;" && tgreentext === true) {
1893
		text = "<font color = '" + greentext + "'>" + text + "</font>";
1894
	}
1895
	else {
1896
		text = "<font color = '" + fontcolour + "'>" + text;
1897
	}
1898
	return text;
1899
}
1900
1901
function isSafeScripts() { //checks if safe scripts is on and if it is it sends a message
1902
	if (sys.isSafeScripts()) {
1903
		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");
1904
		return true;
1905
	}
1906
	return false;
1907
}
1908
1909
function sendMessage(message, channel) { //sends a message to the user
1910
	if (channel === undefined) {
1911
		channel = client.currentChannel();
1912
	}
1913
	client.printChannelMessage(message, channel, false);
1914
}
1915
1916
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
1917
	for (var i = 0; i < ignore.length; i++) {
1918
		if (name.toLowerCase() === ignore[i].toLowerCase()) {
1919
			client.ignore(client.id(name), true);
1920
		}
1921
	}
1922
	return client.isIgnored(client.id(name));
1923
}
1924
1925
function sendHtmlMessage(message, channel) { //sends a html message to the user
1926
	if (channel === undefined) {
1927
		channel = client.currentChannel();
1928
	}
1929
	client.printChannelMessage(message, channel, true);
1930
}
1931
1932
function formatMessage(message, channel) {
1933
	if (callPlugins("formatMessage", message, channel)) {
1934
		return;
1935
	}
1936
	var pos = message.indexOf(': ');
1937
	var bot = false;
1938
	if (pos !== -1) {
1939
		if (client.id(message.substring(0, pos)) === -1 || client.id(message.substring(0, pos)) === undefined) {
1940
			bot = true;
1941
		}
1942
		var playname = message.substring(0, pos);
1943
		if (ignoreCheck(playname)) {
1944
			sys.stopEvent();
1945
			return;
1946
		}
1947
		var id = client.id(playname);
1948
		var playmessage = Utilities.html_escape(message.substr(pos + 2));
1949
		var colour = clientbotcolour;
1950
		if (id !== -1) {
1951
			colour = client.color(id);
1952
		}
1953
		var auth = client.auth(id);
1954
		if (auth > 4 || auth < 0) {
1955
			auth = 4;
1956
		}
1957
		playmessage = addExtras(playmessage, playname, bot, channel);
1958
		var symbol = auth_symbol[auth];
1959
		if (bot === true) {
1960
			symbol = "";
1961
		}
1962
		if (channel === undefined) {
1963
			client.printHtml("<font face ='" + fonttype + "'><font size = " + fontsize + "><font color='" + colour + "'><timestamp/> " + symbol + auth_style[auth] + playname + ": </font>" + Utilities.tagend(auth_style[auth]) + fontstyle + playmessage + Utilities.tagend(fontstyle));
1964
		}
1965
		else {
1966
			client.printChannelMessage("<font face ='" + fonttype + "'><font size = " + fontsize + "><font color='" + colour + "'><timestamp/> " + symbol + auth_style[auth] + playname + ": </font>" + Utilities.tagend(auth_style[auth]) + fontstyle + playmessage + Utilities.tagend(fontstyle), channel, true);
1967
		}
1968
		if(client.trayMessage) {
1969
			if (playmessage.indexOf('<ping/>') !== -1 && !client.windowActive()) {
1970
				client.trayMessage('Ping' + (channel ? " in " + client.channelName(channel) : ""), Utilities.stripHTML(playname + ":" + playmessage));
1971
			}
1972
		}
1973
		
1974
		sys.stopEvent();
1975
	}
1976
}
1977
1978
function getAbility(pokemon, gen) {
1979
	if (sys.pokemon(pokemon) === "Keldeo-R" || sys.pokemon(pokemon) === "Meloetta-S") {
1980
		pokemon = pokemon % 65536;
1981
	}
1982
	var abilityone = sys.pokeAbility(pokemon, 0, gen);
1983
	var abilitytwo = sys.pokeAbility(pokemon, 1, gen);
1984
	var abilitydw = sys.pokeAbility(pokemon, 2, gen);
1985
	if (pokemon === sys.pokeNum('Thundurus-T')) {
1986
		abilityone = 10;
1987
	}
1988
	if (pokemon === sys.pokeNum('Tornadus-T')) {
1989
		abilityone = 144;
1990
	}
1991
	if (pokemon === sys.pokeNum('Landorus-T')) {
1992
		abilityone = 22;
1993
	}
1994
	if (pokemon === sys.pokeNum('Kyurem-W')) {
1995
		abilityone = 163;
1996
	}
1997
	if (pokemon === sys.pokeNum('Kyurem-B')) {
1998
		abilityone = 164;
1999
	}
2000
	if (abilitytwo === 0 && abilitydw === 0 || abilitytwo === undefined && abilitydw === undefined) {
2001
		return "Ability: " + sys.ability(abilityone);
2002
	}
2003
	if (abilitytwo === 0 && abilitydw !== 0 || abilitytwo === undefined && abilitydw !== undefined) {
2004
		return "Abilities: " + sys.ability(abilityone) + " / " + sys.ability(abilitydw) + " (Dream World)";
2005
	}
2006
	if (abilitytwo !== 0 && abilitydw === 0 || abilitytwo !== undefined && abilitydw === undefined) {
2007
		return "Abilities: " + sys.ability(abilityone) + " / " + sys.ability(abilitytwo);
2008
	}
2009
	return "Abilities: " + sys.ability(abilityone) + " / " + sys.ability(abilitytwo) + " / " + sys.ability(abilitydw) + " (Dream World)";
2010
}
2011
2012
function getMinMax(val, hp, level, gen) {
2013
	if (level === undefined) {
2014
		level = 100;
2015
	}
2016
	if (gen > 2) {
2017
		var min, max;
2018
		val = parseInt(val * 2, 10);
2019
		if (hp !== true) {
2020
			var minmin, maxplus;
2021
			min = Math.floor((val + 31) * level / 100) + 5;
2022
			minmin = parseInt(Math.floor(((val + 31) * level / 100) + 5) * 0.9, 10);
2023
			max = Math.floor((val + 31 + 63) * level / 100 + 5);
2024
			maxplus = parseInt(Math.floor(((val + 31 + 63) * level / 100) + 5) * 1.1, 10);
2025
			return "&nbsp;&nbsp;&nbsp;&nbsp;Min (-): " + minmin + " | Min: " + min + " | Max: " + max + " | Max (+): " + maxplus;
2026
		}
2027
		min = Math.floor((val + 31) * level / 100) + level + 10;
2028
		max = Math.floor((val + 63 + 31) * level / 100) + level + 10;
2029
		return "&nbsp;&nbsp;&nbsp;&nbsp;Min: " + min + " | Max: " + max;
2030
	}
2031
	if (hp !== true) {
2032
		var stat = (15 + val + (Math.sqrt(65535) / 8)) * level / 50 + 5;
2033
		return "&nbsp;&nbsp;&nbsp;&nbsp; Stat: " + Math.floor(stat);
2034
	}
2035
	var stat = (15 + val + (Math.sqrt(65535) / 8) + 50) * level / 50 + 10;
2036
	return "&nbsp;&nbsp;&nbsp;&nbsp; Stat: " + Math.floor(stat);
2037
}
2038
2039
function getWeight(pokemon) {
2040
	if (weightData === undefined) {
2041
		weightData = {};
2042
		var data = sys.getFileContent('db/pokes/weight.txt').split('\n');
2043
		for (var x = 0; x < data.length; x++) {
2044
			var line = data[x].split(" ");
2045
			var pokenum = line[0].split(":");
2046
			pokenum[0] = parseInt(65536 * pokenum[1], 10) + parseInt(pokenum[0], 10);
2047
			weightData[pokenum[0]] = line[1];
2048
		}
2049
	}
2050
	return weightData[pokemon];
2051
}
2052
2053
function getWeightDamage(weight) {
2054
	if (weight <= 10) {
2055
		return 20;
2056
	}
2057
	else if (10 <= weight && weight < 25) {
2058
		return 40;
2059
	}
2060
	else if (25 <= weight && weight < 50) {
2061
		return 60;
2062
	}
2063
	else if (50 <= weight && weight < 100) {
2064
		return 80;
2065
	}
2066
	else if (100 <= weight && weight < 200) {
2067
		return 100;
2068
	}
2069
	return 120;
2070
}
2071
2072
function getTierInfo(pokemon) {
2073
	cleanFile('tiers.json');
2074
	if (sys.getFileContent('tiers.json') === "") {
2075
		sys.writeToFile('tiers.json', sys.synchronousWebCall('https://gist.github.com/CrystalMoogle/76a72f564d7eb8c509dd/raw/tiers.json'));
2076
	}
2077
	var data = JSON.parse(sys.getFileContent('tiers.json'));
2078
	var tiers = Object.keys(data);
2079
	var legalTiers = [];
2080
	var sameStatFormes = ["Unown", "Gastrodon", "Arceus", "Genesect", "Deerling", "Sawsbuck", "Keldeo"];
2081
	var poke = sys.pokemon(pokemon);
2082
	if (sameStatFormes.indexOf(poke.substr(0, poke.indexOf("-"))) !== -1) {
2083
		poke = sameStatFormes[sameStatFormes.indexOf(poke.substr(0, poke.indexOf("-")))];
2084
	}
2085
	var banparents = [];
2086
	for(var x = 0; x < tiers.length; x++) {
2087
		var banparent = data[tiers[x]].banParent;
2088
		var end = false;
2089
		if (banparent) {
2090
			while (end === false) {
2091
				if (data[banparent].pokemons.indexOf(poke) !==-1 || banparents.indexOf(banparent) !== -1) {
2092
					banparents.push(tiers[x]);
2093
				}
2094
				if (data[banparent].banparent) {
2095
					var banparent = data[banparent].banParent;
2096
				} else {
2097
					end = true;
2098
				}
2099
			}
2100
		}
2101
		if (data[tiers[x]].pokemons.indexOf(poke) === -1 && banparents.indexOf(tiers[x]) === -1) {
2102
			legalTiers.push("<a href='http://wiki.pokemon-online.eu/view/"+tiers[x].replace(/ /g,"_")+"'>"+tiers[x]+"</a>");
2103
		}
2104
	}
2105
	return legalTiers.join(", ");
2106
}
2107
2108
function pokeDex(pokemon, gen, level) {
2109
	if (sys.pokemon(pokemon) === "Missingno") {
2110
		throw "Invalid pokemon";
2111
	}
2112
	if (gen === undefined) {
2113
		gen = 5;
2114
	}
2115
	if (level === undefined) {
2116
		level = 100;
2117
	}
2118
	var data = [];
2119
	var npokemon = pokemon; //so we can refer to the old number when needed
2120
	if (pokemon > 649) {
2121
		npokemon = pokemon % 65536;
2122
	}
2123
	var generations = [0, 151, 252, 386, 493, 649];
2124
	if (npokemon > generations[gen]) {
2125
		throw "Pokemon is not in this gen";
2126
	}
2127
	data.push("");
2128
	data.push("<b>#" + npokemon + " " + sys.pokemon(pokemon) + "</b>");
2129
	data.push('<img src="pokemon:' + pokemon + '&gen=' + gen + '"/>' + (gen === 1 ? "" : '<img src="pokemon:' + pokemon + '&gen=' + gen + '&shiny=true"/>'));
2130
	data.push('<b>Level: ' + level + '</b>');
2131
	var typea = sys.pokeType1(pokemon, gen);
2132
	var typeb = sys.pokeType2(pokemon, gen);
2133
	data.push("<b>Type: " + sys.type(typea) + (typeb !== 17 ? " / " + sys.type(typeb) + "</b>" : "</b>"));
2134
	if (gen > 2) {
2135
		data.push("<b>" + getAbility(pokemon, gen) + "</b>");
2136
	}
2137
	data.push("<b>HP: " + sys.baseStats(pokemon, 0, gen) + "</b>");
2138
	if (pokemon !== sys.pokeNum("Shedinja")) {
2139
		data.push(getMinMax(sys.baseStats(pokemon, 0, gen), true, level, gen));
2140
	}
2141
	else {
2142
		data.push("&nbsp;&nbsp;&nbsp;&nbsp;Min: " + 1 + " | Max: " + 1);
2143
	}
2144
	data.push("<b>Atk: " + sys.baseStats(pokemon, 1, gen) + "</b>");
2145
	data.push(getMinMax(sys.baseStats(pokemon, 1, gen), false, level, gen));
2146
	data.push("<b>Def: " + sys.baseStats(pokemon, 2, gen) + "</b>");
2147
	data.push(getMinMax(sys.baseStats(pokemon, 2, gen), false, level, gen));
2148
	if (gen !== 1) {
2149
		data.push("<b>SpAtk: " + sys.baseStats(pokemon, 3, gen) + "</b>");
2150
		data.push(getMinMax(sys.baseStats(pokemon, 3, gen), false, level, gen));
2151
		data.push("<b>SpDef: " + sys.baseStats(pokemon, 4, gen) + "</b>");
2152
		data.push(getMinMax(sys.baseStats(pokemon, 4, gen), false, level, gen));
2153
	}
2154
	else {
2155
		data.push("<b>Special: " + sys.baseStats(pokemon, 3, gen) + "</b>");
2156
		data.push(getMinMax(sys.baseStats(pokemon, 3, gen), false, level, gen));
2157
	}
2158
	data.push("<b>Speed: " + sys.baseStats(pokemon, 5, gen) + "</b>");
2159
	data.push(getMinMax(sys.baseStats(pokemon, 5, gen), false, level, gen));
2160
	var weight = getWeight(pokemon);
2161
	if (weight === undefined) {
2162
		weight = getWeight(npokemon);
2163
	}
2164
	var weightLbs = weight * 2.20462;
2165
	data.push("<b>Weight: " + weight + "kg / " + weightLbs.toFixed(1) + "lbs</b>");
2166
	data.push("<b>Damage from GK/LK: " + getWeightDamage(weight) + "</b>");
2167
	/*if (gen === 5) {
2168
	 try {
2169
	 data.push("<b>Legal in tiers: " + getTierInfo(pokemon) + "</b>");
2170
	 } catch (e) {
2171
	 data.push("<b>Tier info unavailable</b>");
2172
	 }
2173
	 }*/
2174
	data.push("");
2175
	for (var x = 0; x < data.length; x++) {
2176
		sendHtmlMessage(data[x]);
2177
	}
2178
}
2179
2180
function changeScript(resp) {
2181
		//sys.changeScript(sys.getFileContent(sys.scriptsFolder + 'scripts.js'));
2182
		sendBotMessage('Scripts were not updated bc reasons');
2183
}
2184
2185
2186
if (client.ownId() !== -1) {
2187
	init();
2188
}
2189
client.network().playerLogin.connect(function () { //only call when the user has logged in to prevent any crashes
2190
	awayFunction();
2191
	init();
2192
});
2193
2194
Script_Version = "2.0.10"; //version the script is currently on
2195
//noinspection JSUnusedAssignment
2196
poScript = ({
2197
	onPlayerReceived: function (id) { //detects when a player is visible to the client (mostly logins, but may also happen upon joining a new channel)
2198
		var flashvar = "";
2199
		if (friendsflash === true) {
2200
			flashvar = "<ping/>";
2201
		}
2202
		for (var x = 0; x < friends.length; x++) {
2203
			if (client.name(id).toLowerCase() === friends[x].toLowerCase() && flash === true) {
2204
				sendHtmlMessage("<font color = '" + Utilities.html_escape(clientbotcolour) + "'><timestamp/>" + clientbotstyle + Utilities.html_escape(clientbotname) + ":" + Utilities.tagend(clientbotstyle) + "</font> User <a href='po:pm/" + id + "'>" + client.name(id) + "</a> has logged in" + flashvar + "", client.currentChannel());
2205
			}
2206
		}
2207
		for (var x = 0; x < ignore.length; x++) {
2208
			if (client.name(id).toLowerCase() === ignore[x].toLowerCase()) {
2209
				client.ignore(id, true);
2210
			}
2211
		}
2212
	},
2213
	onPlayerJoinChan: function (id, channel) {
2214
		saveToLog(client.name(id) + " joined the channel", channel);
2215
	},
2216
	onPlayerLeaveChan: function (id, channel) {
2217
		saveToLog(client.name(id) + " left the channel", channel);
2218
	},
2219
	beforeNewMessage: function (message, html) {
2220
		if (initCheck !== true) {
2221
			init();
2222
		}
2223
		if (html === true) {
2224
			return;
2225
		}
2226
		formatMessage(message);
2227
	},
2228
	beforeChannelMessage: function (message, channel, html) { //detects a channel specific message
2229
		if (initCheck !== true) {
2230
			init();
2231
		}
2232
		callPlugins("beforeChannelMessage", message, channel, html);
2233
		if (message.indexOf('<timestamp/> *** <b>') !== -1) {
2234
			var ignored = getName(message, "me");
2235
			if (ignoreCheck(ignored)) {
2236
				sys.stopEvent();
2237
				return;
2238
			}
2239
			saveToLog(Utilities.stripHTML(message), channel);
2240
		}
2241
		if (message.indexOf('<timestamp/><b><span style') !== -1) {
2242
			var ignored = getName(message, "rainbow");
2243
			if (ignoreCheck(ignored)) {
2244
				sys.stopEvent();
2245
				return;
2246
			}
2247
			saveToLog(Utilities.stripHTML(message), channel);
2248
		}
2249
		if (html === true) {
2250
			return;
2251
		}
2252
		saveToLog(message, channel);
2253
		
2254
		if (contains(message, ":"))
2255
		{
2256
			var m = getMessage(message);
2257
			
2258
			//if (getUser(message) != client.ownName)
2259
			tryKeyword(m, channel, getUser(message));
2260
			
2261
			if (letOthersDefine && startsWith(m, "@" + client.ownName().toLowerCase() + "define")
2262
			&& contains(m, ";") && blacklist.indexOf(client.channelName(channel).toLowerCase()) == -1)
2263
			{
2264
				
2265
				addResponse(m.substr(("@" + client.ownName().toLowerCase() + "define").length + 1)
2266
					.split(";;")[0], m.substr(m.indexOf(";;") + 2));
2267
				say("Added!", channel);
2268
			}
2269
		}
2270
		
2271
		formatMessage(message, channel);
2272
	},
2273
	beforePMReceived: function (id) { // called before a PM is received
2274
		if (ignoreCheck(client.name(id))) {
2275
			sys.stopEvent();
2276
		}
2277
	},
2278
	afterPMReceived: function (id) { //called after a PM is received
2279
		if (playerswarn[id] === true) {
2280
			return;
2281
		}
2282
		var time = new Date();
2283
		var h = time.getHours();
2284
		if (artype === "time") {
2285
			if (arstart < arend) {
2286
				if (h >= arstart && h < arend) {
2287
					client.network().sendPM(id, armessage);
2288
					playerswarn[id] = true;
2289
					return;
2290
				}
2291
			}
2292
			if (h >= arend && h < arstart) {
2293
				client.network().sendPM(id, armessage);
2294
				playerswarn[id] = true;
2295
				return;
2296
			}
2297
		}
2298
		if (autoresponse === true) {
2299
			client.network().sendPM(id, armessage);
2300
			playerswarn[id] = true;
2301
		}
2302
	},
2303
	beforeSendMessage: function (message, channel) { //detects messages sent by the client
2304
		callPlugins("beforeSendMessage", message, channel);
2305
		if (message.toLowerCase() === "reset symbol") {
2306
			sys.stopEvent();
2307
			commandsymbol = "~";
2308
			sendBotMessage('You reset your command symbol to "~"!');
2309
			Utilities.saveSettings();
2310
			return;
2311
		}
2312
		if (message[0] === commandsymbol) {
2313
			var command, commandData;
2314
			var pos = message.indexOf(' ');
2315
			if (pos !== -1) {
2316
				command = message.substring(1, pos).toLowerCase();
2317
				commandData = message.substr(pos + 1);
2318
			}
2319
			else {
2320
				command = message.substr(1).toLowerCase();
2321
			}
2322
			try {
2323
				Commands.commandHandler(command, commandData, channel);
2324
			}
2325
			catch (e) {
2326
				sendBotMessage('ERROR: ' + e); //TODO: Add proper error checks
2327
			}
2328
			if (callPlugins("commandHandler", command, commandData, channel)) {
2329
				sys.stopEvent();
2330
			}
2331
		}
2332
		
2333
		if (startsWith(message, commandsymbol + "add "))
2334
		{
2335
			sys.stopEvent();
2336
			if (contains(message, ";"))
2337
			{
2338
				addResponse(message.substr(5).split(";;")[0], message.substr(message.indexOf(";;") + 2));
2339
				printMessage("Response \"" + message.substr(message.indexOf(";;") + 2) 
2340
					+ "\" added for keyphrase \"" + message.substr(5).split(";;")[0] + "\"");
2341
			}
2342
			else
2343
			{
2344
				printMessage("Correct format is: " + commandsymbol + "add keyphrase;;response");
2345
			}
2346
		}
2347
		else if (startsWith(message, commandsymbol + "remove "))
2348
		{
2349
			sys.stopEvent();
2350
			
2351
			if (contains(message, ";;"))
2352
			{
2353
				if (removeResponse(message.substr(8).split(";;")[0], message.substr(message.indexOf(";;") + 2)))
2354
				{
2355
					printMessage("Response \"" + message.substr(message.indexOf(";;") + 2)
2356
						+ "\" removed from keyphrase \"" + message.substr(8).split(";;")[0] + "\"");
2357
				}
2358
				else
2359
				{
2360
					printMessage("Response \"" + message.substr(message.indexOf(";;") + 2) + "\" does not exist in keyphrase \""
2361
						+ message.substr(8).split(";;")[0] + "\"");
2362
				}
2363
			}
2364
			else
2365
			{
2366
				printMessage("Correct format is: " + commandsymbol + "remove keyphrase;;response");
2367
			}
2368
		}
2369
		else if (compare(message, commandsymbol + "save"))
2370
		{
2371
			sys.stopEvent();
2372
			saveResponses();
2373
		}
2374
		else if (compare(message, commandsymbol + "load"))
2375
		{
2376
			sys.stopEvent();
2377
			loadResponses();
2378
		}
2379
		else if (compare(message, commandsymbol + "myresponses"))
2380
		{
2381
			sys.stopEvent();
2382
			
2383
			printMessage("<b><u>Responses</u></b>");
2384
			
2385
			for (var i = 0; i < keywords.length; i++)
2386
			{
2387
				printMessage(keywords[i].replace(/;;/g, ", ") + " / " + responses[i]);
2388
			}
2389
		}
2390
		else if (compare(message, commandsymbol + "clear"))
2391
		{
2392
			sys.stopEvent();
2393
			
2394
			keywords = new Array();
2395
			responses = new Array();
2396
			
2397
			printMessage("Cleared!");
2398
		}
2399
		else if (startsWith(message, commandsymbol + "addblacklist "))
2400
		{
2401
			sys.stopEvent();
2402
			if (blacklist.indexOf(message.toLowerCase().substr(14)) == -1)
2403
			{
2404
				blacklist.push(message.toLowerCase().substr(14));
2405
				printMessage(message.substr(14) + " added to blacklist.");
2406
			}
2407
			else
2408
			{
2409
				printMessage("That's already on the blacklist.");
2410
			}
2411
		}
2412
		else if (startsWith(message, commandsymbol + "removeblacklist "))
2413
		{
2414
			sys.stopEvent();
2415
			if (blacklist.indexOf(message.substr(17).toLowerCase()) >= 0)
2416
			{
2417
				blacklist.splice(blacklist.indexOf(message.substr(17).toLowerCase()), 1);
2418
				printMessage(message.substr(17) + " removed from blacklist.");
2419
			}
2420
			else
2421
			{
2422
				printMessage("That's not on the blacklist.");
2423
			}
2424
		}
2425
		else if (compare(message, commandsymbol + "viewblacklist"))
2426
		{
2427
			sys.stopEvent();
2428
			var channels = "";
2429
			
2430
			printMessage("<b><u>Blacklist</u></b>");
2431
			
2432
			channels = blacklist.join(", ");
2433
			
2434
			printMessage(channels);
2435
		}
2436
		else if (compare(message, commandsymbol + "allow"))
2437
		{
2438
			sys.stopEvent();
2439
			letOthersDefine = true;
2440
			printMessage("Others can now define phrases with ~" + client.ownName() + "define keyphrase;;response");
2441
		}
2442
		else if (compare(message, commandsymbol + "disallow"))
2443
		{
2444
			sys.stopEvent();
2445
			letOthersDefine = false;
2446
			printMessage("External defining has been disallowed.");
2447
		}
2448
		else if (compare(message, commandsymbol + "help"))
2449
		{
2450
			sys.stopEvent();
2451
			printMessage("<b><u>Help</u></b>");
2452
			printMessage("Add responses with <b>" + commandsymbol + "add keyphrase;;response</b>");
2453
			printMessage("Remove responses with <b>" + commandsymbol + "remove keyphrase;;response</b>");
2454
			printMessage("View responses with <b>" + commandsymbol + "myresponses</b>");
2455
			printMessage("Save with <b>" + commandsymbol + "save</b> and load with <b>" + + commandsymbol + "load</b>, but your things auto save/load anyway so idk why'd you want to use these but WHATEVER :)");
2456
			printMessage("Clear all with <b>" + commandsymbol + "clear</b> - <font color='red'>Can't be undone probably!</font>");
2457
			printMessage("<b>" + commandsymbol + "addblacklist channel</b>, <b>" + commandsymbol + "removeblacklist channel</b>, <b>" + commandsymbol + "viewblacklist</b> - Disables script in certain channels, e.g. Tohjo");
2458
			printMessage("Allow others to define things with <b>@" + client.ownName() + "define</b> with <b>" + commandsymbol + "allow</b> and disallow with <b>" + commandsymbol + "disallow</b>");
2459
			printMessage("If you have suggestions or find a bug, PM SongSing or whatever!");
2460
		}
2461
	},
2462
	beforeChallengeReceived: function () {
2463
		if (nochallenge === true) {
2464
			sys.stopEvent();
2465
		}
2466
	}
2467
2468
});