User:Tsurumaru Kuninaga/TsuruBot.js

if (wgCanonicalSpecialPageName == 'Chat') {

//Given 'input text':, TsuruBot will respond with 'reply text', window.autoreplies = { '^$': '∠(・∀・ )?',       '!': '☆⌒∠(°∀° )?',        '^help': 'With what?', '(hi|hello)': 'ヾ(°∀° )', '^ohayou?': 'おはよう. ',       '^おはよう?': 'おはようございます！', '^goodnight': 'おやすみ. ',       '^bye.?bye': 'ヾ(°∀° )', 'good.?bye': 'さようなら. ',       '^stupid question': 'The http://touken-ranbu.wikia.com/wiki/FAQ is right here.', '^question$': 'No.', '^can i ask a question$': '^ I think you mean \'may I ask a question\'.', '^may i ask a question$': 'Denied.', '^what is life': '(1:30)', '^bless': '(rngesus)', '^bless with holy water': '(cha) (rngesus) (cha)', '^what is heaven$': function (input, name, isAdmin) { var list = ['But what is hell?', '(crane)', '(isshinfuran)']; var rand = Math.floor(Math.random * list.length); Speak(list[rand]); return true; },       '^what is hell$': function (input, name, isAdmin) { var list = ['(1:30)', '(firegif)', '(isshinfuran)', 'LSS: Last Sword Syndrome.', 'CSS: Cold Somen Saga.']; var rand = Math.floor(Math.random * list.length); Speak(list[rand]); return true; },       '^(crane)': 'はっはは、驚いたか？', '^(odoroita ka?|odoroitaka?|驚いたか？)': '(odoroita)', '^who am i': function (input, name, isAdmin) { var list = [', a rarity-3 scrub.', ', who I picked up from the combustible bin (firegif)', '. Please cleanse youself (cha) (rngesus) (cha) .']; var rand = Math.floor(Math.random * list.length); Speak(name + list[rand]); return true; },       '^who are you': '俺は鶴ボット. (・∀・)',

//Game help //Sword husbandry '(who is|who\'?s) your (husband|husbando)': function (input, name, isAdmin) { var list = ["Mikazuki Munechika", "Ichigo Hitofuri", "Kogitsunemaru", "Ookurikara"]; var rand = Math.floor(Math.random * list.length); Speak(list[rand] + "."); return true; },       '(who is|who\'?s) my (husband|husbando)': function (input, name, isAdmin) { var list = ['Me? <3', 'Mitsutada', 'Ookurikara', 'Hasebe', '(kakaka)', 'Nn, some other guy']; if (name == 'Pandacath') list = ['Mitsutada']; if (name == 'Zettanoia') list = ['Sexual_Dark_Chocolate']; if (name == 'Dtx3D') list = ['Hasebe']; var rand = Math.floor(Math.random * list.length); if (rand == '(kakaka') {               Speak(list[rand]);            } else {Speak(list[rand] + ".");}            return true;        },        '(who is|who\'?s) my (waifu|wife)': function (input, name, isAdmin) {            var list = ['Mitsutada.', 'Mitsutada is everyone\'s waifu w'];            if (name == 'Pandacath')                list = ['Mitsutada <3'];            if (name == 'Zettanoia')                list = 'Sexual Dark Chocolate (nyan) ';            var rand = Math.floor(Math.random * list.length);            Speak(list[rand]);            return true;        },        '(who is|who\'?s) your (waifu|wife)': function (input, name, isAdmin) {            var list = ['Mitsutada.', 'Mitsutada w', 'Mitsutada is everyone\'s waifu w', 'I\'d say Mitsutada but Kuri\'ll kill me w'];            var rand = Math.floor(Math.random * list.length);            Speak(list[rand]); return true; },       //Choose '^choose': '^pick', '^pick': function (input, name, isAdmin) { var choices = input.split(' or '); var rand = Math.floor(Math.random * choices.length); Speak(choices[rand] + '.'); return true; },       'do you want to see my ship\\s?list': '^kickme', 'i\'?m kuso': '^kickme', '^killme': '^kickme', '^sinkme': '^kickme', '^chat\\s?nuke': '^kickme', '^kickme': function(input, name, isAdmin) { Kick(name); return true; },       '^sink': '^kick', '^terminate': '^kick', '^exterminate': '^kick', '^slap': '^kick', '^punch': '^kick', '^nuke': '^kick', '^rekt': '^kick', '^grate': '^kick', '^torpedo': '^kick', '^cut-in': '^kick', '^kick': function(input, name, isAdmin) { if(!isAdmin) return true; var short = {'Miia': 'Miiandering'}; if(short[input.removeTrailing('.')]) input = short[input.removeTrailing('.')]; Speak('Get rekt!'); Kick(input); return true; },       '^autokicklist': function(input, name, isAdmin) { if(isAdmin) { var str = []; var time = new Date.getTime; for(var key in window.autokick) { var time_left = (parseInt(window.autokick[key]) - time) / 60000 str.push(key + ' (' + parseInt(time_left) + ')'); }               Speak('Auto-kick registries: ' + str.join(', ')); }           return true; },       '^autokick': function(input, name, isAdmin) { if(isAdmin) { input = input.split(' '); var time = 300000; if(!isNaN(parseInt(input[0]))) time = parseInt(input.shift) * 60000; input = input.join(' '); var kickname = input.removeTrailing('.'); window.autokick[kickname] = new Date.getTime + time; Kick(kickname); }           return true; },       '^release': '^free', '^resurrect': '^free', '^free': function(input, name, isAdmin) { if(isAdmin) { delete window.autokick[input.removeTrailing('.')]; }           return true; },       '^resetcooldowns': '^resetall', '^resetall': function(input, name, isAdmin) { if(isAdmin) { window.personal_cooldowns = []; Speak('All cooldowns reset!'); }           return true; },       '^reset': function(input, name, isAdmin) { if(isAdmin) { window.personal_cooldowns[input.removeTrailing('.')] = []; Speak('Cooldowns reset for ' + input.removeTrailing('.') + '!'); }           return true; },       '^silenceleft': function(input, name, isAdmin) { if(!window.silence) window.silence = 0; Speak(parseInt((window.silence - new Date.getTime) / 60000) + ' minutes remaining.'); return true; },       '^silence': function(input, name, isAdmin) { if(isAdmin && name != 'EchoHolic') { window.silence = new Date.getTime + (parseInt(input) * 60000); }           return true; },       '^who': function (input, name, isAdmin) { var users = mainRoom.model.users.models; var rand = Math.floor(Math.random * users.length); Speak(users[rand].attributes.name + '.'); return true; },	};	window.randomreplies = [ 'No.', 'Absolutely not.', 'Never.', 'You wish.', 'Yes.', 'Definitely.', 'Absolutely.', 'Okay.', 'Maybe.', 'I dunno.', 'I can\'t tell you that right now.', 'Try asking again later.', '/me refrains from answering.', ':v', '<3' ];   window.suicides = { 'Pandacath': 'gravedigger', 'Zettanoia': 'escape', 'Miiandering': 'tsurudie', 'Dtx3D': 'DIEjobu', 'Chuusagi': 'odoroitaka', '1Epinard': 'riprip', 'Kiremoon': 'crane', 'Heshikiri Hasebe': '死ね', }	window.whitelist = ['Heshikiri Hasebe', 'Kitsuboshi', 'JustWastingTime', 'Dnite77', 'Shizen144', 'TScript', 'McDerp', 'CreamX', 'Akios', 'Marcorius', 'D Des']; window.cooldown_time = new Date.getTime; window.personal_cooldowns = []; window.players = []; window.autokick = []; window.silence = 0; NodeChatDiscussion.prototype.respondToChat = function(chat) { // If somebody logs in, it's an inline alert if(chat.attributes.isInlineAlert && chat.attributes.text.indexOf('has joined the chat.') != -1) { var name = chat.attributes.text.replace(' has joined the chat.', ''); /*	       var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: 'Hello, ' + name + '!'}); mainRoom.socket.send(chatEntry.xport); */			var time = new Date.getTime; for(var key in window.autokick) { if(key == name && window.autokick[key] > time) { Kick(name); } else if(window.autokick[key] < time) { delete window.autokick[key]; }			}	   }	    // All regular chats go here if(mainRoom.isInitialized && chat.attributes.name != wgUserName && !chat.attributes.isInlineAlert) { var text = chat.attributes.text; var name = chat.attributes.name; // Check if they're a mod or admin and put the stars var icon = ''; for(var i in this.model.users.models) { if(this.model.users.models[i].attributes.name == chat.attributes.name) { if(this.model.users.models[i].attributes.isStaff) { icon = ' '; } else if(this.model.users.models[i].attributes.isModerator) { icon = ' '; }		   		break; }   		}    		if(text.indexOf('TsuruBot')); if(icon) {this.chatUL.children.last.children('.username').html(this.chatUL.children.last.children('.username').html + icon);} if(icon && chat.attributes.text.match(/^TsuruBot,? silence left/gi) && !(chat.attributes.name == 'Miiandering' || chat.attributes.name == 'Miiandering')) window.autoreplies['silence left'].call(this, , , ''); // If silence is activated, just return here if(!window.silence) window.silence = 0; if(new Date.getTime < window.silence && !(chat.attributes.name == 'Miiandering' || chat.attributes.name == 'Miiandering')) return true; // Remove any personal cooldowns that are past 10 minutes old if(window.personal_cooldowns[name] === undefined) window.personal_cooldowns[name] = []; for(var i = 0; i < window.personal_cooldowns[chat.attributes.name].length; i++) { if(new Date.getTime - window.personal_cooldowns[name][i] > 600000) window.personal_cooldowns[name].shift; else break; }			// Suicide checks if(window.suicides[name] && text.toLowerCase.indexOf(window.suicides[name]) != -1) { Kick(name); }			// Risemiria explosion check if(name == 'Risemiria' && /explodes/.test(text)) { for(var i = 0; i < 3; i++) { var rand = Math.floor(Math.random * window.whitelist.length); Kick(window.whitelist[rand]); }			   Speak('Risemiria\'s explosion has claimed a few lives.'); }			// Pull the text apart into its pieces var regex = /^(TsuruBot),?\s?([a-zA-Z0-9ぁ-ゟ-]*)\s?(.*)/gi; var match = regex.exec(text) if(!match) return true; match.splice(0, 2); // Can only activate 3 times per 10 minutes UNLESS the user is a mod/admin if(window.personal_cooldowns[name].length < 60 || icon) { for(var keyword in window.autoreplies) { var regexp = new RegExp(keyword, 'gi'); if(regexp.test(match[0]) || regexp.test(match.join('')) || regexp.test(match.join(' '))) { while(typeof window.autoreplies[keyword] != 'function') { // If the end point is a string, we won't be finding a function and it'll turn undefined. if(typeof window.autoreplies[keyword] == 'undefined') { window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); Speak(keyword); return true; }   					       keyword = window.autoreplies[keyword]; }   	    			window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); return window.autoreplies[keyword].call(this, match[1], chat.attributes.name, icon); }				}				var rand = Math.floor(Math.random * window.randomreplies.length); Speak(window.randomreplies[rand]); window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); }		}	}	mainRoom.model.chats.bind('afteradd', $.proxy(mainRoom.viewDiscussion.respondToChat, mainRoom.viewDiscussion)); NodeChatController.prototype.onOpenPrivateRoom = function(message) { var room = new models.OpenPrivateRoom; room.mport(message.data); var users = room.get('users'); for(var i = 0; i < users.length; i++) { if(users[i] != wgUserName) { var blockedUser = this.model.blockedUsers.findByName(users[i]); if(typeof(blockedUser) != 'undefined' && blockedUser.get('name') == users[i]) { return; }   		}    	}    	if(typeof(this.chats.privates[room.get('roomId')]) == 'undefined') { this.baseOpenPrivateRoom(room, false); }   	this.chats.privates[room.get('roomId')].init; this.chats.privates.model.chats.bind('afteradd', $.proxy(this.chats.privates[room.get('roomId')].viewDiscussion.respondToChat, this.chats.privates[room.get('roomId')].viewDiscussion)); }	NodeChatController.prototype.inlineAlert = function(text) { for(var i in text.split('\n')) { this.viewDiscussion.chatUL.append('' + text.split('\n')[i] + ''); }		this.viewDiscussion.scrollToBottom; }	function toggleAway { if($('#ChatHeader .User').hasClass('away') == true) { var setStatusCommand = new models.SetStatusCommand({statusState: STATUS_STATE_PRESENT, statusMessage: ''}); mainRoom.inlineAlert('You are no longer Away.'); mainRoom.socket.send(setStatusCommand.xport); } else { var setStatusCommand = new models.SetStatusCommand({statusState: STATUS_STATE_AWAY, statusMessage: ''}); mainRoom.inlineAlert('You are now Away.'); mainRoom.socket.send(setStatusCommand.xport); }	}	NodeChatController.prototype.clearWindow = function { this.viewDiscussion.chatUL.html(''); this.inlineAlert('The window has been cleared.'); }	function active { //Returns the NodeChatController for the active window if(mainRoom.activeRoom && mainRoom.activeRoom != 'main') {return mainRoom.chats.privates[mainRoom.activeRoom];} else {return mainRoom;} }	String.prototype.removeTrailing = function(char) { //Remove extraneous characters var str = this; while(str.charAt(0) == char) {str = str.substring(1, str.length);} while(str.charAt(str.length - 1) == char) {str = str.substring(0, str.length - 1);} return str; }	function Speak(text) { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: text}); mainRoom.socket.send(chatEntry.xport); }	function Kick(name) { if(mainRoom.model.users.findByName(name) === undefined && name.split('').pop == '.') { name = name.split(''); name.pop; name = name.join(''); }	   var kickCommand = new models.KickCommand({userToKick: name}); mainRoom.socket.send(kickCommand.xport); }	$(function {		if(!importScriptURI) {function importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}}        $('#Write').append('Toggle Away StatusClear window');		$('head').append('\n.stafficon {\n\tmargin-bottom:-4px;\n\twidth:14px;\n\theight:14px;\n}\n.modicon {\n\tmargin-bottom:-3px;\n\twidth:14px;\n\theight:14px;\n}\n.UserStatsMenu {\n\tcolor:#000;\n}\n.Write [name="message"] {\n\twidth:93%;\n}\n.inline-alert span {\n\tcolor:#006CB0;\n\tcursor:pointer;\n}\n.inline-alert span:hover {\n\ttext-decoration:underline;\n}\n#pingspan {\n\tposition:absolute;\n\tz-index:5;\n\ttop:23px;\n\tmargin-left:15px;\n\tfont-size:15px;\n\tfont-weight:normal;\n\tline-height:15px;\n}\n#pings {\n\tresize:none;\n\tmargin-left:0;\n\tfont-size:12px;\n\theight:100px;\n\tdisplay:block;\n}\n#pingspan div span {\n\tfont-size:55%;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n.message.ping {\n\tcolor:red;\n}\n '); $(window).unbind('mousemove').unbind('focus').unbind('keypress'); }); } else {	$(function { var a = document.getElementsByTagName('a'); for(var i = 0; i < a.length; i++) { if(a[i].href && a[i].href.indexOf('/wiki/Special:Chat') != -1) { a[i].addEventListener('click', function(event) {event.preventDefault; OpenChatWindow;}); a[i].removeAttribute('data-canonical'); }		}		if(document.body.className.indexOf('skin-oasis') != -1) {window.chatcheck = setInterval('ChatCheck', 200);} });	function ChatCheck {		if($('.chat-join button').length != 0) {			$('.chat-join button').replaceWith('' + $('.chat-join button').html + '');			clearInterval(window.chatcheck);		}	}	function OpenChatWindow {		window.chatwindow = window.open('/wiki/Special:Chat?useskin=wikia', 'chat');		window.chatwindow.onload = function {			window.chatwindow.importScriptPage('User:' + wgUserName + '/global.js', 'c');			window.chatwindow.importScript('User:' + wgUserName + '/wikia.js');		}	} }