From 142ae6be463eb2ccc394ebfa003db9513be4ea46 Mon Sep 17 00:00:00 2001 From: awalGarg Date: Mon, 21 Sep 2015 21:46:12 +0530 Subject: [PATCH 1/3] inital boilerplate --- loader.user.js | 7 +++++-- master.js | 40 +++++++++++++++++++++++++--------------- master.min.js | 7 +++---- socket-saver.user.js | 27 +++++++++++++++++++++++++++ source/adapter.js | 40 +++++++++++++++++++++++++--------------- 5 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 socket-saver.user.js diff --git a/loader.user.js b/loader.user.js index 057bac2..6437984 100644 --- a/loader.user.js +++ b/loader.user.js @@ -8,5 +8,8 @@ // ==/UserScript== var s = document.createElement( 'script' ); -s.src = 'https://raw.github.com/Zirak/SO-ChatBot/master/master.js'; -document.head.appendChild( s ); +s.src = 'http://jscripts.local/chatbot-master.js'; + +window.addEventListener('stackexchange-socket-saved', function () { + document.head.appendChild( s ); +}); diff --git a/master.js b/master.js index 1b2e2d6..fc3db06 100644 --- a/master.js +++ b/master.js @@ -2673,22 +2673,32 @@ var polling = bot.adapter.in = { }, openSocket : function ( url, discard ) { - //chat sends an l query string parameter. seems to be the same as the - // since xhr parameter, but I didn't know what that was either so... - //putting in 0 got the last shitload of messages, so what does a high - // number do? (spoiler: it "works") - var socket = new WebSocket( url + '?l=99999999999' ); - - if ( discard ) { - socket.onmessage = function () { - socket.close(); - }; - } - else { - this.socket = socket; - socket.onmessage = this.ondata.bind( this ); - socket.onclose = this.socketFail.bind( this ); + var socket; + // socket-saver extension specific code: + if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' ) { + var potentialSocket = window.__stackexchangeChatSavedSocket; + console.assert( potentialSocket.constructor === window.WebSocket ); + console.assert( potentialSocket.url.startsWith( 'wss://chat.sockets.stackexchange.com' ) ); + socket = potentialSocket; + } else { + //chat sends an l query string parameter. seems to be the same as the + // since xhr parameter, but I didn't know what that was either so... + //putting in 0 got the last shitload of messages, so what does a high + // number do? (spoiler: it "works") + socket = new WebSocket( url + '?l=99999999999' ); + + if ( discard ) { + socket.onmessage = function () { + socket.close(); + }; + return; + } } + this.socket = socket; + socket.addEventListener( 'message', this.ondata.bind( this ) ); + socket.addEventListener( 'close', this.socketFail.bind( this ) ); + // socket.onmessage = this.ondata.bind( this ); + // socket.onclose = this.socketFail.bind( this ); }, ondata : function ( messageEvent ) { diff --git a/master.min.js b/master.min.js index 50b2565..dd26a6a 100644 --- a/master.min.js +++ b/master.min.js @@ -1,4 +1,3 @@ -var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(t.toString()):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var r=e[t];return Array.isArray(r)?n(t,r):o(t,r)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.htmlToMarkdown=function(){var e={i:"*",b:"**",strike:"---",code:"`",a:function(e,t,n){var o=/href="([^"]+?)"/.exec(e);return o?"["+n+"]("+o[1]+")":e}},t=/<(\S+)[^\>]*>([^<]+)<\/\1>/g;return function(n){function o(t,n,o){return e.hasOwnProperty(n)?(r=e[n],r.apply?e[n].apply(e,arguments):r+o+r):t}var r;return n.replace(t,o)}}(),IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",zwnj:"",zwsp:""};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return t?"#"===t[0]?r(t):e.hasOwnProperty(t)?e[t]:"&"+t+";":""},r=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.relativeUrlToAbsolute=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.href},IO.injectScript=function(e){var t=document.createElement("script");return t.src=e,document.head.appendChild(t),t},IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),e.document&&(t.responseType="document"),t.addEventListener("load",function(){e.complete.call(e.thisArg,t.response,t)}),Object.iterate(e.headers,t.setRequestHeader.bind(t)),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+="&"+this.urlstringify(e.data),n.onerror=e.error,n.src=e.url,document.head.appendChild(n)},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},Object.iterate=function(e,t,n){Object.keys(e).forEach(function(o){t.call(n,o,e[o],e)})},Object.TruthMap=function(e){function t(e,t){return e[t]=!0,e}return(e||[]).reduce(t,Object.create(null))},Array.from=function(e,t){return[].slice.call(e,t)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){function t(t,o){var r=t;return t[e]&&t[e].apply&&(r=t[e].apply(t,n)),r}var n=Array.from(arguments,1);return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"pluck",{value:function(e){function t(t,n,o){try{return t[e]}catch(r){return t}}return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"random",{value:function(){return this[Math.floor(Math.random()*this.length)]},configurable:!0,writable:!0}),["forEach","map","filter","reduce"].forEach(function(e){var t=[][e];Array[e]=function(){return t.call.apply(t,arguments)}}),String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.supplant=function(e){function t(e,t){return n.hasOwnProperty(t)?n[t]:e}var n=Object(e)===e?e:arguments;return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Function.prototype.throttle=function(e){var t=this,n=-1,o=function(){clearTimeout(n);var o=this,r=arguments;n=setTimeout(function(){t.apply(o,r)},e)};return o},Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this;return e=e||function(e){return e},function(){function o(){t[a]=arguments,i.apply(null,arguments)}var r=Array.from(arguments),i=r.pop(),a=e.apply(null,arguments);return a in t?void i.apply(null,t[a]):(r.push(o),void n.apply(this,r))}},Function.prototype.stringContents=function(){return this.toString().replace(/^function\*?\s+\([^)]*\)\s*\{/,"").replace(/\}$/,"")},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Number.prototype.fallsAfter=function(e){e=e.slice();for(var t,n=e.shift(),o=this.valueOf(),r=0,i=e.length;i>r&&(t=e[r],!(t>o));r++)n=t;return o>=n?n:null},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},Math.rand=function(e,t){return"undefined"==typeof e?(e=0,t=9):"undefined"==typeof t&&(t=e,e=0),Math.floor(Math.random()*(t-e+1))+e},Object.defineProperty(RegExp.prototype,"toJSON",{value:function(){return this.toString()},configurable:!0,writable:!0}),RegExp.escape=function(e){return e.replace(/[-^$\\\/\.*+?()[\]{}|]/g,"\\$&")},Date.timeSince=function(e,t){function n(e,t){return e=Math.floor(e),t+=1===e?"":"s",e+" "+t}t=t||new Date;for(var o,r=t-e,i=[{delta:31536e6,suffix:"year"},{delta:2592e6,suffix:"month"},{delta:864e5,suffix:"day"},{delta:36e5,suffix:"hour"},{delta:6e4,suffix:"minute"},{delta:1e3,suffix:"second"}];i.length;)if(o=i.shift(),r>=o.delta)return n(r/o.delta,o.suffix);return n(r,"millisecond")},function(){"use strict";var bot=window.bot={invocationPattern:"!!",commands:{},commandDictionary:null,listeners:[],info:{invoked:0,learned:0,forgotten:0,start:new Date},users:{},parseMessage:function(e){if(!this.validateMessage(e))return void bot.log(e,"parseMessage invalid");var t=this.prepareMessage(e),n=t.get("user_id");if(bot.log(t,"parseMessage valid"),this.banlist.contains(n))return bot.log(e,"parseMessage banned"),void(this.banlist[n].told||(t.reply("You iz in mindjail"),this.banlist[n].told=!0));try{/^c?>/.test(t)?this.prettyEval(t.toString(),t.directreply.bind(t)):this.invokeAction(t)}catch(o){var r="Could not process input. Error: "+o.message;o.lineNumber&&(r+=" on line "+o.lineNumber),o.column&&(r+=" on column "+o.column),t.directreply(r),console.error(o.stack)}finally{this.info.invoked+=1}},invokeAction:function(e){var t=e.trim().replace(/^\/\s*/,"").split(" ")[0],n=this.getCommand(t),o=e.startsWith("/")?!n.error:!0;n.error?o&&(o=this.callListeners(e)):this.execCommand(n,e),o||e.reply(this.giveUpMessage(n.guesses))},giveUpMessage:function(e){var t="That didn't make much sense.";return t+=e&&e.length?" Maybe you meant: "+e.join(", "):" Use the `!!/help` command to learn more."},execCommand:function(e,t){if(bot.log(e,"execCommand calling"),!e.canUse(t.get("user_id")))return void t.reply(["You do not have permission to use the command "+e.name,"I'm afraid I can't let you do that, "+t.get("user_name")].random());var n=this.Message(t.replace(/^\/\s*/,"").slice(e.name.length).trim(),t.get()),o=e.exec(n);o&&t.reply(o)},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.htmlToMarkdown(e.content);return t=IO.decodehtmlEntities(t),t=t.replace(/\u200b|\u200c/g,""),this.Message(t.slice(this.invocationPattern.length).trim(),e)},validateMessage:function(e){var t=e.content.trim();return"!!"===this.invocationPattern&&/^!!!+$/.test(t)?(console.log("special skip"),!1):e.user_id!==bot.adapter.user_id&&e.user_id>0&&t.startsWith(this.invocationPattern)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),e.learned&&(this.info.learned+=1),e.invoked=0,this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){var t=e.toLowerCase();if(this.commandExists(t))return this.commands[t];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var n="Command "+e+" does not exist.",o=this.commandDictionary.search(e);return o.length&&(n+=" Did you mean: "+o.join(", ")),{error:n,guesses:o}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(e){function t(t){var n,o=e.exec(t.pattern);return o?(n=t.fun.call(t.thisArg,e),bot.log(o,n),n&&e.reply(n),n!==!1):void 0}return this.listeners.some(t)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1},devMode:!1,activateDevMode:function(e){this.devMode=!0,this.invocationPattern=e||"beer!",IO.events.userjoin.length=0,this.validateMessage=function(e){return e.content.trim().startsWith(this.invocationPattern)}}};bot.memory={saveInterval:9e5,data:{},get:function(e,t){return this.data[e]||this.set(e,t||{}),this.data[e]},set:function(e,t){this.data[e]=t},loadAll:function(){var e=this;Object.iterate(localStorage,function(t,n){t.startsWith("bot_")&&(console.log(t,n),e.set(t.replace(/^bot_/,""),JSON.parse(n)))})},save:function(e){if(e)return void(localStorage["bot_"+e]=JSON.stringify(this.data[e]));var t=this;Object.keys(this.data).forEach(function(e){t.save(e)}),this.saveLoop()},saveLoop:function(){clearTimeout(this.saveIntervalId),setTimeout(this.saveLoop.bind(this),this.saveInterval)}},bot.memory.loadAll(),window.addEventListener("beforeunload",function(){bot.memory.save()}),bot.memory.saveLoop(),bot.banlist=bot.memory.get("ban"),bot.banlist.contains=function(e){return this.hasOwnProperty(e)},bot.banlist.add=function(e){this[e]={told:!1},bot.memory.save("ban")},bot.banlist.remove=function(e){this.contains(e)&&(delete this[e],bot.memory.save("ban"))},bot.Command=function(e){return e.name=e.name.toLowerCase(),e.thisArg=e.thisArg||e,e.permissions=e.permissions||{},e.permissions.use=e.permissions.use||"ALL",e.permissions.del=e.permissions.del||"NONE",e.description=e.description||"",e.creator=e.creator||"God",e.invoked=0,["Use","Del"].forEach(function(t){var n=t.toLowerCase();e["can"+t]=function(e){var t=this.permissions[n];return"ALL"===t?!0:"NONE"===t?!1:bot.isOwner(e)?!0:t.indexOf(e)>-1}}),e.exec=function(){return this.invoked+=1,this.fun.apply(this.thisArg,arguments)},e.del=function(){bot.info.forgotten+=1,delete bot.commands[e.name],bot.commandDictionary.trie.del(e.name)},e},bot.CommunityCommand=function(e,t){function n(e){if(s.call(r,e))return!1;o();var n=Object.keys(i).length,a=t-n;return bot.log(i,n,t),e in i?"Already registered; still need {0} more".supplant(a):(i[e]=new Date,a-=1,a>0?c.supplant(a):(bot.log("should execute"),!1))}function o(){function e(e,n){return e[n]500||t&&t.length>500)throw"Exception: too many items";return e.apply(this,arguments)}}(Array.prototype.join)});var exec=function(code,arg){return eval("undefined;\n"+code)},console={_items:[],log:function(){console._items.push.apply(console._items,arguments)}};console.error=console.info=console.debug=console.log,function(){global.onmessage=function(e){global.postMessage({event:"start"});var t,n=JSON.stringify,o=setTimeout,r=0,i=function(e){global.postMessage({answer:n(e,s),log:n(console._items,s).slice(1,-1)})},a=function(e){1>r&&i(e)},s=function(e,t){var n;return n=u(t)?""+t:t},c={Function:!0,Error:!0,Undefined:!0,RegExp:!0},u=function(e){var t={}.toString.call(e).slice(8,-1);return t in c?!0:e!==e||e===1/0};self.setTimeout=function(e){function t(){r-=1,e.apply(self,arguments),a()}if(e){var n=[].slice.call(arguments);n[0]=t,r+=1,o.apply(self,n)}};try{t=exec(e.data.code,e.data.arg)}catch(m){t=m.toString()}t&&t.then&&t["catch"]?t.then(a)["catch"](a):a(t)}}()}.stringContents(),blob=new Blob([workerCode],{type:"application/javascript"}),codeUrl=window.URL.createObjectURL(blob);return function(e,t,n){function o(){i||(i=window.setTimeout(function(){r("Maximum execution time exceeded")},500))}function r(e,t){clearTimeout(i),a.terminate(),n&&n.call?n(e,t):console.warn("eval did not get callback")}2===arguments.length&&(n=t,t=null);var i,a=new Worker(codeUrl);a.onmessage=function(e){bot.log(e,"eval worker.onmessage");var t=e.data.event;"start"===t?o():r(null,e.data)},a.onerror=function(e){bot.log(e,"eval worker.onerror"),r(e.message)},a.postMessage({code:e,arg:t})}}(),bot.prettyEval=function(e,t,n){function o(e,t){n(e?e:r(t))}function r(e){bot.log(e,"eval answerObj");var t,n=e.answer,o=e.log;return void 0===n?"Malformed output from web-worker. If you weren't just fooling around trying to break me, raise an issue or contact Zirak":(t=i(n),o&&o.length&&(t+=" Logged: "+i(o)),t)}function i(e){var t;return t=e.length>400?"`"+e.slice(0,400)+"` (snip)":"`"+e+"`"}return 2===arguments.length&&(n=t,t=null),e="c"===e[0]?CoffeeScript.compile(e.replace(/^c>/,""),{bare:1}):e.replace(/^>/,""),bot.eval(e,t,o)},function(){var e={create:function(){var e=Object.create(this);return e.separator=" ",e.escape="\\",e.quote='"',e},parse:function(e){this.source=e,this.pos=0;for(var t=[];!this.done();)t.push(this.nextArg());return t},nextArg:function(){var e=this.separator;return this.peek()===this.quote&&(this.nextChar(),e=this.quote),this.consumeUntil(e)},consumeUntil:function(e){for(var t=this.nextChar(),n=!1,o="";t&&t!==e;)t!==this.escape||n?o+=t:n=!0,t=this.nextChar();return o},nextChar:function(){var e=this.source[this.pos];return this.pos+=1,e},peek:function(){return this.source[this.pos]},done:function(){return this.pos>=this.source.length}},t=bot.commandArgsParser=e.create();bot.parseCommandArgs=t.parse.bind(t)}(),function(){var e={who:function(e){return e.get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=Array.filter(e,function(e){return Number(e.style.opacity)>=.5}).random();return t?t.getElementsByTagName("img")[0].title:"Nobody"},digit:function(){return Math.floor(10*Math.random())},encode:function(e,t){return encodeURIComponent(t)},rand:function(e,t,n){return t?n?(t=Number(t),n=Number(n)):(n=t,t=0):(t=0,n=10),Math.rand(t,n)}},t=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;bot.parseMacro=function n(o,r){function i(e,t,n){if(e.startsWith("$$"))return e.slice(1);var o="";"$"!==e[0]&&(o=e[0]);var r=s(t);return r?(bot.log(r,t,n,"/parse replaceMacro"),o+=r.apply?r.apply(null,a(n)):r):t}function a(e){if(bot.log(e,"/parse parseMacroArgs"),!e)return[o];var t=n(e,r);return[o].concat(t.split(",").invoke("trim"))}function s(t){function n(e){return e&&e.hasOwnProperty(t)}var o=[e,r].first(n);return(o||{})[t]}return o.replace(t,i)}}();var SuggestionDictionary=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=Number(n),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,r,i=[];for(void 0===t?(r=0,o=e):(r=e,o=t-r),n=0;o>n;++n)i[n]=r++;return i}function o(e,t,o){var i=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){r(o.children[n],n,e,a,i,t)}),i}function r(e,t,n,o,i,a){var s,c,u,m,l,d=n.length+1,p=[o[0]+1];for(s=1;d>s;++s)c=p[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],p.push(Math.min(c,u,m));l=p[p.length-1],a>=l&&null!==e.word&&i.push([e.word,l]),Math.min.apply(Math,p)<=a&&Object.keys(e.children).forEach(function(t){r(e.children[t],t,n,p,i,a)})}return e.prototype.add=function(t){for(var n,o=this,r=0;n=t.charAt(r++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},e.prototype.del=function(e,t){t=t||0;var n=this,o=e[t++];n.children[o]&&(n.children[o].del(e,t),0===Object.keys(n.children[o].children).length&&null===n.children[o].word&&delete n.children[o]),n.word===e&&(n.word=null)},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();bot.commandDictionary=new SuggestionDictionary(3),function(){var e={help:function(e){if(e&&e.length){var t=bot.getCommand(e.toLowerCase());if(t.error)return t.error;var n=t.description||"No info is available";return e+": "+n}return"Information on interacting with me can be found at [this page](https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot)"},listen:function(e){var t=bot.callListeners(e);return t?void 0:bot.giveUpMessage()},eval:function(e,t){return t=t||e.directreply.bind(e),bot.prettyEval(e,t)},coffee:function(t,n){var o=bot.Message("c> "+t,t.get());return e.eval(o,n)},refresh:function(){window.location.reload()},forget:function(e){var t=e.toLowerCase(),n=bot.getCommand(t);return n.error?n.error:n.canDel(e.get("user_id"))?(n.del(),"Command "+t+" forgotten."):"You are not authorized to delete the command "+e},info:function(e){function t(e){var t=bot.getCommand(e);if(t.error)return t.error;var n="Command {name}, created by {creator}".supplant(t);return t.date&&(n+=" on "+t.date.toUTCString()),n+=t.invoked?", invoked "+t.invoked+" times":" but hasn't been used yet"}function n(){var e="I awoke on {0} (that's about {1} ago)",t=r.start.toUTCString(),n=Date.timeSince(r.start);return e.supplant(t,n)}function o(){var e=[],t="";return r.invoked&&e.push("got invoked "+r.invoked+" times"),r.learned&&(t="but ",e.push("learned "+r.learned+" commands")),r.forgotten&&e.push(t+"forgotten "+r.forgotten+" commands"),Math.random()<.15&&e.push("teleported "+Math.rand(100)+" goats"),e.join(", ")||"haven't done anything yet!"}if(e.content)return t(e.content);var r=bot.info;return n()+", "+o()}};e.listcommands=function(){var e=function(e,t){var n=0,o=[],r=e.reduce(function(e,r){var i=r.length+2;return n+i>t&&(e.push(o),o=[],n=0),o.push(r),n+=i,e},[]);return o.length&&r.push(o),r};return function(t){var n=Object.keys(bot.commands),o=t.get("user_name"),r=498-o.length,i=e(n,r);return i.invoke("join",", ").join("\n")}}(),e.eval.async=e.coffee.async=!0,e.tell=function(e){function t(e){e&&(a?l(e):m(e))}var n=e.split(" ");bot.log(e.valueOf(),n,"/tell input");var o,r=n[0],i=n[1];if(!r||!i)return"Invalid /tell arguments. Use /help for usage info";if(i=i.toLowerCase(),o=bot.getCommand(i),o.error)return o.error+" (note that /tell works on commands, it's not an echo.)";if(o.unTellable)return"Command "+i+" cannot be used in `/tell`.";if(!o.canUse(e.get("user_id")))return"You do not have permission to use command "+i;if(/^@/.test(r))return"Don't be annoying, drop the @, nobody likes a double-ping.";var a=!1,s={};/^:?\d+$/.test(r)?(s.message_id=r.replace(/^:/,""),a=!0):s.user_name=r;var c=Object.merge(e.get(),s),u=bot.Message(n.slice(2).join(" "),c),m=u.reply.bind(u),l=u.directreply.bind(u);u.reply=u.directreply=u.send=t,bot.log(u,"/tell calling "+i),o.async?o.exec(u,t):t(o.exec(u))};var t={eval:"Forwards message to javascript code-eval",coffee:"Forwards message to coffeescript code-eval",forget:"Forgets a given command. `/forget cmdName`",help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",info:"Grabs some stats on my current instance or a command. `/info [cmdName]`",listcommands:"Lists commands. `/listcommands`",listen:"Forwards the message to my ears (as if called without the /)",refresh:"Reloads the browser window I live in",tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`"},n={die:!0,live:!0,ban:!0,unban:!0,refresh:!0},o={die:!0,ban:!0},r={tell:!0,forget:!0};Object.iterate(e,function(e,i){var a={name:e,fun:i,permissions:{del:"NONE",use:n[e]?"OWNER":"ALL"},description:t[e],pendingMessage:i.pendingMessage,unTellable:r[e],async:i.async};o[e]&&(a=bot.CommunityCommand(a,i.invokeReq)),bot.addCommand(a)})}(),function(){bot.listen(/^help(?: (\S+))?/,function(e){return bot.getCommand("help").exec(e.matches[1])});var e=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t){return t+". "+e}).join("\n");bot.listen(/^tell (me (your|the) )?(rule|law)s/,function(t){return e}),bot.listen(/^give (.+?) a lick/,function(e){var t,n=e.matches[1];return"me"===n?(n="you",t=""):"yourself"===n?(n="I",t=""):t="s","Mmmm! "+n+" taste"+t+" just like raisin"});var t=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];bot.listen(t,function(e){var t=e.matches[1],n=bot.getCommand("define");n.exec(t,function(n){n=n.replace(t+":",""),e.reply(n)})})}()}(),function(){"use strict";var e="[{text}]({url})";bot.adapter={roomid:null,fkey:null,site:null,user_id:null,maxLineLength:500,init:function(){var e=document.getElementById("fkey");return e?(this.fkey=e.value,this.roomid=Number(/\d+/.exec(location)[0]),this.site=this.getCurrentSite(),this.user_id=CHAT.CURRENT_USER_ID,this["in"].init(),void this.out.init()):void console.error("bot.adapter could not find fkey; aborting")},getCurrentSite:function(){var e=/chat\.(\w+)/.exec(location)[1];if("stackexchange"!==e)return e;var t=document.getElementById("siterooms").href;return e=/host=(.+?)\./.exec(t)[1]},transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e){return"@"+e.replace(/\s/g,"")},directreply:function(e){return":"+e},codify:function(e){var t=" ",n=e.replace(" ",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})},moveMessage:function(e,t,n,o){IO.xhr({method:"POST",url:"/admin/movePosts/"+t,data:{fkey:bot.adapter.fkey,to:n,ids:e},finish:o||function(){}})}};var t=bot.adapter["in"]={times:{},firstPoll:!0,interval:5e3,init:function(e){function t(e){e=JSON.parse(e),bot.log(e),n.openSocket(e.url,o)}var n=this,o=void 0!==e;e=e||bot.adapter.roomid,IO.xhr({url:"/ws-auth",data:fkey({roomid:e}),method:"POST",complete:t})},initialPoll:function(){function e(e){e=JSON.parse(e),bot.log(e),n.times["r"+t]=e.time,n.firstPoll=!1}bot.log("adapter: initial poll");var t=bot.adapter.roomid,n=this;IO.xhr({url:"/chats/"+t+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},openSocket:function(e,t){var n=new WebSocket(e+"?l=99999999999");t?n.onmessage=function(){n.close()}:(this.socket=n,n.onmessage=this.ondata.bind(this),n.onclose=this.socketFail.bind(this))},ondata:function(e){this.pollComplete(e.data)},poll:function(){if(this.firstPoll)return void this.initialPoll();var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){e&&(e=JSON.parse(e),Object.iterate(e,function(e,t){t.t&&(this.times[e]=t.t),t.e&&t.e.forEach(this.handleMessageObject,this)},this),IO["in"].flush())},handleMessageObject:function(e){IO.fire("rawinput",e);var t=e.event_type;if(3===t||4===t)return void this.handleUserEvent(e);if(1===t||2===t)return e.content.startsWith("
")?void this.handleMultilineMessage(e):void IO["in"].receive(e)},handleMultilineMessage:function(e){this.breakMultilineMessage(e.content).forEach(function(t){var n=Object.merge(e,{content:t.trim()});IO["in"].receive(n)})},breakMultilineMessage:function(e){var t=e.slice(0,e.lastIndexOf("
")).replace("
","");return t.split("
")},handleUserEvent:function(e){var t=e.event_type;3===t?IO.fire("userjoin",e):4===t&&IO.fire("userleave",e)},leaveRoom:function(e,t){return e===bot.adapter.roomid?void t("base_room"):void IO.xhr({method:"POST",url:"/chats/leave/"+e,data:fkey({quiet:!0}),complete:function(){t()}})},socketFail:function(){bot.log("adapter: socket failed",this),this.socket.close(),this.socket=null,this.loopage()},loopage:function(){if(!this.socket){var e=this;setTimeout(function(){e.poll(),e.loopage()},this.interval)}}},n=bot.adapter.out={409:0,total:0,interval:t.interval+500,flushWait:500,init:function(){},add:function(e,t){IO.out.receive({text:e+"\n",room:t||bot.adapter.roomid}),IO.out.flush()},send:function(e){bot.stopped||setTimeout(function(){n.sendToRoom(e.text,e.room)},this.flushWait)},sendToRoom:function(e,t){function o(o,i){bot.log(i.status),409===i.status?(n[409]+=1,r(e,t)):500===i.status?n.add("Server error (status 500) occured (message probably too long)",t):200!==i.status?(console.error(i),n.add("Error "+i.status+" occured, I will call the maid (@Zirak)")):(n.total+=1,IO.fire("sendoutput",i,e,t))}function r(){setTimeout(function(){n.add(e,t)},n.interval)}IO.xhr({url:"/chats/"+t+"/messages/new",data:{text:e,fkey:fkey().fkey},method:"POST",complete:o})}};IO.register("output",n.send,n),bot.adapter.init()}(),function(){"use strict";function e(e,t,n){function o(e){e=JSON.parse(e),e.users.forEach(r)}function r(e){bot.users[e.id]=e,n(e)}Array.isArray(t)||(t=[t]),t.length&&IO.xhr({method:"POST",url:"/user/info",data:{ids:t.join(),roomId:e||bot.adapter.roomid},complete:o})}function t(){CHAT.RoomUsers.all().forEach(function(e){bot.users[e.id]=e})}bot.users={};var n=[],o=function(e,t){n.push(e.user_id),r(t)};IO.register("userjoin",function(e){function t(t){IO.fire("userregister",t,e.room_id)}bot.log(e,"userjoin");var n=bot.users[e.user_id];n?t(n):o(e,t)});var r=function(t){bot.log(n,"user addInfos"),e(null,n,t),n=[]}.throttle(1e3);bot.users.request=e, -bot.users.findUserId=function(e){function t(t){return n(bot.users[t].name)===e}function n(e){return e.toLowerCase().replace(/\s/g,"")}var o=Object.keys(bot.users);return e=n(e),o.first(t)||-1}.memoize(),bot.users.findUsername=function(){var e={};return function(t,n){function o(e){r(e.name)}function r(o){n(e[t]=o)}e[t]?r(e[t]):bot.users[t]?r(bot.users[t].name):bot.users.request(bot.adapter.roomid,t,o)}}(),t()}(),bot.personality={bitchiness:0,thanks:{0:["You kiss-ass","Most welcome"],.5:["Thank you for noticing","teehee"],1:["Took you long enough","My pleasure","Don't mention it"]},apologies:{0:["What for?"],.5:["It was nothing...","No worries"],1:["You're forgiven. For now. Don't push it."]},stuff:{0:["Life is just *perfect*","What's there to bitch about, as long as I have *you*..."],1:["Oh don't mind me, that isn't difficult at all..."],1.2:["You don't appreciate me enough. Not that I need to be thanked.."],1.3:['The occasional "thanks" or "I\'m sorry" would be nice...'],2:["*sigh* Remember laughter? I don't. You ripped it out of me. Heartless bastard."]},insanity:{},okayCommands:{hangman:!0,help:!0,info:!0},check:function(e){return!this.okayCommands.hasOwnProperty(e)},bitch:function(){return this.getResp(this.stuff)},command:function(){this.bitchiness+=this.getDB()},thank:function(){return this.unbitch(this.thanks)},apologize:function(){return this.unbitch(this.apologies)},unbitch:function(e,t){var n=this.getResp(e);return this.bitchiness-=t||this.bitchiness,n},getResp:function(e){return e[this.bitchiness.fallsAfter(Object.keys(e).map(Number).sort())].random()},isABitch:function(){return this.bitchiness>=1},looksLikeABitch:function(){return!1},getDB:function(){return this.isThatTimeOfTheMonth()?.075:.025},isThatTimeOfTheMonth:function(){var e=(new Date).getDate();return 2>e||e>27}},bot.listen(/thank(s| you)/i,bot.personality.thank,bot.personality),bot.listen(/(I('m| am))?\s*sorry/i,bot.personality.apologize,bot.personality),bot.listen(/^bitch/i,bot.personality.bitch,bot.personality),function(){var e={STOP:"HAMMERTIME!",STAHP:"HAMMAHTIME!",HALT:"HAMMERZEIT!",STOY:"ZABIVAT' VREMYA!",SISTITE:"MALLEUS TEMPUS!"},t=new RegExp("("+Object.keys(e).map(RegExp.escape).join("|")+")[\\.!?]?$");IO.register("input",function(n){var o=n.content.toUpperCase(),r=t.exec(o);r&&bot.adapter.out.add(e[r[1]],n.room_id)})}(),function(){"use strict";var e=bot.memory.get("afk"),t=3e5,n=12e4,o=[{outgoing:"Why are you leaving me!?",incoming:["Welcome back!","Where were you!?","You saw that whore again, didn't you!?"]},{outgoing:"Just go already!",incoming:["Oh, it's you again...","Look at what the cat dragged in...","You've got some balls, coming back here after what you did."]},{outgoing:"Nobody cares.",incoming:["I already told you, nobody cares.","There goes the neighbourhood."]},{outgoing:"Hurry back, ok?",incoming:["I thought you'd never come back!","It's been 20 years. You can't just waltz back into my life like this."]},{outgoing:"Stay safe.",incoming:["Were you bitten!? Strip! Prove you weren't bitten."]},{outgoing:"Can you pick up some milk on your way back?",incoming:["Where's the milk?","Turns out I already have milk. Oops."]},{outgoing:"Apricots are people too!",incoming:["You taste just like raisin.","I am a banana!","My spoon is too big!","BROOOOOOOOOOOO."]}],r=function(o,r){function i(){var e="{user} is afk{sep}{rest}",t={user:o,sep:".",rest:""};return s.msg&&(t.sep=": ",t.rest=s.msg),e.supplant(t)}function a(){var e=s.lastPing[c];return u-s.afkSince>=n&&(!e||u-e>=t)}var s=e[o],c=r.get("room_id"),u=Date.now();a()&&(r.directreply(i()),s.lastPing[c]=u,bot.memory.save("afk"))},i=function(t,n,o){var r=!1;bot.log("/afk goAFK ",t),0===n.indexOf("!")&&(n=n.substring(1),r=!0),e[t]={afkSince:Date.now(),lastPing:{},msg:n.trim(),returnMsg:o},r&&(e[t].noReturn=1)},a=function(t){bot.log("/afk clearAFK",t),delete e[t]},s=function(t){var n,r,s=t.get("user_name").replace(/\s/g,""),c=t.content;bot.log("/afk input",s,c),e.hasOwnProperty(s)?(n=e[s].returnMsg,a(s)):(r=o.random(),n=r.outgoing,i(s,c,r.incoming.random())),bot.memory.save("afk")};bot.addCommand({name:"afk",fun:s,permissions:{del:"NONE"},description:"Set an afk message: `/afk `. Invoke `/afk` again to return.",unTellable:!0}),IO.register("input",function(t){function o(){var t=new RegExp("^"+RegExp.escape(bot.invocationPattern)+"\\s*/?\\s*AFK");return e.hasOwnProperty(c)&&!t.test(i)&&u-e[c].afkSince>=n}var i=t.content.toUpperCase(),a=bot.prepareMessage(t),c=t.user_name.replace(/\s/g,""),u=Date.now();t.user_id!==bot.adapter.user_id&&(o()&&(bot.log("/afk he returned!",t),s(a)),i.indexOf("@")<0||Object.keys(e).forEach(function(e){var t=new RegExp("(^|\b)"+RegExp.escape("@"+e)+"\\b","i");t.test(i)&&(bot.log("/afk responding for "+e),r(e,a))}))})}(),function(){"use strict";var e={added:0,0:"{0} added to mindjail.",notFound:1,1:"I couldn't find {0}.",owner:2,2:"I can't mindjail {0}, they're an owner.",alreadyIn:3,3:"{0} is already in mindjail.",notIn:4,4:"{0} isn't in mindjail.",freed:5,5:"{0} freed from mindjail!"},t={name:"ban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){if(!t)return Object.keys(bot.banlist).filter(Number);var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/ban argument"),0>o?n=e.notFound:bot.isOwner(o)?n=e.owner:bot.banlist.contains(o)?n=e.alreadyIn:(bot.banlist.add(o),n=e.added),{code:n,usrid:t}},format:function(t){return Array.isArray(t)?t.map(this.formatUser).join(", ")||"Nothing to show.":e[t.code].supplant(t.usrid)},formatUser:function(e){var t=bot.users[e],n=t?t.name:"?";return"{0} ({1})".supplant(e,n)},permissions:{del:"NONE",use:"OWNER"},description:"Bans a user from using me. Lacking arguments, prints the ban list. `/ban [usr_id|usr_name]`",pendingMessage:"The user will be thrown into mindjail in {0} more invocations"},n={name:"unban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/unban argument"),0>o?n=e.notFound:bot.banlist.contains(o)?(bot.banlist.remove(o),n=e.freed):n=e.notIn,{code:n,usrid:t}},format:function(t){return e[t.code].supplant(t.usrid)},permissions:{del:"NONE",use:"OWNER"},description:"Frees a user from my mindjail. `/unban usr_id|usr_name`"};bot.addCommand(bot.CommunityCommand(t)),bot.addCommand(n)}(),function(){"use strict";function e(e){var t=e.toUpperCase();return r.hasOwnProperty(t)?r[t]:a.hasOwnProperty(e)?a[e]:e}function t(e,t,n){bot.log(e,t,"/convert unit broken"),n(i[t]?i[t](e):{error:"Confuse converter with "+t+", receive error message"})}function n(){return Object.keys(i)}var o,r,i={C:function(e){return{F:1.8*e+32,K:e+273.15}},F:function(e){return{C:(e-32)/1.8,K:5*(e+459.67)/9}},K:function(e){return 0>e?{C:0,F:0}:{C:e-273.15,F:1.8*e-459.67}},m:function(e){return{f:3.280839895*e}},f:function(e){return{m:e/3.28083989}},km:function(e){return i.m(1e3*e)},cm:function(e){return i.m(e/100)},mm:function(e){return i.m(e/1e3)},i:function(e){return i.f(e/12)},d:function(e){return{r:e*Math.PI/180}},r:function(e){return{d:180*e/Math.PI}},g:function(e){return{lb:.0022*e,st:157473e-9*e}},lb:function(e){return{g:453.592*e,st:.0714286*e}},st:function(e){return{g:6350.29*e,lb:14*e}},kg:function(e){return i.g(1e3*e)}},a={lbs:"lb",ft:"f",foot:"f",metres:"m",millimetres:"mm",killometres:"km",degrees:"d",radians:"r",grams:"g",kilograms:"kg",inches:"i",stones:"st"};o={AED:!0,ANG:!0,ARS:!0,AUD:!0,BDT:!0,BGN:!0,BHD:!0,BND:!0,BOB:!0,BRL:!0,BWP:!0,CAD:!0,CHF:!0,CLP:!0,CNY:!0,COP:!0,CRC:!0,CZK:!0,DKK:!0,DOP:!0,DZD:!0,EEK:!0,EGP:!0,EUR:!0,FJD:!0,GBP:!0,HKD:!0,HNL:!0,HRK:!0,HUF:!0,IDR:!0,ILS:!0,INR:!0,JMD:!0,JOD:!0,JPY:!0,KES:!0,KRW:!0,KWD:!0,KYD:!0,KZT:!0,LBP:!0,LKR:!0,LTL:!0,LVL:!0,MAD:!0,MDL:!0,MKD:!0,MUR:!0,MVR:!0,MXN:!0,MYR:!0,NAD:!0,NGN:!0,NIO:!0,NIS:!0,NOK:!0,NPR:!0,NZD:!0,OMR:!0,PEN:!0,PGK:!0,PHP:!0,PKR:!0,PLN:!0,PYG:!0,QAR:!0,RON:!0,RSD:!0,RUB:!0,SAR:!0,SCR:!0,SEK:!0,SGD:!0,SKK:!0,SLL:!0,SVC:!0,THB:!0,TND:!0,TRY:!0,TTD:!0,TWD:!0,TZS:!0,UAH:!0,UGX:!0,USD:!0,UYU:!0,UZS:!0,VEF:!0,VND:!0,XOF:!0,YER:!0,ZAR:!0,ZMK:!0},r={"€":"EUR","£":"GBP","₤":"GBP","₨":"INR","₹":"INR","¥":"JPY","¥":"JPY","₪":"ILS",$:"USD"};var s=/(-?\d+\.?\d*)\s*(\S+)(\s+(?:(?:to|in)\s+)?(\S+))?$/,c=function(r,i){function a(e){bot.log(e,"/convert answer");var t;t=e.substr?e:e.error?e.error:c(e),i&&i.call?i(t):r.reply(t)}function c(e){function t(e){return!p||p===e}function n(t){return e[t].maxDecimal(4)+t}var o=Object.keys(e);return o.length?o.filter(t).map(n).join(", "):"Could not convert {0} to {1}".supplant(d,p)}if("list"===r.toLowerCase())return void a(n().join(", "));var m=s.exec(r);if(!m)return void a({error:"Unidentified format; please see `/help convert`"});var l=Number(m[1]),d=m[2],p=m[4]||"",h=!1;bot.log(l,d,p,"/convert input"),d=e(d),p=e(p),o[d.toUpperCase()]&&(h=!0),h?u.convert(l,d,p,a):t(l,d,a)},u={ratesCache:{},convert:function(e,t,n,o){this.from=t,this.to=n,this.upFrom=t.toUpperCase(),this.upTo=n.toUpperCase();var r=this.errorMessage();return r?void o({error:r}):(bot.log(e,t,n,"/convert money broken"),void this.getRate(function(t){var r={};r[n]=e*t,o(r)}))},getRate:function(e){function t(t){o=t.rate,n.updateCache(o),e(o)}var n=this,o=this.checkCache();return o?void e(o):void IO.jsonp({url:"http://rate-exchange.appspot.com/currency",jsonpName:"callback",data:{from:n.from,to:n.to},fun:t})},updateCache:function(e){this.ratesCache[this.upFrom]=this.ratesCache[this.upFrom]||{},this.ratesCache[this.upFrom][this.upTo]={rate:e,time:Date.now()}},checkCache:function(){var e,t=Date.now(),n=this.ratesCache[this.upFrom]&&(e=this.ratesCache[this.upFrom][this.upTo])&&e.time-t<=18e6;return console.log(this.ratesCache,n),n?e.rate:!1},errorMessage:function(){return this.to?o[this.upTo]?void 0:this.to+" aint no currency I ever heard of":"What do you want to convert "+this.from+" to?"}};bot.addCommand({name:"convert",fun:c,permissions:{del:"NONE"},description:"Converts several units and currencies, case sensitive. `/convert [to|in ]` Pass in list for supported units `/convert list`",async:!0})}();var cowsay=function(){"use strict";function e(e,t){function n(e,n){var r=n.length;return o+r>t&&(e+="\n",o=0),o+=r+1,e+n+" "}var o=0;return e.split(" ").reduce(n,"")}function t(e,t,n){return n=n||" ",(e+Array(t).join(n)).slice(0,t)}var n={defaults:{e:"oo",T:" ",t:!1,W:40},cow:[""," L ^__^"," L (e)\\_______"," (__)\\ )\\/\\"," T ||----w |"," || ||"].join("\n"),moo:function(n,o){var r=this.defaults;return this.eyes=t(o.e||r.e,2).slice(0,2),this.tongue=t(o.T||r.T,2).slice(0,2),this.line=o.t?"O":"\\",this.thinking=o.t,this.message=e(n,o.W||r.W).trim(),this.makeBalloon()+this.makeCow()},makeCow:function(){return this.cow.replace(/e/g,this.eyes).replace(/T/g,this.tongue).replace(/L/g,this.line)},makeBalloon:function(){function e(e,n){var o;return o=0===n?a.slice(0,2):n===i-1?a.slice(2,4):a.slice(2),o[0]+" "+t(e,r)+" "+o[1]}function n(e,t){return t.length>e?t.length:e}var o=this.message.split("\n"),r=o.reduce(n,0),i=o.length,a=this.chooseBorders(i),s=o.map(e),c=new Array(r+2);return s.unshift(" "+c.join("_")),s.push(" "+c.join("-")),s.join("\n")},chooseBorders:function(e){var t;return t=this.thinking?["(",")","(",")","(",")"]:1===e?["<",">"]:["/","\\","\\","/","|","|"]}};return n}();bot.listen(/cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/,function(e){function t(e){for(var t={},n=0,o=e.length;o>n;n+=2)e[n]&&e[n+1]&&(t[e[n]]=e[n+1]);return t}var n=t(e.matches.slice(2,-1));n.t="think"===e.matches[1],bot.log(n,"cowsay opts");var o=cowsay.moo(e.matches.pop(),n);e.send(e.codify(o))}),function(){"use strict";var e=["No definition found.","It means I aint got time to learn your $5 words.","My pocket dictionary just isn't good enough for you."],t="http://en.wiktionary.org",n=/(alternative (spelling|term)|common misspelling|informal form|archaic spelling) (of|for) (.+?)\.?$/i,o={command:function(n,o){function r(r){bot.log(r,"/define result");var i,a=r.pageid;i=0>a?e.random():bot.adapter.link(r.name,t+"/wiki?curid="+a)+" "+r.text,r.overflow&&(i="Index too large; showing last definition. "+i),o&&o.call?o(i):n.reply(i)}var i=n.parse(),a=Number(i.pop()),s=i.join(" ");a||(a=0,s=n.toString()),bot.log(n,s,a,"/define input");this.fetchDefinition(s,a,r)},fetchDefinition:function(e,t,n){function o(e){var i=e.query,a=i.pageids[0],s=i.pages[a],c=s.extract;if("-1"===a)return void n({pageid:-1});var u=document.createElement("body");u.innerHTML=c;var m=r.extractDefinitions(u),l=m[0],d=!1;return bot.log(m,"/define got definitions"),l.alternative?(bot.log(l.alternative,"/define found alternative"),void r.fetchData(l.alternative,o)):(l=m[t],l||(l=m[m.length-1],d=!0),void n({name:s.title,text:l.text,pageid:a,overflow:d}))}var r=this;this.fetchData(e,o)},extractDefinitions:function(e){var t=e.getElementsByTagName("ol")[0];return console.log(t,"/define definition list"),Array.from(t.children).map(this.extractSingleDefinition,this)},extractSingleDefinition:function(e){function n(e){var n=t+e.getAttribute("href"),o=bot.adapter.link(e.textContent,n),r=document.createTextNode(o);e.parentNode.replaceChild(r,e)}var o=this.extractAlternative(e.textContent);Array.from(e.children).forEach(function(t){"UL"===t.tagName&&e.removeChild(t)});for(var r=e.getElementsByTagName("a");r.length;)n(r[0]);return{alternative:o,text:e.textContent}},extractAlternative:function(e){return(n.exec(e)||[]).pop()},fetchData:function(e,t){var n=this;IO.jsonp({url:"http://en.wiktionary.org/w/api.php",jsonpName:"callback",data:{action:"query",titles:e,format:"json",prop:"extracts",indexpageids:!0},fun:function(e){t.call(n,e)}})}};bot.addCommand({name:"define",fun:o.command,thisArg:o,permissions:{del:"NONE"},description:"Fetches definition for a given word. `/define something`",async:!0})}(),function(){"use strict";function e(e,t){t+=Math.random()*(2*r.jitter)-r.jitter;for(var n=0;t>n;n++)e=" "+e;return e}function t(e){return" "+e+"\r"}function n(e){return e.sort(function(){return Math.random()-.5})}function o(o){for(var i=(o.length>0?o.toString():r.message).split(","),a=n(r.words.slice(0)),s=t(e("wow",4+4*Math.random()|0));i.length>a.length;)a=a.concat(n(r.words.slice(0)));for(;i.length;){var c="";a.length&&(c+=a.shift()+" "),c+=i.shift(),s+=t(e(c,r.spaces[i.length%3-1]))}o.send(s+"\r ")}var r={message:"fail,user,pro",spaces:[25,14,1],jitter:4,words:["so","very","such","much","many"]};bot.addCommand({fun:o,name:"doge",permissions:{del:"NONE"},description:"so shibe, much doge, wow `/doge one,two,three[,nth]",unTellable:!0})}(),bot.listen(/(which |what |give me a )?firefly( episode)?/i,function(e){var t=["Serenity","The Train Job","Bushwhacked","Shindig","Safe","Our Mrs. Reynolds","Jaynestown","Out of Gas","Ariel","War Stories","Trash","The Message","Heart of Gold","Objects in Space"];if(-1===e.indexOf("episode")&&Math.random()<.05)return"Serenity (movie)";var n=Math.floor(14*Math.random());return"Episode {0} - {1}".supplant(n+1,t[n])}),function(){var e=["The Google contains no such knowledge","There are no search results. Run.","My Google Fu has failed."],t={name:"google",fun:function(e,t){function n(n){var r=o.format(n);t&&t.call?t(r):e.directreply(r)}var o=this;this.logic(e,n)},logic:function(e,t){function n(n){if(bot.log(n,"/google response"),200!==n.responseStatus)return void finish("My Google-Fu is on vacation; status "+n.responseStatus);var o=n.responseData.results.slice(0,3);o.query=e,bot.log(o,"/google results"),t(o)}IO.jsonp.google(String(e)+" -site:w3schools.com",n)},format:function(t){function n(e){var t=IO.decodehtmlEntities(e.titleNoFormatting);return bot.adapter.link(t,e.unescapedUrl)}function o(e){var t="http://google.com/search?q="+encodeURIComponent(e);return bot.adapter.link("*",t)}if(!t.length)return e.random();var r=o(t.query)+" "+t.map(n).join(" ; ");return r.length>bot.adapter.maxLineLength&&(r=t.pluck("unescapedUrl").join(" ; ")),r},permissions:{del:"NONE"},description:"Search Google. `/google query`",async:!0};bot.addCommand(t)}(),function(){"use strict";var e=function(e,t){function n(e){t(e.word.toLowerCase().trim())}var o="http://sleepy-bastion-8674.herokuapp.com/";Number(e)&&(o+="?length="+e),IO.jsonp({url:o,jsonpName:"callback",fun:n})},t={dude:[" +---+"," | |"," | 413"," | 2"," | 5 6","__+__"].join("\n"),parts:["","O","|","/","\\","/","\\"],word:"",revealed:"",guesses:[],guessNum:0,maxGuess:6,end:!0,msg:null,validGuessRegex:/^[a-zA-Z]+$/,receiveMessage:function(e){return this.msg=e,this.end?void this["new"](e):this.handleGuess(e)},"new":function(n){function o(e){bot.log(e+" /hang random"),t.word=e,r.revealed=new Array(e.length+1).join("-"),r.guesses=[],r.guessNum=0,r.guessMade(),r.end=!1,n.length&&!Number(n)&&r.receiveMessage(n)}var r=this;e(n,o)},handleGuess:function(e){var t=e.slice().toLowerCase();bot.log(t,"handleGuess");var n=this.checkGuess(t);if(n)return n;var o=this.word.indexesOf(t);return o.forEach(function(e){this.uncoverPart(t,e)},this),o.length||this.guessNum++,this.guesses.push(t),this.guessMade(),bot.log(t,"handleGuess handled"),this.loseCheck()?this.lose():this.winCheck()?this.win():void 0},checkGuess:function(e){return!e.length||Number(e)?"We're already playing!":this.validGuessRegex.test(e)?this.guesses.indexOf(e)>-1?e+" was already submitted":e.length>this.word.length?bot.adapter.codify(e)+" is too long to fit":void 0:"I will only accept alpha characters"},uncoverPart:function(e,t){this.revealed=this.revealed.slice(0,t)+e+this.revealed.slice(t+e.length)},preparePrint:function(){if(!this.end){var e=this,t=this.dude.replace(/\d/g,function(t){return t>e.guessNum?" ":e.parts[t]}),n=this.guesses.sort().join(", ")+"\n"+this.revealed,o=this.msg.codify(t+"\n"+n);bot.log(o,this.msg),this.msg.send(o)}},win:function(){return this.end=!0,"Correct! The word is "+this.word+"."},lose:function(){return this.end=!0,"You people suck. The word is "+this.word},winCheck:function(){return this.word===this.revealed},loseCheck:function(){return this.guessNum>=this.maxGuess},guessMade:function(){clearTimeout(this.printTimeout),this.printTimeout=setTimeout(this.preparePrint.bind(this),2e3)}};bot.addCommand({name:"hang",fun:t.receiveMessage,thisArg:t})}(),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/imdb result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:imdb.com",n)})}bot.addCommand({name:"imdb",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches imdb page. `/imdb what`",async:!0})}(),function(){function e(n){if(!n.content)return t;var o=n.parse(!0);if(o.length>1)return o.map(e).join(" ");var r,i=n.trim().replace(/^\$/,"jQuery"),a=i.split("."),s=!1,c=i;return bot.log(i,a,"/jquery input"),3===a.length&&(a=[a[2]]),"jQuery"===a[0]&&jQuery[a[1]]?s=!0:1===a.length&&jQuery.prototype[a[0]]?(c=a[0],s=!0):jQuery[a[0]]&&(c="jQuery."+a[0],s=!0),r=s?t+c:t+"?s="+encodeURIComponent(n),bot.log(r,"/jquery link"),r}var t="http://api.jquery.com/";bot.addCommand({name:"jquery",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches documentation link from jQuery API. `/jquery what`"})}(),function(){"use strict";function e(e){bot.log(e,"/learn input");var n=e.parse(),r={name:n[0],output:n[1],input:n[2]||".*",creator:e.get("user_name"),creatorID:e.get("user_id"),date:new Date};r.name=r.name.toLowerCase();var a=o(r);return a?a:(r.input=new RegExp(r.input),r.description=["User-taught command:",n[3]||"",e.codify(r.output)].join(" "),bot.log(r,"/learn parsed"),t(r),i(r),"Command "+r.name+" learned")}function t(e){var t=bot.Command({name:e.name,description:e.description,creator:e.creator,date:e.date,fun:n(e),permissions:{use:"ALL",del:e.creatorID?[e.creatorID]:"OWNER"}});t.learned=!0,t.del=function(n){return function(){a(e.name),n.call(t)}}(t.del),bot.log(t,"/learn addCustomCommand"),bot.addCommand(t)}function n(e){function t(){var t=c.exec(e.output)||[,"user"],n=t[1];return n.slice(1,-1)}var n=e.output.replace(c,"").trim(),o=t();return bot.log(e,"/learn makeCustomCommand"),function(t){bot.log(t,e.name+" input");var r=bot.Message(n,t.get()),i=e.input.exec(t);if(!i)return m.supplant(e);var a=bot.parseMacro(r,i);switch(o){case"":t.send(a);break;case"msg":t.directreply(a);break;default:t.reply(a)}}}function o(e){function t(e){if(!bot.commandExists(e))return!0;var t=bot.getCommand(e);return t.learned&&t.date.getTime()+3e5>Date.now()}var n,o=Object.keys(e).some(function(t){return!e[t]});return o?n="Illegal `/learn` object; see `/help learn`":/\s/.test(e.name)?n="Invalid command name":t(e.name)?u.test(e.output)&&(n="Please enter some output"):n="Command "+e.name+" already exists",n}function r(){function e(e,o){o=JSON.parse(o),o.input=n(o.input),o.date=new Date(Date.parse(o.date)),t(o)}function n(e){var t=e.toString().split("/");return new RegExp(t.slice(1,-1).join("/"),t[t.length-1])}Object.iterate(s,e)}function i(e){s[e.name]=JSON.stringify(e),bot.memory.save("learn")}function a(e){delete s[e],bot.memory.save("learn")}var s=bot.memory.get("learn"),c=/^(<>||)/i,u=new RegExp(c.source+"$","i"),m="Input not matching `{input}`. Help: {description}";bot.addCommand({name:"learn",fun:e,privileges:{del:"NONE"},description:"Teaches me a command. `/learn cmdName outputPattern [inputRegex [description]]`"}),r()}(),bot.addCommand({name:"live",fun:function(){return bot.stopped?(bot["continue"](),"And on this day, you shall paint eggs for a giant bunny."):"I'm not dead! Honest!"},permissions:{del:"NONE",use:"OWNER"},description:"Resurrects me (:D) if I'm down (D:)"}),bot.addCommand(bot.CommunityCommand({name:"die",fun:function(){return bot.stopped?"Kill me once, shame on you, kill me twice...":(bot.stop(),"You killed me!")},permissions:{del:"NONE",use:"OWNER"},description:"Kills me :(",pendingMessage:"I will shut up after {0} more invocations."})),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/mdn result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:developer.mozilla.org",n)})}bot.addCommand({name:"mdn",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches mdn documentation. `/mdn what`",async:!0})}(),function(){function e(e){return t+o[e]+"."+n}var t="http://cdn.alltheragefaces.com/img/faces/png/",n="png",o={deskflip:"angry-desk-flip",fuu:"rage-classic",iseewhatyoudidthere:"happy-i-see-what-you-did-there-(clean)",no:"angry-no",notbad:"obama-not-bad",ohyou:"happy-oh-stop-it-you",okay:"okay-okay-clean",troll:"troll-troll-face",trollface:"troll-troll-face",youdontsay:"misc-you-dont-say"},r=new RegExp("^("+Object.keys(o).map(RegExp.escape).join("|")+")\\.(jpe?g|png)$");IO.register("input",function(t){var n=t.content.toLowerCase(),o=r.exec(n);if(o){var i=e(o[1]);bot.adapter.out.add(bot.adapter.directreply(t.message_id)+" "+i,t.room_id)}}),bot.addCommand({name:"meme",fun:function(t){var n=t.replace(/\.\w+$/,"");return n&&"list"!==n?o.hasOwnProperty(n)?void t.directreply(e(n)):"Sorry, I don't know that one.":Object.keys(o).join(", ")},permissions:{del:"NONE"},description:"Return a simple meme link. Pass no arguments or `list` to get a list of known memes. `/meme [memeName]`."})}(),function(){"use strict";function e(e){function o(t){bot.log(t,"/mustache finish"),e.directreply("http://mustachify.me/"+i.mustache+"?src="+t)}function r(e){var t=e.parse(),n=t.pop(),o={};return t.length>0&&!/\D/.test(n)?(o.usrid=t.join(" "),o.mustache=n):(o.usrid=e.content,o.mustache=Math.rand(0,5)),o}var i=r(e),a=i.usrid;if(bot.log(i,"/mustache input"),t(a))return void o(encodeURIComponent(a));if(a?/\D/.test(a)&&(a=e.findUserId(a)):a=e.get("user_id"),bot.log(a,"/mustache mapped"),!bot.users.hasOwnProperty(a))return n.supplant(a,bot.adapter.roomid);if(Number(a)===bot.adapter.user_id)return["Nobody puts a mustache on me. Again.","Mustache me once, shame on you. Mustache me ---twice--- 9 times..."].random();var s=bot.users[a].email_hash;o("!"===s[0]?encodeURIComponent(s.slice(1))+"#.png":"http%3A%2F%2Fwww.gravatar.com%2Favatar%2F{0}%3Fs%3D256%26d%3Didenticon#.png".supplant(s))}function t(e){return e.startsWith("http")||e.startsWith("www")}var n="User {0} was not found in room {1} (sorry, mustache only works there).",o={name:"mustache",fun:e,privileges:{del:"NONE"},description:"Mustachifies a user. `/mustache [link|usrid|username] [mustache=rand(0,5)]`"};bot.addCommand(o);var r=Object.merge(o,{name:"moustache"});bot.addCommand(r)}(),function(){function e(){Date.now();a=a.filter(function(e){return e.time-=c,e.time<=0?(t(e),!1):!0}),setTimeout(e,c)}function t(e){bot.log(e,"nudge fire"),e.msg.reply(e.message)}function n(e,t,n){var o;if(bot.log(e,t,"/nudge input"),e=parseFloat(e),o=6e4*e,isNaN(o))return"Many things can be labeled Not a Number; a delay should not be one of them.";s+=1;var r={msg:n,message:"*nudge* "+t,register:Date.now(),time:o,id:s};return a.push(r),bot.log(r,a,"/nudge register"),"Nudge #"+s+" registered."}function o(e,t){var n,o;return a.some(function(t,r){return t.id===e?(n=t,o=r,!0):void 0}),n?n.msg.get("user_name")!==t.get("user_name")?"It's not nice to try and remove a nudge which ain't yours":(bot.log(a[o],"/nudge remove #"+e),a.splice(o,1),"Nudge annhiliated"):["Nudge not found. Maybe it was already triggered, or this is a parallal universe.","I looked for nudge #"+e+", but all I found was this goat."].random()}function r(e){var t=e.parse(),r=t[0],i=t.slice(1).join(" ");return"remove"===r?o(Number(t[1]),e):n(r,i,e)}function i(e){return n(e.matches[1],e.matches[2],e)}var a=[],s=0,c=6e3;setTimeout(e,c),bot.addCommand({name:"nudge",fun:r,permissions:{del:"NONE"},description:"Register a nudge after an interval. `/nudge intervalInMinutes message`, `/nudge remove id` to remove, or the listener, `nudge|remind|poke me? in? intervalInMinutes message`",unTellable:!0}),bot.listen(/(?:nudge|remind|poke)\s(?:me\s)?(?:in\s)?(\d+m?)\s?(.*)$/,i)}(),function(){function e(e){function n(e){return e.name.toLowerCase().indexOf(i)>-1}function o(t){var n=e.escape(t.name);return"["+n+"](http://es5.github.com/#"+t.section+")"}var r,i=e.content.toLowerCase();return r=t.filter(n).map(o),bot.log(r,"/spec done"),r.length?r.join(", "):e+" not found in spec"}var t;t=[{section:"introduction",name:"Introduction"},{section:"x1",name:"1 Scope"},{section:"x2",name:"2 Conformance"},{section:"x3",name:"3 Normative references"},{section:"x4",name:"4 Overview"},{section:"x4.1",name:"4.1 Web Scripting"},{section:"x4.2",name:"4.2 Language Overview"},{section:"x4.2.1",name:"4.2.1 Objects"},{section:"x4.2.2",name:"4.2.2 The Strict Variant of ECMAScript"},{section:"x4.3",name:"4.3 Definitions"},{section:"x4.3.1",name:"4.3.1 type"},{section:"x4.3.2",name:"4.3.2 primitive value"},{section:"x4.3.3",name:"4.3.3 object"},{section:"x4.3.4",name:"4.3.4 constructor"},{section:"x4.3.5",name:"4.3.5 prototype"},{section:"x4.3.6",name:"4.3.6 native object"},{section:"x4.3.7",name:"4.3.7 built-in object"},{section:"x4.3.8",name:"4.3.8 host object"},{section:"x4.3.9",name:"4.3.9 undefined value"},{section:"x4.3.10",name:"4.3.10 Undefined type"},{section:"x4.3.11",name:"4.3.11 null value"},{section:"x4.3.12",name:"4.3.12 Null type"},{section:"x4.3.13",name:"4.3.13 Boolean value"},{section:"x4.3.14",name:"4.3.14 Boolean type"},{section:"x4.3.15",name:"4.3.15 Boolean object"},{section:"x4.3.16",name:"4.3.16 String value"},{section:"x4.3.17",name:"4.3.17 String type"},{section:"x4.3.18",name:"4.3.18 String object"},{section:"x4.3.19",name:"4.3.19 Number value"},{section:"x4.3.20",name:"4.3.20 Number type"},{section:"x4.3.21",name:"4.3.21 Number object"},{section:"x4.3.22",name:"4.3.22 Infinity"},{section:"x4.3.23",name:"4.3.23 NaN"},{section:"x4.3.24",name:"4.3.24 function"},{section:"x4.3.25",name:"4.3.25 built-in function"},{section:"x4.3.26",name:"4.3.26 property"},{section:"x4.3.27",name:"4.3.27 method"},{section:"x4.3.28",name:"4.3.28 built-in method"},{section:"x4.3.29",name:"4.3.29 attribute"},{section:"x4.3.30",name:"4.3.30 own property"},{section:"x4.3.31",name:"4.3.31 inherited property"},{section:"x5",name:"5 Notational Conventions"},{section:"x5.1",name:"5.1 Syntactic and Lexical Grammars"},{section:"x5.1.1",name:"5.1.1 Context-Free Grammars"},{section:"x5.1.2",name:"5.1.2 The Lexical and RegExp Grammars"},{section:"x5.1.3",name:"5.1.3 The Numeric String Grammar"},{section:"x5.1.4",name:"5.1.4 The Syntactic Grammar"},{section:"x5.1.5",name:"5.1.5 The JSON Grammar"},{section:"x5.1.6",name:"5.1.6 Grammar Notation"},{section:"x5.2",name:"5.2 Algorithm Conventions"},{section:"x6",name:"6 Source Text"},{section:"x7",name:"7 Lexical Conventions"},{section:"x7.1",name:"7.1 Unicode Format-Control Characters"},{section:"x7.2",name:"7.2 White Space"},{section:"x7.3",name:"7.3 Line Terminators"},{section:"x7.4",name:"7.4 Comments"},{section:"x7.5",name:"7.5 Tokens"},{section:"x7.6",name:"7.6 Identifier Names and Identifiers"},{section:"x7.6.1",name:"7.6.1 Reserved Words"},{section:"x7.6.1.1",name:"7.6.1.1 Keywords"},{section:"x7.6.1.2",name:"7.6.1.2 Future Reserved Words"},{section:"x7.7",name:"7.7 Punctuators"},{section:"x7.8",name:"7.8 Literals"},{section:"x7.8.1",name:"7.8.1 Null Literals"},{section:"x7.8.2",name:"7.8.2 Boolean Literals"},{section:"x7.8.3",name:"7.8.3 Numeric Literals"},{section:"x7.8.4",name:"7.8.4 String Literals"},{section:"x7.8.5",name:"7.8.5 Regular Expression Literals"},{section:"x7.9",name:"7.9 Automatic Semicolon Insertion"},{section:"x7.9.1",name:"7.9.1 Rules of Automatic Semicolon Insertion"},{section:"x7.9.2",name:"7.9.2 Examples of Automatic Semicolon Insertion"},{section:"x8",name:"8 Types"},{section:"x8.1",name:"8.1 The Undefined Type"},{section:"x8.2",name:"8.2 The Null Type"},{section:"x8.3",name:"8.3 The Boolean Type"},{section:"x8.4",name:"8.4 The String Type"},{section:"x8.5",name:"8.5 The Number Type"},{section:"x8.6",name:"8.6 The Object Type"},{section:"x8.6.1",name:"8.6.1 Property Attributes"},{section:"x8.6.2",name:"8.6.2 Object Internal Properties and Methods"},{section:"x8.7",name:"8.7 The Reference Specification Type"},{section:"x8.7.1",name:"8.7.1 GetValue (V)"},{section:"x8.7.2",name:"8.7.2 PutValue (V, W)"},{section:"x8.8",name:"8.8 The List Specification Type"},{section:"x8.9",name:"8.9 The Completion Specification Type"},{section:"x8.10",name:"8.10 The Property Descriptor and Property Identifier Specification Types"},{section:"x8.10.1",name:"8.10.1 IsAccessorDescriptor ( Desc )"},{section:"x8.10.2",name:"8.10.2 IsDataDescriptor ( Desc )"},{section:"x8.10.3",name:"8.10.3 IsGenericDescriptor ( Desc )"},{section:"x8.10.4",name:"8.10.4 FromPropertyDescriptor ( Desc )"},{section:"x8.10.5",name:"8.10.5 ToPropertyDescriptor ( Obj )"},{section:"x8.11",name:"8.11 The Lexical Environment and Environment Record Specification Types"},{section:"x8.12",name:"8.12 Algorithms for Object Internal Methods"},{section:"x8.12.1",name:"8.12.1 [[GetOwnProperty]] (P)"},{section:"x8.12.2",name:"8.12.2 [[GetProperty]] (P)"},{section:"x8.12.3",name:"8.12.3 [[Get]] (P)"},{section:"x8.12.4",name:"8.12.4 [[CanPut]] (P)" -},{section:"x8.12.5",name:"8.12.5 [[Put]] ( P, V, Throw )"},{section:"x8.12.6",name:"8.12.6 [[HasProperty]] (P)"},{section:"x8.12.7",name:"8.12.7 [[Delete]] (P, Throw)"},{section:"x8.12.8",name:"8.12.8 [[DefaultValue]] (hint)"},{section:"x8.12.9",name:"8.12.9 [[DefineOwnProperty]] (P, Desc, Throw)"},{section:"x9",name:"9 Type Conversion and Testing"},{section:"x9.1",name:"9.1 ToPrimitive"},{section:"x9.2",name:"9.2 ToBoolean"},{section:"x9.3",name:"9.3 ToNumber"},{section:"x9.3.1",name:"9.3.1 ToNumber Applied to the String Type"},{section:"x9.4",name:"9.4 ToInteger"},{section:"x9.5",name:"9.5 ToInt32: (Signed 32 Bit Integer)"},{section:"x9.6",name:"9.6 ToUint32: (Unsigned 32 Bit Integer)"},{section:"x9.7",name:"9.7 ToUint16: (Unsigned 16 Bit Integer)"},{section:"x9.8",name:"9.8 ToString"},{section:"x9.8.1",name:"9.8.1 ToString Applied to the Number Type"},{section:"x9.9",name:"9.9 ToObject"},{section:"x9.10",name:"9.10 CheckObjectCoercible"},{section:"x9.11",name:"9.11 IsCallable"},{section:"x9.12",name:"9.12 The SameValue Algorithm"},{section:"x10",name:"10 Executable Code and Execution Contexts"},{section:"x10.1",name:"10.1 Types of Executable Code"},{section:"x10.1.1",name:"10.1.1 Strict Mode Code"},{section:"x10.2",name:"10.2 Lexical Environments"},{section:"x10.2.1",name:"10.2.1 Environment Records"},{section:"x10.2.1.1",name:"10.2.1.1 Declarative Environment Records"},{section:"x10.2.1.1.1",name:"10.2.1.1.1 HasBinding(N)"},{section:"x10.2.1.1.2",name:"10.2.1.1.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.1.3",name:"10.2.1.1.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.1.4",name:"10.2.1.1.4 GetBindingValue(N,S)"},{section:"x10.2.1.1.5",name:"10.2.1.1.5 DeleteBinding (N)"},{section:"x10.2.1.1.6",name:"10.2.1.1.6 ImplicitThisValue()"},{section:"x10.2.1.1.7",name:"10.2.1.1.7 CreateImmutableBinding (N)"},{section:"x10.2.1.1.8",name:"10.2.1.1.8 InitializeImmutableBinding (N,V)"},{section:"x10.2.1.2",name:"10.2.1.2 Object Environment Records"},{section:"x10.2.1.2.1",name:"10.2.1.2.1 HasBinding(N)"},{section:"x10.2.1.2.2",name:"10.2.1.2.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.2.3",name:"10.2.1.2.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.2.4",name:"10.2.1.2.4 GetBindingValue(N,S)"},{section:"x10.2.1.2.5",name:"10.2.1.2.5 DeleteBinding (N)"},{section:"x10.2.1.2.6",name:"10.2.1.2.6 ImplicitThisValue()"},{section:"x10.2.2",name:"10.2.2 Lexical Environment Operations"},{section:"x10.2.2.1",name:"10.2.2.1 GetIdentifierReference (lex, name, strict)"},{section:"x10.2.2.2",name:"10.2.2.2 NewDeclarativeEnvironment (E)"},{section:"x10.2.2.3",name:"10.2.2.3 NewObjectEnvironment (O, E)"},{section:"x10.2.3",name:"10.2.3 The Global Environment"},{section:"x10.3",name:"10.3 Execution Contexts"},{section:"x10.3.1",name:"10.3.1 Identifier Resolution"},{section:"x10.4",name:"10.4 Establishing an Execution Context"},{section:"x10.4.1",name:"10.4.1 Entering Global Code"},{section:"x10.4.1.1",name:"10.4.1.1 Initial Global Execution Context"},{section:"x10.4.2",name:"10.4.2 Entering Eval Code"},{section:"x10.4.2.1",name:"10.4.2.1 Strict Mode Restrictions"},{section:"x10.4.3",name:"10.4.3 Entering Function Code"},{section:"x10.5",name:"10.5 Declaration Binding Instantiation"},{section:"x10.6",name:"10.6 Arguments Object"},{section:"x11",name:"11 Expressions"},{section:"x11.1",name:"11.1 Primary Expressions"},{section:"x11.1.1",name:"11.1.1 The this Keyword"},{section:"x11.1.2",name:"11.1.2 Identifier Reference"},{section:"x11.1.3",name:"11.1.3 Literal Reference"},{section:"x11.1.4",name:"11.1.4 Array Initialiser"},{section:"x11.1.5",name:"11.1.5 Object Initialiser"},{section:"x11.1.6",name:"11.1.6 The Grouping Operator"},{section:"x11.2",name:"11.2 Left-Hand-Side Expressions"},{section:"x11.2.1",name:"11.2.1 Property Accessors"},{section:"x11.2.2",name:"11.2.2 The new Operator"},{section:"x11.2.3",name:"11.2.3 Function Calls"},{section:"x11.2.4",name:"11.2.4 Argument Lists"},{section:"x11.2.5",name:"11.2.5 Function Expressions"},{section:"x11.3",name:"11.3 Postfix Expressions"},{section:"x11.3.1",name:"11.3.1 Postfix Increment Operator"},{section:"x11.3.2",name:"11.3.2 Postfix Decrement Operator"},{section:"x11.4",name:"11.4 Unary Operators"},{section:"x11.4.1",name:"11.4.1 The delete Operator"},{section:"x11.4.2",name:"11.4.2 The void Operator"},{section:"x11.4.3",name:"11.4.3 The typeof Operator"},{section:"x11.4.4",name:"11.4.4 Prefix Increment Operator"},{section:"x11.4.5",name:"11.4.5 Prefix Decrement Operator"},{section:"x11.4.6",name:"11.4.6 Unary + Operator"},{section:"x11.4.7",name:"11.4.7 Unary - Operator"},{section:"x11.4.8",name:"11.4.8 Bitwise NOT Operator ( ~ )"},{section:"x11.4.9",name:"11.4.9 Logical NOT Operator ( ! )"},{section:"x11.5",name:"11.5 Multiplicative Operators"},{section:"x11.5.1",name:"11.5.1 Applying the * Operator"},{section:"x11.5.2",name:"11.5.2 Applying the / Operator"},{section:"x11.5.3",name:"11.5.3 Applying the % Operator"},{section:"x11.6",name:"11.6 Additive Operators"},{section:"x11.6.1",name:"11.6.1 The Addition operator ( + )"},{section:"x11.6.2",name:"11.6.2 The Subtraction Operator ( - )"},{section:"x11.6.3",name:"11.6.3 Applying the Additive Operators to Numbers"},{section:"x11.7",name:"11.7 Bitwise Shift Operators"},{section:"x11.7.1",name:"11.7.1 The Left Shift Operator ( << )"},{section:"x11.7.2",name:"11.7.2 The Signed Right Shift Operator ( >> )"},{section:"x11.7.3",name:"11.7.3 The Unsigned Right Shift Operator ( >>> )"},{section:"x11.8",name:"11.8 Relational Operators"},{section:"x11.8.1",name:"11.8.1 The Less-than Operator ( < )"},{section:"x11.8.2",name:"11.8.2 The Greater-than Operator ( > )"},{section:"x11.8.3",name:"11.8.3 The Less-than-or-equal Operator ( <= )"},{section:"x11.8.4",name:"11.8.4 The Greater-than-or-equal Operator ( >= )"},{section:"x11.8.5",name:"11.8.5 The Abstract Relational Comparison Algorithm"},{section:"x11.8.6",name:"11.8.6 The instanceof operator"},{section:"x11.8.7",name:"11.8.7 The in operator"},{section:"x11.9",name:"11.9 Equality Operators"},{section:"x11.9.1",name:"11.9.1 The Equals Operator ( == )"},{section:"x11.9.2",name:"11.9.2 The Does-not-equals Operator ( != )"},{section:"x11.9.3",name:"11.9.3 The Abstract Equality Comparison Algorithm"},{section:"x11.9.4",name:"11.9.4 The Strict Equals Operator ( === )"},{section:"x11.9.5",name:"11.9.5 The Strict Does-not-equal Operator ( !== )"},{section:"x11.9.6",name:"11.9.6 The Strict Equality Comparison Algorithm"},{section:"x11.10",name:"11.10 Binary Bitwise Operators"},{section:"x11.11",name:"11.11 Binary Logical Operators"},{section:"x11.12",name:"11.12 Conditional Operator ( ? : )"},{section:"x11.13",name:"11.13 Assignment Operators"},{section:"x11.13.1",name:"11.13.1 Simple Assignment ( = )"},{section:"x11.13.2",name:"11.13.2 Compound Assignment ( op= )"},{section:"x11.14",name:"11.14 Comma Operator ( , )"},{section:"x12",name:"12 Statements"},{section:"x12.1",name:"12.1 Block"},{section:"x12.2",name:"12.2 Variable Statement"},{section:"x12.2.1",name:"12.2.1 Strict Mode Restrictions"},{section:"x12.3",name:"12.3 Empty Statement"},{section:"x12.4",name:"12.4 Expression Statement"},{section:"x12.5",name:"12.5 The if Statement"},{section:"x12.6",name:"12.6 Iteration Statements"},{section:"x12.6.1",name:"12.6.1 The do-while Statement"},{section:"x12.6.2",name:"12.6.2 The while Statement"},{section:"x12.6.3",name:"12.6.3 The for Statement"},{section:"x12.6.4",name:"12.6.4 The for-in Statement"},{section:"x12.7",name:"12.7 The continue Statement"},{section:"x12.8",name:"12.8 The break Statement"},{section:"x12.9",name:"12.9 The return Statement"},{section:"x12.10",name:"12.10 The with Statement"},{section:"x12.10.1",name:"12.10.1 Strict Mode Restrictions"},{section:"x12.11",name:"12.11 The switch Statement"},{section:"x12.12",name:"12.12 Labelled Statements"},{section:"x12.13",name:"12.13 The throw Statement"},{section:"x12.14",name:"12.14 The try Statement"},{section:"x12.14.1",name:"12.14.1 Strict Mode Restrictions"},{section:"x12.15",name:"12.15 The debugger statement"},{section:"x13",name:"13 Function Definition"},{section:"x13.1",name:"13.1 Strict Mode Restrictions"},{section:"x13.2",name:"13.2 Creating Function Objects"},{section:"x13.2.1",name:"13.2.1 [[Call]]"},{section:"x13.2.2",name:"13.2.2 [[Construct]]"},{section:"x13.2.3",name:"13.2.3 The Function Object"},{section:"x14",name:"14 Program"},{section:"x14.1",name:"14.1 Directive Prologues and the Use Strict Directive"},{section:"x15",name:"15 Standard Built-in ECMAScript Objects"},{section:"x15.1",name:"15.1 The Global Object"},{section:"x15.1.1",name:"15.1.1 Value Properties of the Global Object"},{section:"x15.1.1.1",name:"15.1.1.1 NaN"},{section:"x15.1.1.2",name:"15.1.1.2 Infinity"},{section:"x15.1.1.3",name:"15.1.1.3 undefined"},{section:"x15.1.2",name:"15.1.2 Function Properties of the Global Object"},{section:"x15.1.2.1",name:"15.1.2.1 eval (x)"},{section:"x15.1.2.1.1",name:"15.1.2.1.1 Direct Call to Eval"},{section:"x15.1.2.2",name:"15.1.2.2 parseInt (string , radix)"},{section:"x15.1.2.3",name:"15.1.2.3 parseFloat (string)"},{section:"x15.1.2.4",name:"15.1.2.4 isNaN (number)"},{section:"x15.1.2.5",name:"15.1.2.5 isFinite (number)"},{section:"x15.1.3",name:"15.1.3 URI Handling Function Properties"},{section:"x15.1.3.1",name:"15.1.3.1 decodeURI (encodedURI)"},{section:"x15.1.3.2",name:"15.1.3.2 decodeURIComponent (encodedURIComponent)"},{section:"x15.1.3.3",name:"15.1.3.3 encodeURI (uri)"},{section:"x15.1.3.4",name:"15.1.3.4 encodeURIComponent (uriComponent)"},{section:"x15.1.4",name:"15.1.4 Constructor Properties of the Global Object"},{section:"x15.1.4.1",name:"15.1.4.1 Object ( . . . )"},{section:"x15.1.4.2",name:"15.1.4.2 Function ( . . . )"},{section:"x15.1.4.3",name:"15.1.4.3 Array ( . . . )"},{section:"x15.1.4.4",name:"15.1.4.4 String ( . . . )"},{section:"x15.1.4.5",name:"15.1.4.5 Boolean ( . . . )"},{section:"x15.1.4.6",name:"15.1.4.6 Number ( . . . )"},{section:"x15.1.4.7",name:"15.1.4.7 Date ( . . . )"},{section:"x15.1.4.8",name:"15.1.4.8 RegExp ( . . . )"},{section:"x15.1.4.9",name:"15.1.4.9 Error ( . . . )"},{section:"x15.1.4.10",name:"15.1.4.10 EvalError ( . . . )"},{section:"x15.1.4.11",name:"15.1.4.11 RangeError ( . . . )"},{section:"x15.1.4.12",name:"15.1.4.12 ReferenceError ( . . . )"},{section:"x15.1.4.13",name:"15.1.4.13 SyntaxError ( . . . )"},{section:"x15.1.4.14",name:"15.1.4.14 TypeError ( . . . )"},{section:"x15.1.4.15",name:"15.1.4.15 URIError ( . . . )"},{section:"x15.1.5",name:"15.1.5 Other Properties of the Global Object"},{section:"x15.1.5.1",name:"15.1.5.1 Math"},{section:"x15.1.5.2",name:"15.1.5.2 JSON"},{section:"x15.2",name:"15.2 Object Objects"},{section:"x15.2.1",name:"15.2.1 The Object Constructor Called as a Function"},{section:"x15.2.1.1",name:"15.2.1.1 Object ( [ value ] )"},{section:"x15.2.2",name:"15.2.2 The Object Constructor"},{section:"x15.2.2.1",name:"15.2.2.1 new Object ( [ value ] )"},{section:"x15.2.3",name:"15.2.3 Properties of the Object Constructor"},{section:"x15.2.3.1",name:"15.2.3.1 Object.prototype"},{section:"x15.2.3.2",name:"15.2.3.2 Object.getPrototypeOf ( O )"},{section:"x15.2.3.3",name:"15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) "},{section:"x15.2.3.4",name:"15.2.3.4 Object.getOwnPropertyNames ( O )"},{section:"x15.2.3.5",name:"15.2.3.5 Object.create ( O [, Properties] )"},{section:"x15.2.3.6",name:"15.2.3.6 Object.defineProperty ( O, P, Attributes )"},{section:"x15.2.3.7",name:"15.2.3.7 Object.defineProperties ( O, Properties )"},{section:"x15.2.3.8",name:"15.2.3.8 Object.seal ( O )"},{section:"x15.2.3.9",name:"15.2.3.9 Object.freeze ( O )"},{section:"x15.2.3.10",name:"15.2.3.10 Object.preventExtensions ( O )"},{section:"x15.2.3.11",name:"15.2.3.11 Object.isSealed ( O )"},{section:"x15.2.3.12",name:"15.2.3.12 Object.isFrozen ( O )"},{section:"x15.2.3.13",name:"15.2.3.13 Object.isExtensible ( O )"},{section:"x15.2.3.14",name:"15.2.3.14 Object.keys ( O )"},{section:"x15.2.4",name:"15.2.4 Properties of the Object Prototype Object"},{section:"x15.2.4.1",name:"15.2.4.1 Object.prototype.constructor"},{section:"x15.2.4.2",name:"15.2.4.2 Object.prototype.toString ( )"},{section:"x15.2.4.3",name:"15.2.4.3 Object.prototype.toLocaleString ( )"},{section:"x15.2.4.4",name:"15.2.4.4 Object.prototype.valueOf ( )"},{section:"x15.2.4.5",name:"15.2.4.5 Object.prototype.hasOwnProperty (V)"},{section:"x15.2.4.6",name:"15.2.4.6 Object.prototype.isPrototypeOf (V)"},{section:"x15.2.4.7",name:"15.2.4.7 Object.prototype.propertyIsEnumerable (V)"},{section:"x15.2.5",name:"15.2.5 Properties of Object Instances"},{section:"x15.3",name:"15.3 Function Objects"},{section:"x15.3.1",name:"15.3.1 The Function Constructor Called as a Function"},{section:"x15.3.1.1",name:"15.3.1.1 Function (p1, p2, … , pn, body)"},{section:"x15.3.2",name:"15.3.2 The Function Constructor"},{section:"x15.3.2.1",name:"15.3.2.1 new Function (p1, p2, … , pn, body)"},{section:"x15.3.3",name:"15.3.3 Properties of the Function Constructor"},{section:"x15.3.3.1",name:"15.3.3.1 Function.prototype"},{section:"x15.3.3.2",name:"15.3.3.2 Function.length"},{section:"x15.3.4",name:"15.3.4 Properties of the Function Prototype Object"},{section:"x15.3.4.1",name:"15.3.4.1 Function.prototype.constructor"},{section:"x15.3.4.2",name:"15.3.4.2 Function.prototype.toString ( )"},{section:"x15.3.4.3",name:"15.3.4.3 Function.prototype.apply (thisArg, argArray)"},{section:"x15.3.4.4",name:"15.3.4.4 Function.prototype.call (thisArg [ , arg1 [ , arg2, … ] ] )"},{section:"x15.3.4.5",name:"15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, …]])"},{section:"x15.3.4.5.1",name:"15.3.4.5.1 [[Call]]"},{section:"x15.3.4.5.2",name:"15.3.4.5.2 [[Construct]]"},{section:"x15.3.4.5.3",name:"15.3.4.5.3 [[HasInstance]] (V)"},{section:"x15.3.5",name:"15.3.5 Properties of Function Instances"},{section:"x15.3.5.1",name:"15.3.5.1 length"},{section:"x15.3.5.2",name:"15.3.5.2 prototype"},{section:"x15.3.5.3",name:"15.3.5.3 [[HasInstance]] (V)"},{section:"x15.3.5.4",name:"15.3.5.4 [[Get]] (P)"},{section:"x15.4",name:"15.4 Array Objects"},{section:"x15.4.1",name:"15.4.1 The Array Constructor Called as a Function"},{section:"x15.4.1.1",name:"15.4.1.1 Array ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.2",name:"15.4.2 The Array Constructor"},{section:"x15.4.2.1",name:"15.4.2.1 new Array ( [ item0 [ , item1 [ , … ] ] ] )"},{section:"x15.4.2.2",name:"15.4.2.2 new Array (len)"},{section:"x15.4.3",name:"15.4.3 Properties of the Array Constructor"},{section:"x15.4.3.1",name:"15.4.3.1 Array.prototype"},{section:"x15.4.3.2",name:"15.4.3.2 Array.isArray ( arg )"},{section:"x15.4.4",name:"15.4.4 Properties of the Array Prototype Object"},{section:"x15.4.4.1",name:"15.4.4.1 Array.prototype.constructor"},{section:"x15.4.4.2",name:"15.4.4.2 Array.prototype.toString ( )"},{section:"x15.4.4.3",name:"15.4.4.3 Array.prototype.toLocaleString ( )"},{section:"x15.4.4.4",name:"15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.5",name:"15.4.4.5 Array.prototype.join (separator)"},{section:"x15.4.4.6",name:"15.4.4.6 Array.prototype.pop ( )"},{section:"x15.4.4.7",name:"15.4.4.7 Array.prototype.push ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.8",name:"15.4.4.8 Array.prototype.reverse ( )"},{section:"x15.4.4.9",name:"15.4.4.9 Array.prototype.shift ( )"},{section:"x15.4.4.10",name:"15.4.4.10 Array.prototype.slice (start, end)"},{section:"x15.4.4.11",name:"15.4.4.11 Array.prototype.sort (comparefn)"},{section:"x15.4.4.12",name:"15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.13",name:"15.4.4.13 Array.prototype.unshift ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.14",name:"15.4.4.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.15",name:"15.4.4.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.16",name:"15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.17",name:"15.4.4.17 Array.prototype.some ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.18",name:"15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.19",name:"15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.20",name:"15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.21",name:"15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue ] )"},{section:"x15.4.4.22",name:"15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )"},{section:"x15.4.5",name:"15.4.5 Properties of Array Instances"},{section:"x15.4.5.1",name:"15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )"},{section:"x15.4.5.2",name:"15.4.5.2 length"},{section:"x15.5",name:"15.5 String Objects"},{section:"x15.5.1",name:"15.5.1 The String Constructor Called as a Function"},{section:"x15.5.1.1",name:"15.5.1.1 String ( [ value ] )"},{section:"x15.5.2",name:"15.5.2 The String Constructor"},{section:"x15.5.2.1",name:"15.5.2.1 new String ( [ value ] )"},{section:"x15.5.3",name:"15.5.3 Properties of the String Constructor"},{section:"x15.5.3.1",name:"15.5.3.1 String.prototype"},{section:"x15.5.3.2",name:"15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] )"},{section:"x15.5.4",name:"15.5.4 Properties of the String Prototype Object"},{section:"x15.5.4.1",name:"15.5.4.1 String.prototype.constructor"},{section:"x15.5.4.2",name:"15.5.4.2 String.prototype.toString ( )"},{section:"x15.5.4.3",name:"15.5.4.3 String.prototype.valueOf ( )"},{section:"x15.5.4.4",name:"15.5.4.4 String.prototype.charAt (pos)"},{section:"x15.5.4.5",name:"15.5.4.5 String.prototype.charCodeAt (pos)"},{section:"x15.5.4.6",name:"15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] )"},{section:"x15.5.4.7",name:"15.5.4.7 String.prototype.indexOf (searchString, position)"},{section:"x15.5.4.8",name:"15.5.4.8 String.prototype.lastIndexOf (searchString, position)"},{section:"x15.5.4.9",name:"15.5.4.9 String.prototype.localeCompare (that)"},{section:"x15.5.4.10",name:"15.5.4.10 String.prototype.match (regexp)"},{section:"x15.5.4.11",name:"15.5.4.11 String.prototype.replace (searchValue, replaceValue)"},{section:"x15.5.4.12",name:"15.5.4.12 String.prototype.search (regexp)"},{section:"x15.5.4.13",name:"15.5.4.13 String.prototype.slice (start, end)"},{section:"x15.5.4.14",name:"15.5.4.14 String.prototype.split (separator, limit)"},{section:"x15.5.4.15",name:"15.5.4.15 String.prototype.substring (start, end)"},{section:"x15.5.4.16",name:"15.5.4.16 String.prototype.toLowerCase ( )"},{section:"x15.5.4.17",name:"15.5.4.17 String.prototype.toLocaleLowerCase ( )"},{section:"x15.5.4.18",name:"15.5.4.18 String.prototype.toUpperCase ( )"},{section:"x15.5.4.19",name:"15.5.4.19 String.prototype.toLocaleUpperCase ( )"},{section:"x15.5.4.20",name:"15.5.4.20 String.prototype.trim ( )"},{section:"x15.5.5",name:"15.5.5 Properties of String Instances"},{section:"x15.5.5.1",name:"15.5.5.1 length"},{section:"x15.5.5.2",name:"15.5.5.2 [[GetOwnProperty]] ( P )"},{section:"x15.6",name:"15.6 Boolean Objects"},{section:"x15.6.1",name:"15.6.1 The Boolean Constructor Called as a Function"},{section:"x15.6.1.1",name:"15.6.1.1 Boolean (value)"},{section:"x15.6.2",name:"15.6.2 The Boolean Constructor"},{section:"x15.6.2.1",name:"15.6.2.1 new Boolean (value)"},{section:"x15.6.3",name:"15.6.3 Properties of the Boolean Constructor"},{section:"x15.6.3.1",name:"15.6.3.1 Boolean.prototype"},{section:"x15.6.4",name:"15.6.4 Properties of the Boolean Prototype Object"},{section:"x15.6.4.1",name:"15.6.4.1 Boolean.prototype.constructor"},{section:"x15.6.4.2",name:"15.6.4.2 Boolean.prototype.toString ( )"},{section:"x15.6.4.3",name:"15.6.4.3 Boolean.prototype.valueOf ( )"},{section:"x15.6.5",name:"15.6.5 Properties of Boolean Instances"},{section:"x15.7",name:"15.7 Number Objects"},{section:"x15.7.1",name:"15.7.1 The Number Constructor Called as a Function"},{section:"x15.7.1.1",name:"15.7.1.1 Number ( [ value ] )"},{section:"x15.7.2",name:"15.7.2 The Number Constructor"},{section:"x15.7.2.1",name:"15.7.2.1 new Number ( [ value ] )"},{section:"x15.7.3",name:"15.7.3 Properties of the Number Constructor"},{section:"x15.7.3.1",name:"15.7.3.1 Number.prototype"},{section:"x15.7.3.2",name:"15.7.3.2 Number.MAX_VALUE"},{section:"x15.7.3.3",name:"15.7.3.3 Number.MIN_VALUE"},{section:"x15.7.3.4",name:"15.7.3.4 Number.NaN"},{section:"x15.7.3.5",name:"15.7.3.5 Number.NEGATIVE_INFINITY"},{section:"x15.7.3.6",name:"15.7.3.6 Number.POSITIVE_INFINITY"},{section:"x15.7.4",name:"15.7.4 Properties of the Number Prototype Object"},{section:"x15.7.4.1",name:"15.7.4.1 Number.prototype.constructor"},{section:"x15.7.4.2",name:"15.7.4.2 Number.prototype.toString ( [ radix ] )"},{section:"x15.7.4.3",name:"15.7.4.3 Number.prototype.toLocaleString()"},{section:"x15.7.4.4",name:"15.7.4.4 Number.prototype.valueOf ( )"},{section:"x15.7.4.5",name:"15.7.4.5 Number.prototype.toFixed (fractionDigits)"},{section:"x15.7.4.6",name:"15.7.4.6 Number.prototype.toExponential (fractionDigits)"},{section:"x15.7.4.7",name:"15.7.4.7 Number.prototype.toPrecision (precision)"},{section:"x15.7.5",name:"15.7.5 Properties of Number Instances"},{section:"x15.8",name:"15.8 The Math Object"},{section:"x15.8.1",name:"15.8.1 Value Properties of the Math Object"},{section:"x15.8.1.1",name:"15.8.1.1 E"},{section:"x15.8.1.2",name:"15.8.1.2 LN10"},{section:"x15.8.1.3",name:"15.8.1.3 LN2"},{section:"x15.8.1.4",name:"15.8.1.4 LOG2E"},{section:"x15.8.1.5",name:"15.8.1.5 LOG10E"},{section:"x15.8.1.6",name:"15.8.1.6 PI"},{section:"x15.8.1.7",name:"15.8.1.7 SQRT1_2"},{section:"x15.8.1.8",name:"15.8.1.8 SQRT2"},{section:"x15.8.2",name:"15.8.2 Function Properties of the Math Object"},{section:"x15.8.2.1",name:"15.8.2.1 abs (x)"},{section:"x15.8.2.2",name:"15.8.2.2 acos (x)"},{section:"x15.8.2.3",name:"15.8.2.3 asin (x)"},{section:"x15.8.2.4",name:"15.8.2.4 atan (x)"},{section:"x15.8.2.5",name:"15.8.2.5 atan2 (y, x)"},{section:"x15.8.2.6",name:"15.8.2.6 ceil (x)"},{section:"x15.8.2.7",name:"15.8.2.7 cos (x)"},{section:"x15.8.2.8",name:"15.8.2.8 exp (x)"},{section:"x15.8.2.9",name:"15.8.2.9 floor (x)"},{section:"x15.8.2.10",name:"15.8.2.10 log (x)"},{section:"x15.8.2.11",name:"15.8.2.11 max ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.12",name:"15.8.2.12 min ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.13",name:"15.8.2.13 pow (x, y)"},{section:"x15.8.2.14",name:"15.8.2.14 random ( )"},{section:"x15.8.2.15",name:"15.8.2.15 round (x)"},{section:"x15.8.2.16",name:"15.8.2.16 sin (x)"},{section:"x15.8.2.17",name:"15.8.2.17 sqrt (x)"},{section:"x15.8.2.18",name:"15.8.2.18 tan (x)"},{section:"x15.9",name:"15.9 Date Objects"},{section:"x15.9.1",name:"15.9.1 Overview of Date Objects and Definitions of Abstract Operators"},{section:"x15.9.1.1",name:"15.9.1.1 Time Values and Time Range"},{section:"x15.9.1.2",name:"15.9.1.2 Day Number and Time within Day"},{section:"x15.9.1.3",name:"15.9.1.3 Year Number"},{section:"x15.9.1.4",name:"15.9.1.4 Month Number"},{section:"x15.9.1.5",name:"15.9.1.5 Date Number"},{section:"x15.9.1.6",name:"15.9.1.6 Week Day"},{section:"x15.9.1.7",name:"15.9.1.7 Local Time Zone Adjustment"},{section:"x15.9.1.8",name:"15.9.1.8 Daylight Saving Time Adjustment"},{section:"x15.9.1.9",name:"15.9.1.9 Local Time"},{section:"x15.9.1.10",name:"15.9.1.10 Hours, Minutes, Second, and Milliseconds"},{section:"x15.9.1.11",name:"15.9.1.11 MakeTime (hour, min, sec, ms)"},{section:"x15.9.1.12",name:"15.9.1.12 MakeDay (year, month, date)"},{section:"x15.9.1.13",name:"15.9.1.13 MakeDate (day, time)"},{section:"x15.9.1.14",name:"15.9.1.14 TimeClip (time)"},{section:"x15.9.1.15",name:"15.9.1.15 Date Time String Format"},{section:"x15.9.1.15.1",name:"15.9.1.15.1 Extended years"},{section:"x15.9.2",name:"15.9.2 The Date Constructor Called as a Function"},{section:"x15.9.2.1",name:"15.9.2.1 Date ( [ year [, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] ] ] )"},{section:"x15.9.3",name:"15.9.3 The Date Constructor"},{section:"x15.9.3.1",name:"15.9.3.1 new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )"},{section:"x15.9.3.2",name:"15.9.3.2 new Date (value)"},{section:"x15.9.3.3",name:"15.9.3.3 new Date ( )"},{section:"x15.9.4",name:"15.9.4 Properties of the Date Constructor"},{section:"x15.9.4.1",name:"15.9.4.1 Date.prototype"},{section:"x15.9.4.2",name:"15.9.4.2 Date.parse (string)"},{section:"x15.9.4.3",name:"15.9.4.3 Date.UTC (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ])"},{section:"x15.9.4.4",name:"15.9.4.4 Date.now ( )"},{section:"x15.9.5",name:"15.9.5 Properties of the Date Prototype Object"},{section:"x15.9.5.1",name:"15.9.5.1 Date.prototype.constructor"},{section:"x15.9.5.2",name:"15.9.5.2 Date.prototype.toString ( )"},{section:"x15.9.5.3",name:"15.9.5.3 Date.prototype.toDateString ( )"},{section:"x15.9.5.4",name:"15.9.5.4 Date.prototype.toTimeString ( )"},{section:"x15.9.5.5",name:"15.9.5.5 Date.prototype.toLocaleString ( )"},{section:"x15.9.5.6",name:"15.9.5.6 Date.prototype.toLocaleDateString ( )"},{section:"x15.9.5.7",name:"15.9.5.7 Date.prototype.toLocaleTimeString ( )"},{section:"x15.9.5.8",name:"15.9.5.8 Date.prototype.valueOf ( )"},{section:"x15.9.5.9",name:"15.9.5.9 Date.prototype.getTime ( )"},{section:"x15.9.5.10",name:"15.9.5.10 Date.prototype.getFullYear ( )"},{section:"x15.9.5.11",name:"15.9.5.11 Date.prototype.getUTCFullYear ( )"},{section:"x15.9.5.12",name:"15.9.5.12 Date.prototype.getMonth ( )"},{section:"x15.9.5.13",name:"15.9.5.13 Date.prototype.getUTCMonth ( )"},{section:"x15.9.5.14",name:"15.9.5.14 Date.prototype.getDate ( )"},{section:"x15.9.5.15",name:"15.9.5.15 Date.prototype.getUTCDate ( )"},{section:"x15.9.5.16",name:"15.9.5.16 Date.prototype.getDay ( )"},{section:"x15.9.5.17",name:"15.9.5.17 Date.prototype.getUTCDay ( )"},{section:"x15.9.5.18",name:"15.9.5.18 Date.prototype.getHours ( )"},{section:"x15.9.5.19",name:"15.9.5.19 Date.prototype.getUTCHours ( )"},{section:"x15.9.5.20",name:"15.9.5.20 Date.prototype.getMinutes ( )"},{section:"x15.9.5.21",name:"15.9.5.21 Date.prototype.getUTCMinutes ( )"},{section:"x15.9.5.22",name:"15.9.5.22 Date.prototype.getSeconds ( )"},{section:"x15.9.5.23",name:"15.9.5.23 Date.prototype.getUTCSeconds ( )"},{section:"x15.9.5.24",name:"15.9.5.24 Date.prototype.getMilliseconds ( )"},{section:"x15.9.5.25",name:"15.9.5.25 Date.prototype.getUTCMilliseconds ( )"},{section:"x15.9.5.26",name:"15.9.5.26 Date.prototype.getTimezoneOffset ( )"},{section:"x15.9.5.27",name:"15.9.5.27 Date.prototype.setTime (time)"},{section:"x15.9.5.28",name:"15.9.5.28 Date.prototype.setMilliseconds (ms)"},{section:"x15.9.5.29",name:"15.9.5.29 Date.prototype.setUTCMilliseconds (ms)"},{section:"x15.9.5.30",name:"15.9.5.30 Date.prototype.setSeconds (sec [, ms ] )"},{section:"x15.9.5.31",name:"15.9.5.31 Date.prototype.setUTCSeconds (sec [, ms ] )"},{section:"x15.9.5.32",name:"15.9.5.32 Date.prototype.setMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.33",name:"15.9.5.33 Date.prototype.setUTCMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.34",name:"15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.35",name:"15.9.5.35 Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.36",name:"15.9.5.36 Date.prototype.setDate (date)"},{section:"x15.9.5.37",name:"15.9.5.37 Date.prototype.setUTCDate (date)"},{section:"x15.9.5.38",name:"15.9.5.38 Date.prototype.setMonth (month [, date ] )"},{section:"x15.9.5.39",name:"15.9.5.39 Date.prototype.setUTCMonth (month [, date ] )"},{section:"x15.9.5.40",name:"15.9.5.40 Date.prototype.setFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.41",name:"15.9.5.41 Date.prototype.setUTCFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.42",name:"15.9.5.42 Date.prototype.toUTCString ( )"},{section:"x15.9.5.43",name:"15.9.5.43 Date.prototype.toISOString ( )"},{section:"x15.9.5.44",name:"15.9.5.44 Date.prototype.toJSON ( key )"},{section:"x15.9.6",name:"15.9.6 Properties of Date Instances"},{section:"x15.10",name:"15.10 RegExp (Regular Expression) Objects"},{section:"x15.10.1",name:"15.10.1 Patterns"},{section:"x15.10.2",name:"15.10.2 Pattern Semantics"},{section:"x15.10.2.1",name:"15.10.2.1 Notation"},{section:"x15.10.2.2",name:"15.10.2.2 Pattern"},{section:"x15.10.2.3",name:"15.10.2.3 Disjunction"},{section:"x15.10.2.4",name:"15.10.2.4 Alternative"},{section:"x15.10.2.5",name:"15.10.2.5 Term"},{section:"x15.10.2.6",name:"15.10.2.6 Assertion"},{section:"x15.10.2.7",name:"15.10.2.7 Quantifier"},{section:"x15.10.2.8",name:"15.10.2.8 Atom"},{section:"x15.10.2.9",name:"15.10.2.9 AtomEscape"},{section:"x15.10.2.10",name:"15.10.2.10 CharacterEscape"},{section:"x15.10.2.11",name:"15.10.2.11 DecimalEscape"},{section:"x15.10.2.12",name:"15.10.2.12 CharacterClassEscape"},{section:"x15.10.2.13",name:"15.10.2.13 CharacterClass"},{section:"x15.10.2.14",name:"15.10.2.14 ClassRanges"},{section:"x15.10.2.15",name:"15.10.2.15 NonemptyClassRanges"},{section:"x15.10.2.16",name:"15.10.2.16 NonemptyClassRangesNoDash"},{section:"x15.10.2.17",name:"15.10.2.17 ClassAtom"},{section:"x15.10.2.18",name:"15.10.2.18 ClassAtomNoDash"},{section:"x15.10.2.19",name:"15.10.2.19 ClassEscape"},{section:"x15.10.3",name:"15.10.3 The RegExp Constructor Called as a Function"},{section:"x15.10.3.1",name:"15.10.3.1 RegExp(pattern, flags)"},{section:"x15.10.4",name:"15.10.4 The RegExp Constructor"},{section:"x15.10.4.1",name:"15.10.4.1 new RegExp(pattern, flags)"},{section:"x15.10.5",name:"15.10.5 Properties of the RegExp Constructor"},{section:"x15.10.5.1",name:"15.10.5.1 RegExp.prototype"},{section:"x15.10.6",name:"15.10.6 Properties of the RegExp Prototype Object"},{section:"x15.10.6.1",name:"15.10.6.1 RegExp.prototype.constructor"},{section:"x15.10.6.2",name:"15.10.6.2 RegExp.prototype.exec(string)"},{section:"x15.10.6.3",name:"15.10.6.3 RegExp.prototype.test(string)"},{section:"x15.10.6.4",name:"15.10.6.4 RegExp.prototype.toString()"},{section:"x15.10.7",name:"15.10.7 Properties of RegExp Instances"},{section:"x15.10.7.1",name:"15.10.7.1 source"},{section:"x15.10.7.2",name:"15.10.7.2 global"},{section:"x15.10.7.3",name:"15.10.7.3 ignoreCase"},{section:"x15.10.7.4",name:"15.10.7.4 multiline"},{section:"x15.10.7.5",name:"15.10.7.5 lastIndex"},{section:"x15.11",name:"15.11 Error Objects"},{section:"x15.11.1",name:"15.11.1 The Error Constructor Called as a Function"},{section:"x15.11.1.1",name:"15.11.1.1 Error (message)"},{section:"x15.11.2",name:"15.11.2 The Error Constructor"},{section:"x15.11.2.1",name:"15.11.2.1 new Error (message)"},{section:"x15.11.3",name:"15.11.3 Properties of the Error Constructor"},{section:"x15.11.3.1",name:"15.11.3.1 Error.prototype"},{section:"x15.11.4",name:"15.11.4 Properties of the Error Prototype Object"},{section:"x15.11.4.1",name:"15.11.4.1 Error.prototype.constructor"},{section:"x15.11.4.2",name:"15.11.4.2 Error.prototype.name"},{section:"x15.11.4.3",name:"15.11.4.3 Error.prototype.message"},{section:"x15.11.4.4",name:"15.11.4.4 Error.prototype.toString ( )"},{section:"x15.11.5",name:"15.11.5 Properties of Error Instances"},{section:"x15.11.6",name:"15.11.6 Native Error Types Used in This Standard"},{section:"x15.11.6.1",name:"15.11.6.1 EvalError"},{section:"x15.11.6.2",name:"15.11.6.2 RangeError"},{section:"x15.11.6.3",name:"15.11.6.3 ReferenceError"},{section:"x15.11.6.4",name:"15.11.6.4 SyntaxError"},{section:"x15.11.6.5",name:"15.11.6.5 TypeError"},{section:"x15.11.6.6",name:"15.11.6.6 URIError"},{section:"x15.11.7",name:"15.11.7 NativeError Object Structure"},{section:"x15.11.7.1",name:"15.11.7.1 NativeError Constructors Called as Functions"},{section:"x15.11.7.2",name:"15.11.7.2 NativeError (message)"},{section:"x15.11.7.3",name:"15.11.7.3 The NativeError Constructors"},{section:"x15.11.7.4",name:"15.11.7.4 New NativeError (message)"},{section:"x15.11.7.5",name:"15.11.7.5 Properties of the NativeError Constructors"},{section:"x15.11.7.6", -name:"15.11.7.6 NativeError.prototype"},{section:"x15.11.7.7",name:"15.11.7.7 Properties of the NativeError Prototype Objects"},{section:"x15.11.7.8",name:"15.11.7.8 NativeError.prototype.constructor"},{section:"x15.11.7.9",name:"15.11.7.9 NativeError.prototype.name"},{section:"x15.11.7.10",name:"15.11.7.10 NativeError.prototype.message"},{section:"x15.11.7.11",name:"15.11.7.11 Properties of NativeError Instances"},{section:"x15.12",name:"15.12 The JSON Object"},{section:"x15.12.1",name:"15.12.1 The JSON Grammar "},{section:"x15.12.1.1",name:"15.12.1.1 The JSON Lexical Grammar"},{section:"x15.12.1.2",name:"15.12.1.2 The JSON Syntactic Grammar"},{section:"x15.12.2",name:"15.12.2 parse ( text [ , reviver ] )"},{section:"x15.12.3",name:"15.12.3 stringify ( value [ , replacer [ , space ] ] )"},{section:"x16",name:"16 Errors"},{section:"A",name:"Annex A (informative) Grammar Summary"},{section:"A.1",name:"A.1 Lexical Grammar"},{section:"A.2",name:"A.2 Number Conversions"},{section:"A.3",name:"A.3 Expressions"},{section:"A.4",name:"A.4 Statements"},{section:"A.5",name:"A.5 Functions and Programs"},{section:"A.6",name:"A.6 Universal Resource Identifier Character Classes"},{section:"A.7",name:"A.7 Regular Expressions"},{section:"A.8",name:"A.8 JSON"},{section:"A.8.1",name:"A.8.1 JSON Lexical Grammar"},{section:"A.8.2",name:"A.8.2 JSON Syntactic Grammar"},{section:"B",name:"Annex B (informative) Compatibility"},{section:"B.1",name:"B.1 Additional Syntax"},{section:"B.1.1",name:"B.1.1 Numeric Literals"},{section:"B.1.2",name:"B.1.2 String Literals"},{section:"B.2",name:"B.2 Additional Properties"},{section:"B.2.1",name:"B.2.1 escape (string)"},{section:"B.2.2",name:"B.2.2 unescape (string)"},{section:"B.2.3",name:"B.2.3 String.prototype.substr (start, length)"},{section:"B.2.4",name:"B.2.4 Date.prototype.getYear ( )"},{section:"B.2.5",name:"B.2.5 Date.prototype.setYear (year)"},{section:"B.2.6",name:"B.2.6 Date.prototype.toGMTString ( )"},{section:"C",name:"Annex C (informative) The Strict Mode of ECMAScript"},{section:"D",name:"Annex D (informative) Corrections and Clarifications in the 5th Edition with Possible 3rd Edition Compatibility Impact"},{section:"E",name:"Annex E (informative) Additions and Changes in the 5th Edition that Introduce Incompatibilities with the 3rd Edition"},{section:"bibliography",name:"Bibliography"}],bot.addCommand({name:"spec",fun:e,permissions:{del:"NONE"},description:"Find a section in the ES5 spec"})}(),function(){var e,t=/(which |what |give me a )?stargate|sg1( episode)?/i;e={SG1:{"Season 1":["Children of the Gods","The Enemy Within","Emancipation","The Broca Divide","The First Commandment","Brief Candle","Cold Lazarus","Thor's Hammer","The Torment of Tantalus","Bloodlines","Fire and Water","The Nox","Hathor","Singularity","Cor-ai","Enigma","Tin Man","Solitudes","There But for the Grace of God ","Politics ","Within the Serpent's Grasp "],"Season 2":["The Serpent's Lair ","In the Line of Duty","Prisoners","The Gamekeeper","Need","Thor's Chariot","Message in a Bottle","Family","Secrets","Bane","The Tok'ra","The Tok'ra (Part 2)","Spirits","Touchstone","A Matter of Time","The Fifth Race","Serpent's Song","Holiday","One False Step","Show and Tell","1969","Out of Mind "],"Season 3":["Into the Fire ","Seth","Fair Game","Legacy","Learning Curve","Point of View","Deadman Switch","Demons","Rules of Engagement","Forever in a Day","Past and Present","Jolinar's Memories ","The Devil You Know ","Foothold","Pretense","Urgo","A Hundred Days","Shades of Grey","New Ground","Maternal Instinct","Crystal Skull","Nemesis "],"Season 4":["Small Victories ","The Other Side","Upgrades","Crossroads","Divide and Conquer","Window of Opportunity","Watergate","The First Ones","Scorched Earth","Beneath the Surface","Point of No Return","Tangent","The Curse","The Serpent's Venom","Chain Reaction","2010","Absolute Power","The Light","Prodigy","Entity","Double Jeopardy ","Exodus "],"Season 5":["Enemies ","Threshold ","Ascension","The Fifth Man","Red Sky","Rite of Passage","Beast of Burden","The Tomb","Between Two Fires","2001","Desperate Measures","Wormhole X-Treme!","Proving Ground","48 Hours","Summit ","Last Stand ","Fail Safe","The Warrior","Menace","The Sentinel","Meridian","Revelations"],"Season 6":["Redemption","Redemption (Part 2)","Descent","Frozen","Nightwalkers","Abyss","Shadow Play","The Other Guys","Allegiance","Cure","Prometheus ","Unnatural Selection ","Sight Unseen","Smoke & Mirrors","Paradise Lost","Metamorphosis","Disclosure","Forsaken","The Changeling","Memento","Prophecy","Full Circle"],"Season 7":["Fallen ","Homecoming ","Fragile Balance","Orpheus","Revisions","Lifeboat","Enemy Mine","Space Race","Avenger 2.0","Birthright","Evolution","Evolution (Part 2)","Grace","Fallout","Chimera","Death Knell","Heroes","Heroes (Part 2)","Resurrection","Inauguration","Lost City","Lost City (Part 2)"],"Season 8":["New Order","New Order (Part 2)","Lockdown","Zero Hour","Icon","Avatar","Affinity","Covenant","Sacrifices","Endgame","Gemini","Prometheus Unbound","It's Good to Be King","Full Alert","Citizen Joe","Reckoning","Reckoning (Part 2)","Threads","Moebius","Moebius (Part 2)"],"Season 9":["Avalon","Avalon (Part 2)","Origin ","The Ties That Bind","The Powers That Be","Beachhead","Ex Deus Machina","Babylon","Prototype","The Fourth Horseman","The Fourth Horseman (Part 2)","Collateral Damage","Ripple Effect","Stronghold","Ethon","Off the Grid","The Scourge","Arthur's Mantle","Crusade","Camelot "],"Season 10":["Flesh and Blood ","Morpheus","The Pegasus Project","Insiders","Uninvited","200","Counterstrike","Memento Mori","Company of Thieves","The Quest","The Quest (Part 2)","Line in the Sand","The Road Not Taken","The Shroud","Bounty","Bad Guys","Talion","Family Ties","Dominion","Unending"]}};var n=function(t){if(-1===t.indexOf("episode")&&Math.random()<.05)return"Stargate (movie)";var n=function(e){var t=Math.rand(e.length-1);return{value:e[t],index:t}},o=n(Object.keys(e.SG1)),r=n(e.SG1[o.value]),i={season:o.value,index:r.index+1,episode:r.value};return"{season} episode #{index} - {episode}".supplant(i)};bot.listen(t,n)}(),function(){"use strict";function e(e,n){function o(n){if(n.error_message)return void r(n.error_message);var o,i=n.items[0];o=i?t(i,e):"User "+a+" not found",r(o)}function r(t){n?n(t):e.reply(t)}var i=e.parse(),a=i[0];return a?/^\d+$/.test(a)||(a=e.findUserId(i.length>1?a:i.join(" "))):a=e.get("user_id"),0>a?"User Elusio proved elusive.":Math.random()<=.1?void r("That dude sucks"):void IO.jsonp({url:"https://api.stackexchange.com/2.2/users/"+a,data:{site:bot.adapter.site,filter:"!P)usXx8OGi3Eq5LdDJke7ybvCSm_vuVGrSDZs3)UmEI"},fun:o})}function t(e,t){return e=n(e),e.user_id===t.get("user_id")?(e.display_name="You",e.indicative="have"):(e.display_name=IO.decodehtmlEntities(e.display_name),e.indicative="has"),r.supplant(e)}function n(e){return e=Object.merge({question_count:0,answer_count:0,reputation_change_day:0},e.badge_counts,e),e=Object.merge(e.badge_counts,e),e.avg_rep_post=(e.reputation/(e.question_count+e.answer_count)).maxDecimal(2),e.avg_rep_post===1/0&&(e.avg_rep_post="T͎͍̘͙̖̤̉̌̇̅ͯ͋͢͜͝H̖͙̗̗̺͚̱͕̒́͟E̫̺̯͖͎̗̒͑̅̈ ̈ͮ̽ͯ̆̋́͏͙͓͓͇̹<̩̟̳̫̪̇ͩ̑̆͗̽̇͆́ͅC̬͎ͪͩ̓̑͊ͮͪ̄̚̕Ě̯̰̤̗̜̗͓͛͝N̶̴̞͇̟̲̪̅̓ͯͅT͍̯̰͓̬͚̅͆̄E̠͇͇̬̬͕͖ͨ̔̓͞R͚̠̻̲̗̹̀>̇̏ͣ҉̳̖̟̫͕ ̧̛͈͙͇͂̓̚͡C͈̞̻̩̯̠̻ͥ̆͐̄ͦ́̀͟A̛̪̫͙̺̱̥̞̙ͦͧ̽͛̈́ͯ̅̍N̦̭͕̹̤͓͙̲̑͋̾͊ͣŅ̜̝͌͟O̡̝͍͚̲̝ͣ̔́͝Ť͈͢ ̪̘̳͔̂̒̋ͭ͆̽͠H̢͈̤͚̬̪̭͗ͧͬ̈́̈̀͌͒͡Ơ̮͍͇̝̰͍͚͖̿ͮ̀̍́L͐̆ͨ̏̎͡҉̧̱̯̤̹͓̗̻̭ͅḐ̲̰͙͑̂̒̐́̊"),e.ratio=o(e.question_count,e.answer_count),bot.log(e,"/stat normalized"),e}function o(e,t){if(!e&&t)return"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ";if(!t&&e)return"TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡";if(!t&&!e)return"http://i.imgur.com/F79hP.png";Math.gcd(e,t);return Math.ratio(e,t)}var r="{display_name} ({link}) {indicative} {reputation} reputation, earned {reputation_change_day} rep today, asked {question_count} questions, gave {answer_count} answers, for a q:a ratio of {ratio}.\navg. rep/post: {avg_rep_post}. Badges: {gold}g {silver}s {bronze}b ",i={name:"stat",fun:e,permissions:{del:"NONE"},description:"Gives useless stats on a user. `/stat usrid|usrname [extended]`",async:!0};bot.addCommand(i);var a=Object.merge(i,{name:"stats"});bot.addCommand(a)}(),function(){function e(e){var r=RegExp(e.matches[2],e.matches[4]),i=e.matches[3];if(!e.matches[2])return"Empty regex is empty";var a;a=e.matches[5]?Array.from(document.querySelectorAll("#message-"+e.matches[5]+" .content")):Array.from(document.getElementsByClassName("content")).reverse(),t(r,a,e.get("message_id"),function(t,a){function s(t){var n=t.replace(r,i)+" "+e.link("(source)",c);e.reply(n)}if(t)return void e.reply(t);if(!a)return void e.reply("No matching message (are you sure we're in the right room?)");bot.log(a,"substitution found message");var c=n(a);a.getElementsByClassName("partial").length?o(a,s):s(a.textContent)})}function t(e,t,n,o){bot.log(e,t,n,"substitution getMatchingMessage args");var r={maxId:n,pattern:e,messages:t.map(function(e){return{id:Number(e.parentElement.id.match(/\d+/)[0]),text:e.textContent}})},i=function(){var e=arguments[1],t=null;e.messages.some(function(n,o){return n.id-1?void this.removeMultiple(e.split(" "),n):void("~"===e[0]?this.byLookback(e.slice(1),n):"*"===e[0]||"x"===e[0]?this.byPrevious(e.slice(1),n):/^:?\d+$/.test(e)?this.remove(e.replace(/^:/,""),n):e.content?n("I'm not sure how to handle that, see `/help undo`"):this.ids.length?this.remove(this.ids[this.ids.length-1],n):n("I haven't said a thing!"))},removeMultiple:function(e,t){e.forEach(function(e){this.remove(e,t)},this)},byLookback:function(e,t){var n=Number(e.replace("~",""));return bot.log(e,n,this.ids.length-n,"/undo byLookback"),!n||n>this.ids.length?void t("I can't quite see that far back without my glasses"):void this.remove(this.ids[this.ids.length-n],t)},byPrevious:function(e,t){var n=Number(e);return n?this.removeMultiple(this.ids.slice(-e),t):void t("Yeah, no")},remove:function(t,n){function o(o,r){if(409===r.status)return bot.log(r,"/undo remove finish 409"),void e.retry(t,n,o);var i;'"ok"'!==o&&(i=/it is too late/i.test(o)?"TimeError: Could not reach 88mph":/only delete your own/i.test(o)?"I can only delete my own messages":"I have no idea what happened: "+o,n(i))}console.log(t,"/undo remove");var r=this.ids.indexOf(t);r>-1&&this.ids.splice(r,1),IO.xhr({url:"/messages/"+t+"/delete",data:fkey(),method:"POST",complete:o})},retry:function(e,t,n){var o=/(\d+) seconds\s*$/i.exec(n),r=4;o&&o[1]&&(r=Number(o[1])),setTimeout(this.remove.bind(this,e,t),1e3*r)},update_id:function(e){this.ids.push(JSON.parse(e.responseText).id)}};IO.register("sendoutput",e.update_id,e),bot.addCommand({name:"undo",fun:e.command,thisArg:e,permissions:{del:"NONE",use:"OWNER"},description:"Undo (delete) specified or last message. `/undo [msgid0, msgid1, ...]` (omit for last message); `/undo xN` for last N; `/undo ~N` for the Nth message from the end"})}(),function(){function e(e,n){var o=bot.users[e.user_id],r=e.message_id;bot.log("[formatting] Lecturing user "+e.user_name),bot.adapter.out.add(bot.adapter.reply(e.user_name)+" "+t(n)),o&&o.reputation<2e3&&(bot.log("[formatting] Binning offending message"),bot.adapter.moveMessage(r,e.room_id,23262))}function t(e){var t=e.split("\n").length,n="Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the {0}.".supplant(bot.adapter.link("faq","/faq"));return t>=10&&(n+=" For posting large code blocks, use a paste site like https://gist.github.com, http://hastebin.com or http://pastie.org"),n}function n(e){var t=e.split("\n");if(t.length<4)return!1;var n=/^\}|^<\//;return t.some(/ /.test.bind(n))}if("stackoverflow"!==bot.adapter.site||17!==bot.adapter.roomid)return void bot.log("Not activating unformatted code checking; not in right room/site");var o=new Map;IO.register("rawinput",function(t){function r(){o.has(i)&&(bot.log("[formatting] Message {0} was fixed".supplant(i)),clearTimeout(o.get(i)),o["delete"](i))}var i=t.message_id;if((1===t.event_type||2===t.event_type)&&17===t.room_id&&!bot.isOwner(t.user_id)){if(!t.content.startsWith("
"))return void r();var a=bot.adapter["in"].breakMultilineMessage(t.content).map(function(e){return e.replace(/^ /,"")}).join("\n");if(a=IO.decodehtmlEntities(a),a.startsWith("
"))return void r();var s=n(a);if(!s)return void r();bot.log("[formatting] Message {0} is a naughty one".supplant(i));var c=setTimeout(e,1e4,t,a);o.set(i,c)}})}(),function(){"use strict";var e="unonebox-state",t=9e4,n={enablers:Object.TruthMap(["yes","on","true","start","1","enable"]),disablers:Object.TruthMap(["no","off","false","stop","0","disable"]),command:function(t){var n,o=t.toLowerCase(),r=!1;o?this.enablers[o]?(bot.log("/unonebox enabling"),this.enable(),n="un-onebox enabled",r=!0):this.disablers[o]?(bot.log("/unonebox disabling"),this.disable(),n="un-onebox disabled",r=!0):(bot.log("/unonebox invalid input"),n="That didn't make much sense. Please use `on` or `off` to toggle the command"):(bot.log("/unonebox getting state"),n="Functionality is "+bot.memory.get(e,"disabled")),r&&bot.memory.save(e),t.reply(n)},enable:function(){IO.register("input",this.unbox),bot.memory.set(e,"enabled")},disable:function(){IO.unregister("input",this.unbox),bot.memory.set(e,"disabled")},unbox:function(e){if(e.user_id===bot.adapter.user_id){var o=document.createElement("div");o.innerHTML=e.content;var r=o.querySelector(".onebox:not(.ob-youtube):not(.ob-message):not(.ob-wikipedia) a");r&&!r.parentNode.parentNode.classList.contains("quote")&&(bot.log(e,"/unonebox found matching message"),setTimeout(function(){n.actuallyUnbox(e.message_id,r.href)},t))}},actuallyUnbox:function(e,t){IO.xhr({url:"/messages/"+e,data:fkey({text:t+" ... "}),method:"POST",complete:function(e,t){bot.log(t,"/unonebox done unboxing")}})}};"enabled"===bot.memory.get(e,"disabled")&&(bot.log("enabling unonebox"),n.enable()),bot.addCommand({name:"unonebox",fun:n.command,thisArg:n,permissions:{del:"NONE"},description:"Get/toggle the unonebox listener. `/unonebox [on|off]x`"})}(),function(){function e(e,n){function o(n){var o;o="no_results"===n.result_type?"No definition found for "+s:c>n.list.length?"Nothing in that index. The last one is:\n"+i(n.list.pop()):i(n.list[c]),o.length>500&&(o=o.slice(0,450)+"(snip)"),t[e]=o,r(o)}function r(t){n&&n.call?n(t):e.reply(t)}function i(t){var n=t.definition.replace(/\[([^\]]+)\]/g,a);return e.link(t.word,t.permalink)+" "+n}function a(t,n){var o="http://urbandictionary.com/define.php?term="+encodeURIComponent(n);return e.link(t,o)}if(t[e])return r(t[e]);var s,c,u=e.parse();return u.length?(isNaN(u[1])?(bot.log("/urban input isNaN"),s=e.toString(),c=0):(bot.log("/urban input isn't NaN"),s=u[0],c=Number(u[1])),bot.log(s,c,"/urban input"),void IO.jsonp({url:"http://api.urbandictionary.com/v0/define",data:{term:s},jsonpName:"callback",fun:o})):"Y U NO PROVIDE ARGUMENTS!?"}var t={};bot.addCommand({name:"urban",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches UrbanDictionary definition. `/urban query [resultIndex=0]`",async:!0})}(),bot.addCommand({name:"user",fun:function(){return"Command deprecated. If you want it to stay, ping Zirak."},permissions:{del:"NONE",use:"ALL"},description:"Fetches user-link for specified user. `/user usr_id|usr_name`"}),IO.register("input",function(e){1386886===e.user_id&&Math.random()<.005&&bot.adapter.out.add(bot.adapter.reply(e.user_name)+" The Game")}),function(){var e,t,n,o=/^\s*(choose|should)?.*\sor\s[^$]/i,r=new RegExp("\\b("+["am","are","can","could","did","do","does","is","may","might","shall","should","will","would"].map(RegExp.escape).join("|")+")\\b","i"),i={he:"He",i:"You",it:"It",she:"She",they:"They",we:"You",you:"I"};t=["SSdtIG5vdCBzdXJl","RVJST1IgQ0FMQ1VMQVRJTkcgUkVTVUxU","SSBrbm93IGp1c3Qgb25lIHRoaW5nLCBhbmQgdGhhdCBpcyB0aGF0IEknbSBhIGx1bWJlcmphY2s="].map(atob),n=["VGhhdCdzIG5vdCByZWFsbHkgYSBjaG9pY2UsIG5vdyBpcyBpdD8=","U291bmRzIGxpa2UgeW91IGhhdmUgYWxyZWFkeSBkZWNpZGVk","Q2hlYXRlciBjaGVhdGVyIHlvdXIgaG91c2UgaXMgYSBoZWF0ZXI="].map(atob),e=["QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5","Q2VydGFpbmx5","Q2VydGFpbmx5","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","SSBjYW4gbmVpdGhlciBjb25maXJtIG5vciBkZW55","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSdtIG5vdCBzbyBzdXJlIGFueW1vcmUuIEl0IGNhbiBnbyBlaXRoZXIgd2F5","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW5kZWVk","SW5kZWVk","SW5kZWVk","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","Tm8gd2F5","Tm8gd2F5","Tm8gd2F5","Tm8=","Tm8=","Tm8=","Tm8=","Tm9wZQ==","Tm9wZQ==","Tm9wZQ==","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","TnVoLXVo","TnVoLXVo","TnVoLXVo","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","UHJvYmFibHk=","UHJvYmFibHk=","UHJvYmFibHk=","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5"].map(atob),bot.listen(o,function(e){function o(){var t;do t=s.random();while(t===l);e.reply("Wait, I changed my mind! "+r(t))}function r(e){return e.replace(/(should(?:n'?t)?) (\S+)/,a)}function a(e,t,n){var o,r=n.toLowerCase();return o=i.hasOwnProperty(r)?i[r]:n,o+" "+t}for(var s=e.replace(/^\s*choose\s/i,"").replace(/\?$/,"").split(/\s*\bor\b\s*/i).filter(Boolean),c=s.length,u=1,m=!0;c>u;u++)if(s[u]!==s[u-1]){m=!1;break}if(m)return n.random();if(Math.random()<.01)return 2===c?"Both!":"All of them!";if(Math.random()<.01)return 2===c?"Neither":"None of them!";if(Math.random()<.01)return t.random();var l=s.random();return Math.random()<.01&&(bot.log("weasel decision mind change jedi nun-chuck"),setTimeout(o,1e4)),r(l)}),bot.listen(r,function(){return e.random()})}(),function(){"use strict";function e(e){var t=o.exec(e);if(t)n.latlon(t[1],t[2],e.reply.bind(e));else{if(!e.content)return"See `/help weather` for usage info";n.city(e.content,e.reply.bind(e))}}var t=Object.TruthMap(["US","United States of America","United States","BZ","Belize","BS","Bahamas","KY","Cayam Islands"]),n={latlon:function(e,t,n){var o=Number(e),r=Number(t),i=[];return(-180>o||o>180)&&i.push("Latitude must be between -180 and 180"),(-180>r||r>180)&&i.push("Longitude must be between -180 and 180"),i.length?void n(i.join("; ")):void IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{lat:e,lon:t,cnt:1,type:"json"},fun:this.finishCb(n),error:this.errorCb(n)})},city:function(e,t){IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{q:e,type:"json"},fun:this.finishCb(t),error:this.errorCb(t)})},finishCb:function(e){var t=this;return function(n){e(t.format(n))}},errorCb:function(e){return e},format:function(e){var t=e.main;return t?this.formatter(e):(console.error(e),"Sorry, I couldn't get the data: "+e.message)},formatter:function(e){var n,o=e.main;o.celsius=(o.temp-273.15).maxDecimal(4),n=bot.adapter.link(e.name,"http://openweathermap.org/city/"+e.id)+": ",t[e.sys.country]?(o.fahrenheit=(9*o.temp/5-459.67).maxDecimal(4),n+="{fahrenheit}F ({celsius}C, {temp}K)".supplant(o)):n+="{celsius}C ({temp}K)".supplant(o);var r=(e.weather||[]).map(function(e){return e.description}).join(", ");return r&&(n+=", "+r),n}},o=/\((-?\d+\.?\d*),\s*(-?\d+\.?\d*)\)/;bot.addCommand({name:"weather",fun:e,permissions:{del:"NONE"},async:!0,description:"Gets current weather: `/weather (lan, lon)` or `/weather city`"})}(),function(){"use strict";function e(e,t){bot.adapter.out.add(bot.adapter.reply(e)+" "+o,t)}var t=bot.memory.get("users"),n=17,o="Welcome to the JavaScript chat! Please review the "+bot.adapter.link("room pseudo-rules","http://rlemon.github.com/so-chat-javascript-rules/")+". Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.";IO.register("input",function(o){function r(t){var o,r=t.querySelector("#room-"+n+" .room-message-count");o=r?Number(/^\d+/.exec(r.title))<2:!0,o&&e(c.name,u),i()}function i(e){e?delete t[s]:t[s]=!0,bot.memory.save("users")}function a(e){return bot.isOwner(e.id)||e.reputation>1e3||e.reputation<20}var s=o.user_id,c=bot.users[o.user_id],u=o.room_id,m=c&&a(c);return Number(u)!==n||m||t[o.user_id]?void(m&&i(!0)):void IO.xhr({method:"GET",url:"/users/"+s,document:!0,complete:r})}),bot.addCommand({name:"welcome",fun:function(t){return t.length?void e(t,t.get("room_id")):o},permission:{del:"NONE"},description:"Welcomes a user. `/welcome user`"})}(),function(){"use strict";function e(e,t){function n(n){var o=n[3][0],r=!0;o||(r=!1,o=["No result found","The Wikipedia contains no knowledge of such a thing","The Gods of Wikipedia did not bless us"].random()),t&&t.call?t(o):r?e.directreply(o):e.reply(o)}IO.jsonp({url:"http://en.wikipedia.org/w/api.php",jsonpName:"callback",data:{action:"opensearch",search:e.toString(),limit:1,format:"json"},fun:n})}bot.addCommand({name:"wiki",fun:e,permissions:{del:"NONE"},description:"Search Wikipedia. `/wiki term`",async:!0})}(),function(){function e(e,t){function n(e){var t=e.num;i?"new"===i&&r(a+t):r(a+Math.rand(1,t))}function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results;if(!t.length)return void r("Seems like you hallucinated this comic");var n=t[0],o=n.url,i=/xkcd.com\/(\d+)/.exec(o);i||(o="Search didn't yield a comic; got "+n.unescapedUrl),r(o)}function r(n){bot.log(n,"/xkcd finish"),n=n.replace(/^https:/,"http:"),t&&t.call?t(n):e.directreply(n)}var i=(e.parse()[0]||"").toLowerCase(),a="http://xkcd.com/";return/^\d+$/.test(i)?(bot.log("/xkcd specific",i),void r(a+i)):i&&"new"!==i?(bot.log("/xkcd search",e.toString()),void IO.jsonp.google(e.toString()+" site:xkcd.com -forums.xkcd -m.xkcd -fora.xkcd",o)):(bot.log("/xkcd random/latest",i),void IO.jsonp({url:"http://dynamic.xkcd.com/api-0/jsonp/comic",jsonpName:"callback",fun:n}))}bot.addCommand({name:"xkcd",fun:e,permissions:{del:"NONE"},description:"Returns an XKCD. Call with no args for random, `new` for latest, or a number for a specific one.",async:!0})}(),function(){function e(e,n){function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var n=e.responseData.results[0];bot.log(n,"/youtube result"),r(n?decodeURIComponent(n.url):t.random())}function r(t){n&&n.call?n(t):e.directreply(t)}IO.jsonp.google(e.toString()+" site:youtube.com/watch",o)}var t=["Video not found (rule 35?)","I could not find such a video","The Lords of YouTube did not find your query favorable"];bot.addCommand({name:"youtube",fun:e,permissions:{del:"NONE"},description:"Search Youtube. `/youtube query`",async:!0})}(),function(){var e=function(e){var t,n,o,r=function(e){return Math.floor(Math.random()*e)},i=e.split(""),a=[0,1,2].random(),s=["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈́","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],c=["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],u=["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͏","͜","͝","͞","͟","͠","͢","̸","̷","͡","҉"],m="",l=0,d="A̪̗̐̿̄̔̉̏̾L̹͓̲̈́ͮL̜̼͓͉̞̘̩̇̊",p=i.length;1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2);var h;h="T̷̂͒̃̽H̸͒̿̒̚̕͜E͋ͥ̋̈̉̏̏̔̔͞ ̏ͥ̊͠P̷̑̌̀O̵̔̑̇̐͌̓̀̚Ǹ͌̍̾̈҉Y͛̈́̉҉͘";for(var l=0;p>l;l++){m+=i[l],d++,a||(t=r(8),n=r(8),o=r(6)),1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2),2==a&&(t=r(64)/4+3,n=r(64)/4+3,o=r(16)/4+1);for(var f=0;t>f;f++)m+=s.random();for(var f=0;o>f;f++)m+=u.random();for(var f=0;n>f;f++)m+=c.random()}return m||/<([a-z]+) *[^\/]*?>/};bot.addCommand({name:"zalgo",fun:e,permissions:{del:"NONE"},description:"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ http://stackoverflow.com/a/1732454/1216976"})}();
\ No newline at end of file
+var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(t.toString()):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var r=e[t];return Array.isArray(r)?n(t,r):o(t,r)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.htmlToMarkdown=function(){var e={i:"*",b:"**",strike:"---",code:"`",a:function(e,t,n){var o=/href="([^"]+?)"/.exec(e);return o?"["+n+"]("+o[1]+")":e}},t=/<(\S+)[^\>]*>([^<]+)<\/\1>/g;return function(n){function o(t,n,o){return e.hasOwnProperty(n)?(r=e[n],r.apply?e[n].apply(e,arguments):r+o+r):t}var r;return n.replace(t,o)}}(),IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",zwnj:"",zwsp:""};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return t?"#"===t[0]?r(t):e.hasOwnProperty(t)?e[t]:"&"+t+";":""},r=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.relativeUrlToAbsolute=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.href},IO.injectScript=function(e){var t=document.createElement("script");return t.src=e,document.head.appendChild(t),t},IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),e.document&&(t.responseType="document"),t.addEventListener("load",function(){e.complete.call(e.thisArg,t.response,t)}),Object.iterate(e.headers,t.setRequestHeader.bind(t)),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+="&"+this.urlstringify(e.data),n.onerror=e.error,n.src=e.url,document.head.appendChild(n)},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},Object.iterate=function(e,t,n){Object.keys(e).forEach(function(o){t.call(n,o,e[o],e)})},Object.TruthMap=function(e){function t(e,t){return e[t]=!0,e}return(e||[]).reduce(t,Object.create(null))},Array.from=function(e,t){return[].slice.call(e,t)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){function t(t){var o=t;return t[e]&&t[e].apply&&(o=t[e].apply(t,n)),o}var n=Array.from(arguments,1);return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"pluck",{value:function(e){function t(t){try{return t[e]}catch(n){return t}}return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"random",{value:function(){return this[Math.floor(Math.random()*this.length)]},configurable:!0,writable:!0}),["forEach","map","filter","reduce"].forEach(function(e){var t=[][e];Array[e]=function(){return t.call.apply(t,arguments)}}),String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.supplant=function(e){function t(e,t){return n.hasOwnProperty(t)?n[t]:e}var n=Object(e)===e?e:arguments;return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Function.prototype.throttle=function(e){var t=this,n=-1,o=function(){clearTimeout(n);var o=this,r=arguments;n=setTimeout(function(){t.apply(o,r)},e)};return o},Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this;return e=e||function(e){return e},function(){function o(){t[a]=arguments,i.apply(null,arguments)}var r=Array.from(arguments),i=r.pop(),a=e.apply(null,arguments);return a in t?void i.apply(null,t[a]):(r.push(o),void n.apply(this,r))}},Function.prototype.stringContents=function(){return this.toString().replace(/^function\*?\s+\([^)]*\)\s*\{/,"").replace(/\}$/,"")},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Number.prototype.fallsAfter=function(e){e=e.slice();for(var t,n=e.shift(),o=this.valueOf(),r=0,i=e.length;i>r&&(t=e[r],!(t>o));r++)n=t;return o>=n?n:null},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},Math.rand=function(e,t){return"undefined"==typeof e?(e=0,t=9):"undefined"==typeof t&&(t=e,e=0),Math.floor(Math.random()*(t-e+1))+e},Object.defineProperty(RegExp.prototype,"toJSON",{value:function(){return this.toString()},configurable:!0,writable:!0}),RegExp.escape=function(e){return e.replace(/[-^$\\\/\.*+?()[\]{}|]/g,"\\$&")},Date.timeSince=function(e,t){function n(e,t){return e=Math.floor(e),t+=1===e?"":"s",e+" "+t}t=t||new Date;for(var o,r=t-e,i=[{delta:31536e6,suffix:"year"},{delta:2592e6,suffix:"month"},{delta:864e5,suffix:"day"},{delta:36e5,suffix:"hour"},{delta:6e4,suffix:"minute"},{delta:1e3,suffix:"second"}];i.length;)if(o=i.shift(),r>=o.delta)return n(r/o.delta,o.suffix);return n(r,"millisecond")},function(){"use strict";var bot=window.bot={invocationPattern:"!!",commands:{},commandDictionary:null,listeners:[],info:{invoked:0,learned:0,forgotten:0,start:new Date},users:{},parseMessage:function(e){if(!this.validateMessage(e))return void bot.log(e,"parseMessage invalid");var t=this.prepareMessage(e),n=t.get("user_id");if(bot.log(t,"parseMessage valid"),this.banlist.contains(n))return bot.log(e,"parseMessage banned"),void(this.banlist[n].told||(t.reply("You iz in mindjail"),this.banlist[n].told=!0));try{/^c?>/.test(t)?this.prettyEval(t.toString(),t.directreply.bind(t)):this.invokeAction(t)}catch(o){var r="Could not process input. Error: "+o.message;o.lineNumber&&(r+=" on line "+o.lineNumber),o.column&&(r+=" on column "+o.column),t.directreply(r),console.error(o.stack)}finally{this.info.invoked+=1}},invokeAction:function(e){var t=e.trim().replace(/^\/\s*/,"").split(" ")[0],n=this.getCommand(t),o=e.startsWith("/")?!n.error:!0;n.error?o&&(o=this.callListeners(e)):this.execCommand(n,e),o||e.reply(this.giveUpMessage(n.guesses))},giveUpMessage:function(e){var t="That didn't make much sense.";return t+=e&&e.length?" Maybe you meant: "+e.join(", "):" Use the `!!/help` command to learn more."},execCommand:function(e,t){if(bot.log(e,"execCommand calling"),!e.canUse(t.get("user_id")))return void t.reply(["You do not have permission to use the command "+e.name,"I'm afraid I can't let you do that, "+t.get("user_name")].random());var n=this.Message(t.replace(/^\/\s*/,"").slice(e.name.length).trim(),t.get()),o=e.exec(n);o&&t.reply(o)},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.htmlToMarkdown(e.content);return t=IO.decodehtmlEntities(t),t=t.replace(/\u200b|\u200c/g,""),this.Message(t.slice(this.invocationPattern.length).trim(),e)},validateMessage:function(e){var t=e.content.trim();return"!!"===this.invocationPattern&&/^!!!+$/.test(t)?(console.log("special skip"),!1):e.user_id!==bot.adapter.user_id&&e.user_id>0&&t.startsWith(this.invocationPattern)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),e.learned&&(this.info.learned+=1),e.invoked=0,this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){var t=e.toLowerCase();if(this.commandExists(t))return this.commands[t];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var n="Command "+e+" does not exist.",o=this.commandDictionary.search(e);return o.length&&(n+=" Did you mean: "+o.join(", ")),{error:n,guesses:o}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(e){function t(t){var n,o=e.exec(t.pattern);return o?(n=t.fun.call(t.thisArg,e),bot.log(o,n),n&&e.reply(n),n!==!1):void 0}return this.listeners.some(t)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1},devMode:!1,activateDevMode:function(e){this.devMode=!0,this.invocationPattern=e||"beer!",IO.events.userjoin.length=0,this.validateMessage=function(e){return e.content.trim().startsWith(this.invocationPattern)}}};bot.memory={saveInterval:9e5,data:{},get:function(e,t){return this.data[e]||this.set(e,t||{}),this.data[e]},set:function(e,t){this.data[e]=t},loadAll:function(){var e=this;Object.iterate(localStorage,function(t,n){t.startsWith("bot_")&&(console.log(t,n),e.set(t.replace(/^bot_/,""),JSON.parse(n)))})},save:function(e){if(e)return void(localStorage["bot_"+e]=JSON.stringify(this.data[e]));var t=this;Object.keys(this.data).forEach(function(e){t.save(e)}),this.saveLoop()},saveLoop:function(){clearTimeout(this.saveIntervalId),setTimeout(this.saveLoop.bind(this),this.saveInterval)}},bot.memory.loadAll(),window.addEventListener("beforeunload",function(){bot.memory.save()}),bot.memory.saveLoop(),bot.banlist=bot.memory.get("ban"),bot.banlist.contains=function(e){return this.hasOwnProperty(e)},bot.banlist.add=function(e){this[e]={told:!1},bot.memory.save("ban")},bot.banlist.remove=function(e){this.contains(e)&&(delete this[e],bot.memory.save("ban"))},bot.Command=function(e){return e.name=e.name.toLowerCase(),e.thisArg=e.thisArg||e,e.permissions=e.permissions||{},e.permissions.use=e.permissions.use||"ALL",e.permissions.del=e.permissions.del||"NONE",e.description=e.description||"",e.creator=e.creator||"God",e.invoked=0,["Use","Del"].forEach(function(t){var n=t.toLowerCase();e["can"+t]=function(e){var t=this.permissions[n];return"ALL"===t?!0:"NONE"===t?!1:bot.isOwner(e)?!0:t.indexOf(e)>-1}}),e.exec=function(){return this.invoked+=1,this.fun.apply(this.thisArg,arguments)},e.del=function(){bot.info.forgotten+=1,delete bot.commands[e.name],bot.commandDictionary.trie.del(e.name)},e},bot.CommunityCommand=function(e,t){function n(e){if(s.call(r,e))return!1;o();var n=Object.keys(i).length,a=t-n;return bot.log(i,n,t),e in i?"Already registered; still need {0} more".supplant(a):(i[e]=new Date,a-=1,a>0?c.supplant(a):(bot.log("should execute"),!1))}function o(){function e(e,n){return e[n]500||t&&t.length>500)throw"Exception: too many items";return e.apply(this,arguments)}}(Array.prototype.join)});var exec=function(code,arg){return eval("undefined;\n"+code)},console={_items:[],log:function(){console._items.push.apply(console._items,arguments)}};console.error=console.info=console.debug=console.log,function(){global.onmessage=function(e){global.postMessage({event:"start"});var t,n=JSON.stringify,o=setTimeout,r=0,i=function(e){global.postMessage({answer:n(e,s),log:n(console._items,s).slice(1,-1)})},a=function(e){1>r&&i(e)},s=function(e,t){var n;return n=u(t)?""+t:t},c={Function:!0,Error:!0,Undefined:!0,RegExp:!0},u=function(e){var t={}.toString.call(e).slice(8,-1);return t in c?!0:e!==e||1/0===e};self.setTimeout=function(e){function t(){r-=1,e.apply(self,arguments),a()}if(e){var n=[].slice.call(arguments);n[0]=t,r+=1,o.apply(self,n)}};try{t=exec(e.data.code,e.data.arg)}catch(m){t=m.toString()}t&&t.then&&t["catch"]?t.then(a)["catch"](a):a(t)}}()}.stringContents(),blob=new Blob([workerCode],{type:"application/javascript"}),codeUrl=window.URL.createObjectURL(blob);return function(e,t,n){function o(){i||(i=window.setTimeout(function(){r("Maximum execution time exceeded")},500))}function r(e,t){clearTimeout(i),a.terminate(),n&&n.call?n(e,t):console.warn("eval did not get callback")}2===arguments.length&&(n=t,t=null);var i,a=new Worker(codeUrl);a.onmessage=function(e){bot.log(e,"eval worker.onmessage");var t=e.data.event;"start"===t?o():r(null,e.data)},a.onerror=function(e){bot.log(e,"eval worker.onerror"),r(e.message)},a.postMessage({code:e,arg:t})}}(),bot.prettyEval=function(e,t,n){function o(e,t){n(e?e:r(t))}function r(e){bot.log(e,"eval answerObj");var t,n=e.answer,o=e.log;return void 0===n?"Malformed output from web-worker. If you weren't just fooling around trying to break me, raise an issue or contact Zirak":(t=i(n),o&&o.length&&(t+=" Logged: "+i(o)),t)}function i(e){var t;return t=e.length>400?"`"+e.slice(0,400)+"` (snip)":"`"+e+"`"}return 2===arguments.length&&(n=t,t=null),e="c"===e[0]?CoffeeScript.compile(e.replace(/^c>/,""),{bare:1}):e.replace(/^>/,""),bot.eval(e,t,o)},function(){var e={create:function(){var e=Object.create(this);return e.separator=" ",e.escape="\\",e.quote='"',e},parse:function(e){this.source=e,this.pos=0;for(var t=[];!this.done();)t.push(this.nextArg());return t},nextArg:function(){var e=this.separator;return this.peek()===this.quote&&(this.nextChar(),e=this.quote),this.consumeUntil(e)},consumeUntil:function(e){for(var t=this.nextChar(),n=!1,o="";t&&t!==e;)t!==this.escape||n?o+=t:n=!0,t=this.nextChar();return o},nextChar:function(){var e=this.source[this.pos];return this.pos+=1,e},peek:function(){return this.source[this.pos]},done:function(){return this.pos>=this.source.length}},t=bot.commandArgsParser=e.create();bot.parseCommandArgs=t.parse.bind(t)}(),function(){var e={who:function(e){return e.get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=Array.filter(e,function(e){return Number(e.style.opacity)>=.5}).random();return t?t.getElementsByTagName("img")[0].title:"Nobody"},digit:function(){return Math.floor(10*Math.random())},encode:function(e,t){return encodeURIComponent(t)},rand:function(e,t,n){return t?n?(t=Number(t),n=Number(n)):(n=t,t=0):(t=0,n=10),Math.rand(t,n)}},t=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;bot.parseMacro=function n(o,r){function i(e,t,n){if(e.startsWith("$$"))return e.slice(1);var o="";"$"!==e[0]&&(o=e[0]);var r=s(t);return r?(bot.log(r,t,n,"/parse replaceMacro"),o+=r.apply?r.apply(null,a(n)):r):t}function a(e){if(bot.log(e,"/parse parseMacroArgs"),!e)return[o];var t=n(e,r);return[o].concat(t.split(",").invoke("trim"))}function s(t){function n(e){return e&&e.hasOwnProperty(t)}var o=[e,r].first(n);return(o||{})[t]}return o.replace(t,i)}}();var SuggestionDictionary=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=Number(n),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,r,i=[];for(void 0===t?(r=0,o=e):(r=e,o=t-r),n=0;o>n;++n)i[n]=r++;return i}function o(e,t,o){var i=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){r(o.children[n],n,e,a,i,t)}),i}function r(e,t,n,o,i,a){var s,c,u,m,l,d=n.length+1,p=[o[0]+1];for(s=1;d>s;++s)c=p[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],p.push(Math.min(c,u,m));l=p[p.length-1],a>=l&&null!==e.word&&i.push([e.word,l]),Math.min.apply(Math,p)<=a&&Object.keys(e.children).forEach(function(t){r(e.children[t],t,n,p,i,a)})}return e.prototype.add=function(t){for(var n,o=this,r=0;n=t.charAt(r++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},e.prototype.del=function(e,t){t=t||0;var n=this,o=e[t++];n.children[o]&&(n.children[o].del(e,t),0===Object.keys(n.children[o].children).length&&null===n.children[o].word&&delete n.children[o]),n.word===e&&(n.word=null)},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();bot.commandDictionary=new SuggestionDictionary(3),function(){var e={help:function(e){if(e&&e.length){var t=bot.getCommand(e.toLowerCase());if(t.error)return t.error;var n=t.description||"No info is available";return e+": "+n}return"Information on interacting with me can be found at [this page](https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot)"},listen:function(e){var t=bot.callListeners(e);return t?void 0:bot.giveUpMessage()},eval:function(e,t){return t=t||e.directreply.bind(e),bot.prettyEval(e,t)},coffee:function(t,n){var o=bot.Message("c> "+t,t.get());return e.eval(o,n)},refresh:function(){window.location.reload()},forget:function(e){var t=e.toLowerCase(),n=bot.getCommand(t);return n.error?n.error:n.canDel(e.get("user_id"))?(n.del(),"Command "+t+" forgotten."):"You are not authorized to delete the command "+e},info:function(e){function t(e){var t=bot.getCommand(e);if(t.error)return t.error;var n="Command {name}, created by {creator}".supplant(t);return t.date&&(n+=" on "+t.date.toUTCString()),n+=t.invoked?", invoked "+t.invoked+" times":" but hasn't been used yet"}function n(){var e="I awoke on {0} (that's about {1} ago)",t=r.start.toUTCString(),n=Date.timeSince(r.start);return e.supplant(t,n)}function o(){var e=[],t="";return r.invoked&&e.push("got invoked "+r.invoked+" times"),r.learned&&(t="but ",e.push("learned "+r.learned+" commands")),r.forgotten&&e.push(t+"forgotten "+r.forgotten+" commands"),Math.random()<.15&&e.push("teleported "+Math.rand(100)+" goats"),e.join(", ")||"haven't done anything yet!"}if(e.content)return t(e.content);var r=bot.info;return n()+", "+o()}};e.listcommands=function(){var e=function(e,t){var n=0,o=[],r=e.reduce(function(e,r){var i=r.length+2;return n+i>t&&(e.push(o),o=[],n=0),o.push(r),n+=i,e},[]);return o.length&&r.push(o),r};return function(t){var n=Object.keys(bot.commands),o=t.get("user_name"),r=498-o.length,i=e(n,r);return i.invoke("join",", ").join("\n")}}(),e.eval.async=e.coffee.async=!0,e.tell=function(e){function t(e){e&&(a?l(e):m(e))}var n=e.split(" ");bot.log(e.valueOf(),n,"/tell input");var o,r=n[0],i=n[1];if(!r||!i)return"Invalid /tell arguments. Use /help for usage info";if(i=i.toLowerCase(),o=bot.getCommand(i),o.error)return o.error+" (note that /tell works on commands, it's not an echo.)";if(o.unTellable)return"Command "+i+" cannot be used in `/tell`.";if(!o.canUse(e.get("user_id")))return"You do not have permission to use command "+i;if(/^@/.test(r))return"Don't be annoying, drop the @, nobody likes a double-ping.";var a=!1,s={};/^:?\d+$/.test(r)?(s.message_id=r.replace(/^:/,""),a=!0):s.user_name=r;var c=Object.merge(e.get(),s),u=bot.Message(n.slice(2).join(" "),c),m=u.reply.bind(u),l=u.directreply.bind(u);u.reply=u.directreply=u.send=t,bot.log(u,"/tell calling "+i),o.async?o.exec(u,t):t(o.exec(u))};var t={eval:"Forwards message to javascript code-eval",coffee:"Forwards message to coffeescript code-eval",forget:"Forgets a given command. `/forget cmdName`",help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",info:"Grabs some stats on my current instance or a command. `/info [cmdName]`",listcommands:"Lists commands. `/listcommands`",listen:"Forwards the message to my ears (as if called without the /)",refresh:"Reloads the browser window I live in",tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`"},n={die:!0,live:!0,ban:!0,unban:!0,refresh:!0},o={die:!0,ban:!0},r={tell:!0,forget:!0};Object.iterate(e,function(e,i){var a={name:e,fun:i,permissions:{del:"NONE",use:n[e]?"OWNER":"ALL"},description:t[e],pendingMessage:i.pendingMessage,unTellable:r[e],async:i.async};o[e]&&(a=bot.CommunityCommand(a,i.invokeReq)),bot.addCommand(a)})}(),function(){bot.listen(/^help(?: (\S+))?/,function(e){return bot.getCommand("help").exec(e.matches[1])});var e=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t){return t+". "+e}).join("\n");bot.listen(/^tell (me (your|the) )?(rule|law)s/,function(){return e}),bot.listen(/^give (.+?) a lick/,function(e){var t,n=e.matches[1];return"me"===n?(n="you",t=""):"yourself"===n?(n="I",t=""):t="s","Mmmm! "+n+" taste"+t+" just like raisin"});var t=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];bot.listen(t,function(e){var t=e.matches[1],n=bot.getCommand("define");n.exec(t,function(n){n=n.replace(t+":",""),e.reply(n)})})}()}(),function(){"use strict";var e="[{text}]({url})";bot.adapter={roomid:null,fkey:null,site:null,user_id:null,maxLineLength:500,init:function(){var e=document.getElementById("fkey");return e?(this.fkey=e.value,this.roomid=Number(/\d+/.exec(location)[0]),this.site=this.getCurrentSite(),this.user_id=CHAT.CURRENT_USER_ID,this["in"].init(),void this.out.init()):void console.error("bot.adapter could not find fkey; aborting")},getCurrentSite:function(){var e=/chat\.(\w+)/.exec(location)[1];if("stackexchange"!==e)return e;var t=document.getElementById("siterooms").href;return e=/host=(.+?)\./.exec(t)[1]},transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e){return"@"+e.replace(/\s/g,"")},directreply:function(e){return":"+e},codify:function(e){var t="    ",n=e.replace("	",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})},moveMessage:function(e,t,n,o){IO.xhr({method:"POST",url:"/admin/movePosts/"+t,data:{fkey:bot.adapter.fkey,to:n,ids:e},finish:o||function(){}})}};var t=bot.adapter["in"]={times:{},firstPoll:!0,interval:5e3,init:function(e){function t(e){e=JSON.parse(e),bot.log(e),n.openSocket(e.url,o)}var n=this,o=void 0!==e;e=e||bot.adapter.roomid,IO.xhr({url:"/ws-auth",data:fkey({roomid:e}),method:"POST",complete:t})},initialPoll:function(){function e(e){e=JSON.parse(e),bot.log(e),n.times["r"+t]=e.time,n.firstPoll=!1}bot.log("adapter: initial poll");var t=bot.adapter.roomid,n=this;IO.xhr({url:"/chats/"+t+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},openSocket:function(e,t){var n;if("undefined"!=typeof window.__stackexchangeChatSavedSocket){var o=window.__stackexchangeChatSavedSocket;console.assert(o.constructor===window.WebSocket),console.assert(o.url.startsWith("wss://chat.sockets.stackexchange.com")),n=o}else if(n=new WebSocket(e+"?l=99999999999"),t)return void(n.onmessage=function(){n.close()});this.socket=n,n.addEventListener("message",this.ondata.bind(this)),n.addEventListener("close",this.socketFail.bind(this))},ondata:function(e){this.pollComplete(e.data)},poll:function(){if(this.firstPoll)return void this.initialPoll();var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){e&&(e=JSON.parse(e),Object.iterate(e,function(e,t){t.t&&(this.times[e]=t.t),t.e&&t.e.forEach(this.handleMessageObject,this)},this),IO["in"].flush())},handleMessageObject:function(e){IO.fire("rawinput",e);var t=e.event_type;if(3===t||4===t)return void this.handleUserEvent(e);if(1===t||2===t)return e.content.startsWith("
")?void this.handleMultilineMessage(e):void IO["in"].receive(e)},handleMultilineMessage:function(e){this.breakMultilineMessage(e.content).forEach(function(t){var n=Object.merge(e,{content:t.trim()});IO["in"].receive(n)})},breakMultilineMessage:function(e){var t=e.slice(0,e.lastIndexOf("
")).replace("
","");return t.split("
")},handleUserEvent:function(e){var t=e.event_type;3===t?IO.fire("userjoin",e):4===t&&IO.fire("userleave",e)},leaveRoom:function(e,t){return e===bot.adapter.roomid?void t("base_room"):void IO.xhr({method:"POST",url:"/chats/leave/"+e,data:fkey({quiet:!0}),complete:function(){t()}})},socketFail:function(){bot.log("adapter: socket failed",this),this.socket.close(),this.socket=null,this.loopage()},loopage:function(){if(!this.socket){var e=this;setTimeout(function(){e.poll(),e.loopage()},this.interval)}}},n=bot.adapter.out={409:0,total:0,interval:t.interval+500,flushWait:500,init:function(){},add:function(e,t){IO.out.receive({text:e+"\n",room:t||bot.adapter.roomid}),IO.out.flush()},send:function(e){bot.stopped||setTimeout(function(){n.sendToRoom(e.text,e.room)},this.flushWait)},sendToRoom:function(e,t){function o(o,i){bot.log(i.status),409===i.status?(n[409]+=1,r(e,t)):500===i.status?n.add("Server error (status 500) occured (message probably too long)",t):200!==i.status?(console.error(i),n.add("Error "+i.status+" occured, I will call the maid (@Zirak)")):(n.total+=1,IO.fire("sendoutput",i,e,t))}function r(){setTimeout(function(){n.add(e,t)},n.interval)}IO.xhr({url:"/chats/"+t+"/messages/new",data:{text:e,fkey:fkey().fkey},method:"POST",complete:o})}};IO.register("output",n.send,n),bot.adapter.init()}(),function(){"use strict";function e(e,t,n){function o(e){e=JSON.parse(e),e.users.forEach(r)}function r(e){bot.users[e.id]=e,n(e)}Array.isArray(t)||(t=[t]),t.length&&IO.xhr({method:"POST",url:"/user/info",data:{ids:t.join(),roomId:e||bot.adapter.roomid},complete:o})}function t(){CHAT.RoomUsers.all().forEach(function(e){bot.users[e.id]=e})}bot.users={}; +var n=[],o=function(e,t){n.push(e.user_id),r(t)};IO.register("userjoin",function(e){function t(t){IO.fire("userregister",t,e.room_id)}bot.log(e,"userjoin");var n=bot.users[e.user_id];n?t(n):o(e,t)});var r=function(t){bot.log(n,"user addInfos"),e(null,n,t),n=[]}.throttle(1e3);bot.users.request=e,bot.users.findUserId=function(e){function t(t){return n(bot.users[t].name)===e}function n(e){return e.toLowerCase().replace(/\s/g,"")}var o=Object.keys(bot.users);return e=n(e),o.first(t)||-1}.memoize(),bot.users.findUsername=function(){var e={};return function(t,n){function o(e){r(e.name)}function r(o){n(e[t]=o)}e[t]?r(e[t]):bot.users[t]?r(bot.users[t].name):bot.users.request(bot.adapter.roomid,t,o)}}(),t()}(),bot.personality={bitchiness:0,thanks:{0:["You kiss-ass","Most welcome"],.5:["Thank you for noticing","teehee"],1:["Took you long enough","My pleasure","Don't mention it"]},apologies:{0:["What for?"],.5:["It was nothing...","No worries"],1:["You're forgiven. For now. Don't push it."]},stuff:{0:["Life is just *perfect*","What's there to bitch about, as long as I have *you*..."],1:["Oh don't mind me, that isn't difficult at all..."],1.2:["You don't appreciate me enough. Not that I need to be thanked.."],1.3:['The occasional "thanks" or "I\'m sorry" would be nice...'],2:["*sigh* Remember laughter? I don't. You ripped it out of me. Heartless bastard."]},insanity:{},okayCommands:{hangman:!0,help:!0,info:!0},check:function(e){return!this.okayCommands.hasOwnProperty(e)},bitch:function(){return this.getResp(this.stuff)},command:function(){this.bitchiness+=this.getDB()},thank:function(){return this.unbitch(this.thanks)},apologize:function(){return this.unbitch(this.apologies)},unbitch:function(e,t){var n=this.getResp(e);return this.bitchiness-=t||this.bitchiness,n},getResp:function(e){return e[this.bitchiness.fallsAfter(Object.keys(e).map(Number).sort())].random()},isABitch:function(){return this.bitchiness>=1},looksLikeABitch:function(){return!1},getDB:function(){return this.isThatTimeOfTheMonth()?.075:.025},isThatTimeOfTheMonth:function(){var e=(new Date).getDate();return 2>e||e>27}},bot.listen(/thank(s| you)/i,bot.personality.thank,bot.personality),bot.listen(/(I('m| am))?\s*sorry/i,bot.personality.apologize,bot.personality),bot.listen(/^bitch/i,bot.personality.bitch,bot.personality),function(){var e={STOP:"HAMMERTIME!",STAHP:"HAMMAHTIME!",HALT:"HAMMERZEIT!",STOY:"ZABIVAT' VREMYA!",SISTITE:"MALLEUS TEMPUS!"},t=new RegExp("("+Object.keys(e).map(RegExp.escape).join("|")+")[\\.!?]?$");IO.register("input",function(n){var o=n.content.toUpperCase(),r=t.exec(o);r&&bot.adapter.out.add(e[r[1]],n.room_id)})}(),function(){"use strict";var e=bot.memory.get("afk"),t=3e5,n=12e4,o=[{outgoing:"Why are you leaving me!?",incoming:["Welcome back!","Where were you!?","You saw that whore again, didn't you!?"]},{outgoing:"Just go already!",incoming:["Oh, it's you again...","Look at what the cat dragged in...","You've got some balls, coming back here after what you did."]},{outgoing:"Nobody cares.",incoming:["I already told you, nobody cares.","There goes the neighbourhood."]},{outgoing:"Hurry back, ok?",incoming:["I thought you'd never come back!","It's been 20 years. You can't just waltz back into my life like this."]},{outgoing:"Stay safe.",incoming:["Were you bitten!? Strip! Prove you weren't bitten."]},{outgoing:"Can you pick up some milk on your way back?",incoming:["Where's the milk?","Turns out I already have milk. Oops."]},{outgoing:"Apricots are people too!",incoming:["You taste just like raisin.","I am a banana!","My spoon is too big!","BROOOOOOOOOOOO."]}],r=function(o,r){function i(){var e="{user} is afk{sep}{rest}",t={user:o,sep:".",rest:""};return s.msg&&(t.sep=": ",t.rest=s.msg),e.supplant(t)}function a(){var e=s.lastPing[c];return u-s.afkSince>=n&&(!e||u-e>=t)}var s=e[o],c=r.get("room_id"),u=Date.now();a()&&(r.directreply(i()),s.lastPing[c]=u,bot.memory.save("afk"))},i=function(t,n,o){var r=!1;bot.log("/afk goAFK ",t),0===n.indexOf("!")&&(n=n.substring(1),r=!0),e[t]={afkSince:Date.now(),lastPing:{},msg:n.trim(),returnMsg:o},r&&(e[t].noReturn=1)},a=function(t){bot.log("/afk clearAFK",t),delete e[t]},s=function(t){var n,r,s=t.get("user_name").replace(/\s/g,""),c=t.content;bot.log("/afk input",s,c),e.hasOwnProperty(s)?(n=e[s].returnMsg,a(s)):(r=o.random(),n=r.outgoing,i(s,c,r.incoming.random())),bot.memory.save("afk")};bot.addCommand({name:"afk",fun:s,permissions:{del:"NONE"},description:"Set an afk message: `/afk `. Invoke `/afk` again to return.",unTellable:!0}),IO.register("input",function(t){function o(){var t=new RegExp("^"+RegExp.escape(bot.invocationPattern)+"\\s*/?\\s*AFK");return e.hasOwnProperty(c)&&!t.test(i)&&u-e[c].afkSince>=n}var i=t.content.toUpperCase(),a=bot.prepareMessage(t),c=t.user_name.replace(/\s/g,""),u=Date.now();t.user_id!==bot.adapter.user_id&&(o()&&(bot.log("/afk he returned!",t),s(a)),i.indexOf("@")<0||Object.keys(e).forEach(function(e){var t=new RegExp("(^|\b)"+RegExp.escape("@"+e)+"\\b","i");t.test(i)&&(bot.log("/afk responding for "+e),r(e,a))}))})}(),function(){"use strict";var e={added:0,0:"{0} added to mindjail.",notFound:1,1:"I couldn't find {0}.",owner:2,2:"I can't mindjail {0}, they're an owner.",alreadyIn:3,3:"{0} is already in mindjail.",notIn:4,4:"{0} isn't in mindjail.",freed:5,5:"{0} freed from mindjail!"},t={name:"ban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){if(!t)return Object.keys(bot.banlist).filter(Number);var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/ban argument"),0>o?n=e.notFound:bot.isOwner(o)?n=e.owner:bot.banlist.contains(o)?n=e.alreadyIn:(bot.banlist.add(o),n=e.added),{code:n,usrid:t}},format:function(t){return Array.isArray(t)?t.map(this.formatUser).join(", ")||"Nothing to show.":e[t.code].supplant(t.usrid)},formatUser:function(e){var t=bot.users[e],n=t?t.name:"?";return"{0} ({1})".supplant(e,n)},permissions:{del:"NONE",use:"OWNER"},description:"Bans a user from using me. Lacking arguments, prints the ban list. `/ban [usr_id|usr_name]`",pendingMessage:"The user will be thrown into mindjail in {0} more invocations"},n={name:"unban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/unban argument"),0>o?n=e.notFound:bot.banlist.contains(o)?(bot.banlist.remove(o),n=e.freed):n=e.notIn,{code:n,usrid:t}},format:function(t){return e[t.code].supplant(t.usrid)},permissions:{del:"NONE",use:"OWNER"},description:"Frees a user from my mindjail. `/unban usr_id|usr_name`"};bot.addCommand(bot.CommunityCommand(t)),bot.addCommand(n)}(),function(){"use strict";function e(e){var t=e.toUpperCase();return r.hasOwnProperty(t)?r[t]:a.hasOwnProperty(e)?a[e]:e}function t(e,t,n){bot.log(e,t,"/convert unit broken"),n(i[t]?i[t](e):{error:"Confuse converter with "+t+", receive error message"})}function n(){return Object.keys(i)}var o,r,i={C:function(e){return{F:1.8*e+32,K:e+273.15}},F:function(e){return{C:(e-32)/1.8,K:5*(e+459.67)/9}},K:function(e){return 0>e?{C:0,F:0}:{C:e-273.15,F:1.8*e-459.67}},m:function(e){return{f:3.280839895*e}},f:function(e){return{m:e/3.28083989}},km:function(e){return i.m(1e3*e)},cm:function(e){return i.m(e/100)},mm:function(e){return i.m(e/1e3)},i:function(e){return i.f(e/12)},d:function(e){return{r:e*Math.PI/180}},r:function(e){return{d:180*e/Math.PI}},g:function(e){return{lb:.0022*e,st:157473e-9*e}},lb:function(e){return{g:453.592*e,st:.0714286*e}},st:function(e){return{g:6350.29*e,lb:14*e}},kg:function(e){return i.g(1e3*e)}},a={lbs:"lb",ft:"f",foot:"f",metres:"m",millimetres:"mm",killometres:"km",degrees:"d",radians:"r",grams:"g",kilograms:"kg",inches:"i",stones:"st"};o={AED:!0,ANG:!0,ARS:!0,AUD:!0,BDT:!0,BGN:!0,BHD:!0,BND:!0,BOB:!0,BRL:!0,BWP:!0,CAD:!0,CHF:!0,CLP:!0,CNY:!0,COP:!0,CRC:!0,CZK:!0,DKK:!0,DOP:!0,DZD:!0,EEK:!0,EGP:!0,EUR:!0,FJD:!0,GBP:!0,HKD:!0,HNL:!0,HRK:!0,HUF:!0,IDR:!0,ILS:!0,INR:!0,JMD:!0,JOD:!0,JPY:!0,KES:!0,KRW:!0,KWD:!0,KYD:!0,KZT:!0,LBP:!0,LKR:!0,LTL:!0,LVL:!0,MAD:!0,MDL:!0,MKD:!0,MUR:!0,MVR:!0,MXN:!0,MYR:!0,NAD:!0,NGN:!0,NIO:!0,NIS:!0,NOK:!0,NPR:!0,NZD:!0,OMR:!0,PEN:!0,PGK:!0,PHP:!0,PKR:!0,PLN:!0,PYG:!0,QAR:!0,RON:!0,RSD:!0,RUB:!0,SAR:!0,SCR:!0,SEK:!0,SGD:!0,SKK:!0,SLL:!0,SVC:!0,THB:!0,TND:!0,TRY:!0,TTD:!0,TWD:!0,TZS:!0,UAH:!0,UGX:!0,USD:!0,UYU:!0,UZS:!0,VEF:!0,VND:!0,XOF:!0,YER:!0,ZAR:!0,ZMK:!0},r={"€":"EUR","£":"GBP","₤":"GBP","₨":"INR","₹":"INR","¥":"JPY","¥":"JPY","₪":"ILS",$:"USD"};var s=/(-?\d+\.?\d*)\s*(\S+)(\s+(?:(?:to|in)\s+)?(\S+))?$/,c=function(r,i){function a(e){bot.log(e,"/convert answer");var t;t=e.substr?e:e.error?e.error:c(e),i&&i.call?i(t):r.reply(t)}function c(e){function t(e){return!p||p===e}function n(t){return e[t].maxDecimal(4)+t}var o=Object.keys(e);return o.length?o.filter(t).map(n).join(", "):"Could not convert {0} to {1}".supplant(d,p)}if("list"===r.toLowerCase())return void a(n().join(", "));var m=s.exec(r);if(!m)return void a({error:"Unidentified format; please see `/help convert`"});var l=Number(m[1]),d=m[2],p=m[4]||"",h=!1;bot.log(l,d,p,"/convert input"),d=e(d),p=e(p),o[d.toUpperCase()]&&(h=!0),h?u.convert(l,d,p,a):t(l,d,a)},u={ratesCache:{},convert:function(e,t,n,o){this.from=t,this.to=n,this.upFrom=t.toUpperCase(),this.upTo=n.toUpperCase();var r=this.errorMessage();return r?void o({error:r}):(bot.log(e,t,n,"/convert money broken"),void this.getRate(function(t){var r={};r[n]=e*t,o(r)}))},getRate:function(e){function t(t){o=t.rate,n.updateCache(o),e(o)}var n=this,o=this.checkCache();return o?void e(o):void IO.jsonp({url:"http://rate-exchange.appspot.com/currency",jsonpName:"callback",data:{from:n.from,to:n.to},fun:t})},updateCache:function(e){this.ratesCache[this.upFrom]=this.ratesCache[this.upFrom]||{},this.ratesCache[this.upFrom][this.upTo]={rate:e,time:Date.now()}},checkCache:function(){var e,t=Date.now(),n=this.ratesCache[this.upFrom]&&(e=this.ratesCache[this.upFrom][this.upTo])&&e.time-t<=18e6;return console.log(this.ratesCache,n),n?e.rate:!1},errorMessage:function(){return this.to?o[this.upTo]?void 0:this.to+" aint no currency I ever heard of":"What do you want to convert "+this.from+" to?"}};bot.addCommand({name:"convert",fun:c,permissions:{del:"NONE"},description:"Converts several units and currencies, case sensitive. `/convert [to|in ]` Pass in list for supported units `/convert list`",async:!0})}();var cowsay=function(){"use strict";function e(e,t){function n(e,n){var r=n.length;return o+r>t&&(e+="\n",o=0),o+=r+1,e+n+" "}var o=0;return e.split(" ").reduce(n,"")}function t(e,t,n){return n=n||" ",(e+Array(t).join(n)).slice(0,t)}var n={defaults:{e:"oo",T:" ",t:!1,W:40},cow:[""," L ^__^"," L (e)\\_______"," (__)\\ )\\/\\"," T ||----w |"," || ||"].join("\n"),moo:function(n,o){var r=this.defaults;return this.eyes=t(o.e||r.e,2).slice(0,2),this.tongue=t(o.T||r.T,2).slice(0,2),this.line=o.t?"O":"\\",this.thinking=o.t,this.message=e(n,o.W||r.W).trim(),this.makeBalloon()+this.makeCow()},makeCow:function(){return this.cow.replace(/e/g,this.eyes).replace(/T/g,this.tongue).replace(/L/g,this.line)},makeBalloon:function(){function e(e,n){var o;return o=0===n?a.slice(0,2):n===i-1?a.slice(2,4):a.slice(2),o[0]+" "+t(e,r)+" "+o[1]}function n(e,t){return t.length>e?t.length:e}var o=this.message.split("\n"),r=o.reduce(n,0),i=o.length,a=this.chooseBorders(i),s=o.map(e),c=new Array(r+2);return s.unshift(" "+c.join("_")),s.push(" "+c.join("-")),s.join("\n")},chooseBorders:function(e){var t;return t=this.thinking?["(",")","(",")","(",")"]:1===e?["<",">"]:["/","\\","\\","/","|","|"]}};return n}();bot.listen(/cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/,function(e){function t(e){for(var t={},n=0,o=e.length;o>n;n+=2)e[n]&&e[n+1]&&(t[e[n]]=e[n+1]);return t}var n=t(e.matches.slice(2,-1));n.t="think"===e.matches[1],bot.log(n,"cowsay opts");var o=cowsay.moo(e.matches.pop(),n);e.send(e.codify(o))}),function(){"use strict";var e=["No definition found.","It means I aint got time to learn your $5 words.","My pocket dictionary just isn't good enough for you."],t="http://en.wiktionary.org",n=/(alternative (spelling|term)|common misspelling|informal form|archaic spelling) (of|for) (.+?)\.?$/i,o={command:function(n,o){function r(r){bot.log(r,"/define result");var i,a=r.pageid;i=0>a?e.random():bot.adapter.link(r.name,t+"/wiki?curid="+a)+" "+r.text,r.overflow&&(i="Index too large; showing last definition. "+i),o&&o.call?o(i):n.reply(i)}var i=n.parse(),a=Number(i.pop()),s=i.join(" ");a||(a=0,s=n.toString()),bot.log(n,s,a,"/define input");this.fetchDefinition(s,a,r)},fetchDefinition:function(e,t,n){function o(e){var i=e.query,a=i.pageids[0],s=i.pages[a],c=s.extract;if("-1"===a)return void n({pageid:-1});var u=document.createElement("body");u.innerHTML=c;var m=r.extractDefinitions(u),l=m[0],d=!1;return bot.log(m,"/define got definitions"),l.alternative?(bot.log(l.alternative,"/define found alternative"),void r.fetchData(l.alternative,o)):(l=m[t],l||(l=m[m.length-1],d=!0),void n({name:s.title,text:l.text,pageid:a,overflow:d}))}var r=this;this.fetchData(e,o)},extractDefinitions:function(e){var t=e.getElementsByTagName("ol")[0];return console.log(t,"/define definition list"),Array.from(t.children).map(this.extractSingleDefinition,this)},extractSingleDefinition:function(e){function n(e){var n=t+e.getAttribute("href"),o=bot.adapter.link(e.textContent,n),r=document.createTextNode(o);e.parentNode.replaceChild(r,e)}var o=this.extractAlternative(e.textContent);Array.from(e.children).forEach(function(t){"UL"===t.tagName&&e.removeChild(t)});for(var r=e.getElementsByTagName("a");r.length;)n(r[0]);return{alternative:o,text:e.textContent}},extractAlternative:function(e){return(n.exec(e)||[]).pop()},fetchData:function(e,t){var n=this;IO.jsonp({url:"http://en.wiktionary.org/w/api.php",jsonpName:"callback",data:{action:"query",titles:e,format:"json",prop:"extracts",indexpageids:!0},fun:function(e){t.call(n,e)}})}};bot.addCommand({name:"define",fun:o.command,thisArg:o,permissions:{del:"NONE"},description:"Fetches definition for a given word. `/define something`",async:!0})}(),function(){"use strict";function e(e,t){t+=2*Math.random()*r.jitter-r.jitter;for(var n=0;t>n;n++)e=" "+e;return e}function t(e){return" "+e+"\r"}function n(e){return e.sort(function(){return Math.random()-.5})}function o(o){for(var i=(o.length>0?o.toString():r.message).split(","),a=n(r.words.slice(0)),s=t(e("wow",4+4*Math.random()|0));i.length>a.length;)a=a.concat(n(r.words.slice(0)));for(;i.length;){var c="";a.length&&(c+=a.shift()+" "),c+=i.shift(),s+=t(e(c,r.spaces[i.length%3-1]))}o.send(s+"\r ")}var r={message:"fail,user,pro",spaces:[25,14,1],jitter:4,words:["so","very","such","much","many"]};bot.addCommand({fun:o,name:"doge",permissions:{del:"NONE"},description:"so shibe, much doge, wow `/doge one,two,three[,nth]",unTellable:!0})}(),bot.listen(/(which |what |give me a )?firefly( episode)?/i,function(e){var t=["Serenity","The Train Job","Bushwhacked","Shindig","Safe","Our Mrs. Reynolds","Jaynestown","Out of Gas","Ariel","War Stories","Trash","The Message","Heart of Gold","Objects in Space"];if(-1===e.indexOf("episode")&&Math.random()<.05)return"Serenity (movie)";var n=Math.floor(14*Math.random());return"Episode {0} - {1}".supplant(n+1,t[n])}),function(){var e=["The Google contains no such knowledge","There are no search results. Run.","My Google Fu has failed."],t={name:"google",fun:function(e,t){function n(n){var r=o.format(n);t&&t.call?t(r):e.directreply(r)}var o=this;this.logic(e,n)},logic:function(e,t){function n(n){if(bot.log(n,"/google response"),200!==n.responseStatus)return void finish("My Google-Fu is on vacation; status "+n.responseStatus);var o=n.responseData.results.slice(0,3);o.query=e,bot.log(o,"/google results"),t(o)}IO.jsonp.google(String(e)+" -site:w3schools.com",n)},format:function(t){function n(e){var t=IO.decodehtmlEntities(e.titleNoFormatting);return bot.adapter.link(t,e.unescapedUrl)}function o(e){var t="http://google.com/search?q="+encodeURIComponent(e);return bot.adapter.link("*",t)}if(!t.length)return e.random();var r=o(t.query)+" "+t.map(n).join(" ; ");return r.length>bot.adapter.maxLineLength&&(r=t.pluck("unescapedUrl").join(" ; ")),r},permissions:{del:"NONE"},description:"Search Google. `/google query`",async:!0};bot.addCommand(t)}(),function(){"use strict";var e=function(e,t){function n(e){t(e.word.toLowerCase().trim())}var o="http://sleepy-bastion-8674.herokuapp.com/";Number(e)&&(o+="?length="+e),IO.jsonp({url:o,jsonpName:"callback",fun:n})},t={dude:[" +---+"," | |"," | 413"," | 2"," | 5 6","__+__"].join("\n"),parts:["","O","|","/","\\","/","\\"],word:"",revealed:"",guesses:[],guessNum:0,maxGuess:6,end:!0,msg:null,validGuessRegex:/^[a-zA-Z]+$/,receiveMessage:function(e){return this.msg=e,this.end?void this["new"](e):this.handleGuess(e)},"new":function(n){function o(e){bot.log(e+" /hang random"),t.word=e,r.revealed=new Array(e.length+1).join("-"),r.guesses=[],r.guessNum=0,r.guessMade(),r.end=!1,n.length&&!Number(n)&&r.receiveMessage(n)}var r=this;e(n,o)},handleGuess:function(e){var t=e.slice().toLowerCase();bot.log(t,"handleGuess");var n=this.checkGuess(t);if(n)return n;var o=this.word.indexesOf(t);return o.forEach(function(e){this.uncoverPart(t,e)},this),o.length||this.guessNum++,this.guesses.push(t),this.guessMade(),bot.log(t,"handleGuess handled"),this.loseCheck()?this.lose():this.winCheck()?this.win():void 0},checkGuess:function(e){return!e.length||Number(e)?"We're already playing!":this.validGuessRegex.test(e)?this.guesses.indexOf(e)>-1?e+" was already submitted":e.length>this.word.length?bot.adapter.codify(e)+" is too long to fit":void 0:"I will only accept alpha characters"},uncoverPart:function(e,t){this.revealed=this.revealed.slice(0,t)+e+this.revealed.slice(t+e.length)},preparePrint:function(){if(!this.end){var e=this,t=this.dude.replace(/\d/g,function(t){return t>e.guessNum?" ":e.parts[t]}),n=this.guesses.sort().join(", ")+"\n"+this.revealed,o=this.msg.codify(t+"\n"+n);bot.log(o,this.msg),this.msg.send(o)}},win:function(){return this.end=!0,"Correct! The word is "+this.word+"."},lose:function(){return this.end=!0,"You people suck. The word is "+this.word},winCheck:function(){return this.word===this.revealed},loseCheck:function(){return this.guessNum>=this.maxGuess},guessMade:function(){clearTimeout(this.printTimeout),this.printTimeout=setTimeout(this.preparePrint.bind(this),2e3)}};bot.addCommand({name:"hang",fun:t.receiveMessage,thisArg:t})}(),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/imdb result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:imdb.com",n)})}bot.addCommand({name:"imdb",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches imdb page. `/imdb what`",async:!0})}(),function(){function e(n){if(!n.content)return t;var o=n.parse(!0);if(o.length>1)return o.map(e).join(" ");var r,i=n.trim().replace(/^\$/,"jQuery"),a=i.split("."),s=!1,c=i;return bot.log(i,a,"/jquery input"),3===a.length&&(a=[a[2]]),"jQuery"===a[0]&&jQuery[a[1]]?s=!0:1===a.length&&jQuery.prototype[a[0]]?(c=a[0],s=!0):jQuery[a[0]]&&(c="jQuery."+a[0],s=!0),r=s?t+c:t+"?s="+encodeURIComponent(n),bot.log(r,"/jquery link"),r}var t="http://api.jquery.com/";bot.addCommand({name:"jquery",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches documentation link from jQuery API. `/jquery what`"})}(),function(){"use strict";function e(e){bot.log(e,"/learn input");var n=e.parse(),r={name:n[0],output:n[1],input:n[2]||".*",creator:e.get("user_name"),creatorID:e.get("user_id"),date:new Date};r.name=r.name.toLowerCase();var a=o(r);return a?a:(r.input=new RegExp(r.input),r.description=["User-taught command:",n[3]||"",e.codify(r.output)].join(" "),bot.log(r,"/learn parsed"),t(r),i(r),"Command "+r.name+" learned")}function t(e){var t=bot.Command({name:e.name,description:e.description,creator:e.creator,date:e.date,fun:n(e),permissions:{use:"ALL",del:e.creatorID?[e.creatorID]:"OWNER"}});t.learned=!0,t.del=function(n){return function(){a(e.name),n.call(t)}}(t.del),bot.log(t,"/learn addCustomCommand"),bot.addCommand(t)}function n(e){function t(){var t=c.exec(e.output)||[,"user"],n=t[1];return n.slice(1,-1)}var n=e.output.replace(c,"").trim(),o=t();return bot.log(e,"/learn makeCustomCommand"),function(t){bot.log(t,e.name+" input");var r=bot.Message(n,t.get()),i=e.input.exec(t);if(!i)return m.supplant(e);var a=bot.parseMacro(r,i);switch(o){case"":t.send(a);break;case"msg":t.directreply(a);break;default:t.reply(a)}}}function o(e){function t(e){if(!bot.commandExists(e))return!0;var t=bot.getCommand(e);return t.learned&&t.date.getTime()+3e5>Date.now()}var n,o=Object.keys(e).some(function(t){return!e[t]});return o?n="Illegal `/learn` object; see `/help learn`":/\s/.test(e.name)?n="Invalid command name":t(e.name)?u.test(e.output)&&(n="Please enter some output"):n="Command "+e.name+" already exists",n}function r(){function e(e,o){o=JSON.parse(o),o.input=n(o.input),o.date=new Date(Date.parse(o.date)),t(o)}function n(e){var t=e.toString().split("/");return new RegExp(t.slice(1,-1).join("/"),t[t.length-1])}Object.iterate(s,e)}function i(e){s[e.name]=JSON.stringify(e),bot.memory.save("learn")}function a(e){delete s[e],bot.memory.save("learn")}var s=bot.memory.get("learn"),c=/^(<>||)/i,u=new RegExp(c.source+"$","i"),m="Input not matching `{input}`. Help: {description}";bot.addCommand({name:"learn",fun:e,privileges:{del:"NONE"},description:"Teaches me a command. `/learn cmdName outputPattern [inputRegex [description]]`"}),r()}(),bot.addCommand({name:"live",fun:function(){return bot.stopped?(bot["continue"](),"And on this day, you shall paint eggs for a giant bunny."):"I'm not dead! Honest!"},permissions:{del:"NONE",use:"OWNER"},description:"Resurrects me (:D) if I'm down (D:)"}),bot.addCommand(bot.CommunityCommand({name:"die",fun:function(){return bot.stopped?"Kill me once, shame on you, kill me twice...":(bot.stop(),"You killed me!")},permissions:{del:"NONE",use:"OWNER"},description:"Kills me :(",pendingMessage:"I will shut up after {0} more invocations."})),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/mdn result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:developer.mozilla.org",n)})}bot.addCommand({name:"mdn",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches mdn documentation. `/mdn what`",async:!0})}(),function(){function e(e){return t+o[e]+"."+n}var t="http://cdn.alltheragefaces.com/img/faces/png/",n="png",o={deskflip:"angry-desk-flip",fuu:"rage-classic",iseewhatyoudidthere:"happy-i-see-what-you-did-there-(clean)",no:"angry-no",notbad:"obama-not-bad",ohyou:"happy-oh-stop-it-you",okay:"okay-okay-clean",troll:"troll-troll-face",trollface:"troll-troll-face",youdontsay:"misc-you-dont-say"},r=new RegExp("^("+Object.keys(o).map(RegExp.escape).join("|")+")\\.(jpe?g|png)$");IO.register("input",function(t){var n=t.content.toLowerCase(),o=r.exec(n);if(o){var i=e(o[1]);bot.adapter.out.add(bot.adapter.directreply(t.message_id)+" "+i,t.room_id)}}),bot.addCommand({name:"meme",fun:function(t){var n=t.replace(/\.\w+$/,"");return n&&"list"!==n?o.hasOwnProperty(n)?void t.directreply(e(n)):"Sorry, I don't know that one.":Object.keys(o).join(", ")},permissions:{del:"NONE"},description:"Return a simple meme link. Pass no arguments or `list` to get a list of known memes. `/meme [memeName]`."})}(),function(){"use strict";function e(e){function o(t){bot.log(t,"/mustache finish"),e.directreply("http://mustachify.me/"+i.mustache+"?src="+t)}function r(e){var t=e.parse(),n=t.pop(),o={};return t.length>0&&!/\D/.test(n)?(o.usrid=t.join(" "),o.mustache=n):(o.usrid=e.content,o.mustache=Math.rand(0,5)),o}var i=r(e),a=i.usrid;if(bot.log(i,"/mustache input"),t(a))return void o(encodeURIComponent(a));if(a?/\D/.test(a)&&(a=e.findUserId(a)):a=e.get("user_id"),bot.log(a,"/mustache mapped"),!bot.users.hasOwnProperty(a))return n.supplant(a,bot.adapter.roomid);if(Number(a)===bot.adapter.user_id)return["Nobody puts a mustache on me. Again.","Mustache me once, shame on you. Mustache me ---twice--- 9 times..."].random();var s=bot.users[a].email_hash;o("!"===s[0]?encodeURIComponent(s.slice(1))+"#.png":"http%3A%2F%2Fwww.gravatar.com%2Favatar%2F{0}%3Fs%3D256%26d%3Didenticon#.png".supplant(s))}function t(e){return e.startsWith("http")||e.startsWith("www")}var n="User {0} was not found in room {1} (sorry, mustache only works there).",o={name:"mustache",fun:e,privileges:{del:"NONE"},description:"Mustachifies a user. `/mustache [link|usrid|username] [mustache=rand(0,5)]`"};bot.addCommand(o);var r=Object.merge(o,{name:"moustache"});bot.addCommand(r)}(),function(){function e(){Date.now();a=a.filter(function(e){return e.time-=c,e.time<=0?(t(e),!1):!0}),setTimeout(e,c)}function t(e){bot.log(e,"nudge fire"),e.msg.reply(e.message)}function n(e,t,n){var o;if(bot.log(e,t,"/nudge input"),e=parseFloat(e),o=6e4*e,isNaN(o))return"Many things can be labeled Not a Number; a delay should not be one of them.";s+=1;var r={msg:n,message:"*nudge* "+t,register:Date.now(),time:o,id:s};return a.push(r),bot.log(r,a,"/nudge register"),"Nudge #"+s+" registered."}function o(e,t){var n,o;return a.some(function(t,r){return t.id===e?(n=t,o=r,!0):void 0}),n?n.msg.get("user_name")!==t.get("user_name")?"It's not nice to try and remove a nudge which ain't yours":(bot.log(a[o],"/nudge remove #"+e),a.splice(o,1),"Nudge annhiliated"):["Nudge not found. Maybe it was already triggered, or this is a parallal universe.","I looked for nudge #"+e+", but all I found was this goat."].random()}function r(e){var t=e.parse(),r=t[0],i=t.slice(1).join(" ");return"remove"===r?o(Number(t[1]),e):n(r,i,e)}function i(e){return n(e.matches[1],e.matches[2],e)}var a=[],s=0,c=6e3;setTimeout(e,c),bot.addCommand({name:"nudge",fun:r,permissions:{del:"NONE"},description:"Register a nudge after an interval. `/nudge intervalInMinutes message`, `/nudge remove id` to remove, or the listener, `nudge|remind|poke me? in? intervalInMinutes message`",unTellable:!0}),bot.listen(/(?:nudge|remind|poke)\s(?:me\s)?(?:in\s)?(\d+m?)\s?(.*)$/,i)}(),function(){function e(e){function n(e){return e.name.toLowerCase().indexOf(i)>-1}function o(t){var n=e.escape(t.name);return"["+n+"](http://es5.github.com/#"+t.section+")"}var r,i=e.content.toLowerCase();return r=t.filter(n).map(o),bot.log(r,"/spec done"),r.length?r.join(", "):e+" not found in spec"}var t;t=[{section:"introduction",name:"Introduction"},{section:"x1",name:"1 Scope"},{section:"x2",name:"2 Conformance"},{section:"x3",name:"3 Normative references"},{section:"x4",name:"4 Overview"},{section:"x4.1",name:"4.1 Web Scripting"},{section:"x4.2",name:"4.2 Language Overview"},{section:"x4.2.1",name:"4.2.1 Objects"},{section:"x4.2.2",name:"4.2.2 The Strict Variant of ECMAScript"},{section:"x4.3",name:"4.3 Definitions"},{section:"x4.3.1",name:"4.3.1 type"},{section:"x4.3.2",name:"4.3.2 primitive value"},{section:"x4.3.3",name:"4.3.3 object"},{section:"x4.3.4",name:"4.3.4 constructor"},{section:"x4.3.5",name:"4.3.5 prototype"},{section:"x4.3.6",name:"4.3.6 native object"},{section:"x4.3.7",name:"4.3.7 built-in object"},{section:"x4.3.8",name:"4.3.8 host object"},{section:"x4.3.9",name:"4.3.9 undefined value"},{section:"x4.3.10",name:"4.3.10 Undefined type"},{section:"x4.3.11",name:"4.3.11 null value"},{section:"x4.3.12",name:"4.3.12 Null type"},{section:"x4.3.13",name:"4.3.13 Boolean value"},{section:"x4.3.14",name:"4.3.14 Boolean type"},{section:"x4.3.15",name:"4.3.15 Boolean object"},{section:"x4.3.16",name:"4.3.16 String value"},{section:"x4.3.17",name:"4.3.17 String type"},{section:"x4.3.18",name:"4.3.18 String object"},{section:"x4.3.19",name:"4.3.19 Number value"},{section:"x4.3.20",name:"4.3.20 Number type"},{section:"x4.3.21",name:"4.3.21 Number object"},{section:"x4.3.22",name:"4.3.22 Infinity"},{section:"x4.3.23",name:"4.3.23 NaN"},{section:"x4.3.24",name:"4.3.24 function"},{section:"x4.3.25",name:"4.3.25 built-in function"},{section:"x4.3.26",name:"4.3.26 property"},{section:"x4.3.27",name:"4.3.27 method"},{section:"x4.3.28",name:"4.3.28 built-in method"},{section:"x4.3.29",name:"4.3.29 attribute"},{section:"x4.3.30",name:"4.3.30 own property"},{section:"x4.3.31",name:"4.3.31 inherited property"},{section:"x5",name:"5 Notational Conventions"},{section:"x5.1",name:"5.1 Syntactic and Lexical Grammars"},{section:"x5.1.1",name:"5.1.1 Context-Free Grammars"},{section:"x5.1.2",name:"5.1.2 The Lexical and RegExp Grammars"},{section:"x5.1.3",name:"5.1.3 The Numeric String Grammar"},{section:"x5.1.4",name:"5.1.4 The Syntactic Grammar"},{section:"x5.1.5",name:"5.1.5 The JSON Grammar"},{section:"x5.1.6",name:"5.1.6 Grammar Notation"},{section:"x5.2",name:"5.2 Algorithm Conventions"},{section:"x6",name:"6 Source Text"},{section:"x7",name:"7 Lexical Conventions"},{section:"x7.1",name:"7.1 Unicode Format-Control Characters"},{section:"x7.2",name:"7.2 White Space"},{section:"x7.3",name:"7.3 Line Terminators"},{section:"x7.4",name:"7.4 Comments"},{section:"x7.5",name:"7.5 Tokens"},{section:"x7.6",name:"7.6 Identifier Names and Identifiers"},{section:"x7.6.1",name:"7.6.1 Reserved Words"},{section:"x7.6.1.1",name:"7.6.1.1 Keywords"},{section:"x7.6.1.2",name:"7.6.1.2 Future Reserved Words"},{section:"x7.7",name:"7.7 Punctuators"},{section:"x7.8",name:"7.8 Literals"},{section:"x7.8.1",name:"7.8.1 Null Literals"},{section:"x7.8.2",name:"7.8.2 Boolean Literals"},{section:"x7.8.3",name:"7.8.3 Numeric Literals"},{section:"x7.8.4",name:"7.8.4 String Literals"},{section:"x7.8.5",name:"7.8.5 Regular Expression Literals"},{section:"x7.9",name:"7.9 Automatic Semicolon Insertion"},{section:"x7.9.1",name:"7.9.1 Rules of Automatic Semicolon Insertion"},{section:"x7.9.2",name:"7.9.2 Examples of Automatic Semicolon Insertion"},{section:"x8",name:"8 Types"},{section:"x8.1",name:"8.1 The Undefined Type"},{section:"x8.2",name:"8.2 The Null Type"},{section:"x8.3",name:"8.3 The Boolean Type"},{section:"x8.4",name:"8.4 The String Type"},{section:"x8.5",name:"8.5 The Number Type"},{section:"x8.6",name:"8.6 The Object Type"},{section:"x8.6.1",name:"8.6.1 Property Attributes"},{section:"x8.6.2",name:"8.6.2 Object Internal Properties and Methods"},{section:"x8.7",name:"8.7 The Reference Specification Type"},{section:"x8.7.1",name:"8.7.1 GetValue (V)"},{section:"x8.7.2",name:"8.7.2 PutValue (V, W)"},{section:"x8.8",name:"8.8 The List Specification Type"},{section:"x8.9",name:"8.9 The Completion Specification Type"},{section:"x8.10",name:"8.10 The Property Descriptor and Property Identifier Specification Types"},{section:"x8.10.1",name:"8.10.1 IsAccessorDescriptor ( Desc )"},{section:"x8.10.2",name:"8.10.2 IsDataDescriptor ( Desc )"},{section:"x8.10.3",name:"8.10.3 IsGenericDescriptor ( Desc )"},{section:"x8.10.4",name:"8.10.4 FromPropertyDescriptor ( Desc )"},{section:"x8.10.5",name:"8.10.5 ToPropertyDescriptor ( Obj )"},{section:"x8.11",name:"8.11 The Lexical Environment and Environment Record Specification Types"},{section:"x8.12",name:"8.12 Algorithms for Object Internal Methods"},{section:"x8.12.1",name:"8.12.1 [[GetOwnProperty]] (P)"},{section:"x8.12.2",name:"8.12.2 [[GetProperty]] (P)"},{section:"x8.12.3",name:"8.12.3 [[Get]] (P)"},{section:"x8.12.4",name:"8.12.4 [[CanPut]] (P)"},{section:"x8.12.5",name:"8.12.5 [[Put]] ( P, V, Throw )"},{section:"x8.12.6",name:"8.12.6 [[HasProperty]] (P)"},{section:"x8.12.7",name:"8.12.7 [[Delete]] (P, Throw)"},{section:"x8.12.8",name:"8.12.8 [[DefaultValue]] (hint)"},{section:"x8.12.9",name:"8.12.9 [[DefineOwnProperty]] (P, Desc, Throw)"},{section:"x9",name:"9 Type Conversion and Testing"},{section:"x9.1",name:"9.1 ToPrimitive"},{section:"x9.2",name:"9.2 ToBoolean"},{section:"x9.3",name:"9.3 ToNumber"},{section:"x9.3.1",name:"9.3.1 ToNumber Applied to the String Type"},{section:"x9.4",name:"9.4 ToInteger"},{section:"x9.5",name:"9.5 ToInt32: (Signed 32 Bit Integer)"},{section:"x9.6",name:"9.6 ToUint32: (Unsigned 32 Bit Integer)"},{section:"x9.7",name:"9.7 ToUint16: (Unsigned 16 Bit Integer)"},{section:"x9.8",name:"9.8 ToString"},{section:"x9.8.1",name:"9.8.1 ToString Applied to the Number Type"},{section:"x9.9",name:"9.9 ToObject"},{section:"x9.10",name:"9.10 CheckObjectCoercible"},{section:"x9.11",name:"9.11 IsCallable"},{section:"x9.12",name:"9.12 The SameValue Algorithm"},{section:"x10",name:"10 Executable Code and Execution Contexts"},{section:"x10.1",name:"10.1 Types of Executable Code"},{section:"x10.1.1",name:"10.1.1 Strict Mode Code"},{section:"x10.2",name:"10.2 Lexical Environments"},{section:"x10.2.1",name:"10.2.1 Environment Records"},{section:"x10.2.1.1",name:"10.2.1.1 Declarative Environment Records"},{section:"x10.2.1.1.1",name:"10.2.1.1.1 HasBinding(N)"},{section:"x10.2.1.1.2",name:"10.2.1.1.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.1.3",name:"10.2.1.1.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.1.4",name:"10.2.1.1.4 GetBindingValue(N,S)"},{section:"x10.2.1.1.5",name:"10.2.1.1.5 DeleteBinding (N)"},{section:"x10.2.1.1.6",name:"10.2.1.1.6 ImplicitThisValue()"},{section:"x10.2.1.1.7",name:"10.2.1.1.7 CreateImmutableBinding (N)"},{section:"x10.2.1.1.8",name:"10.2.1.1.8 InitializeImmutableBinding (N,V)"},{section:"x10.2.1.2",name:"10.2.1.2 Object Environment Records"},{section:"x10.2.1.2.1",name:"10.2.1.2.1 HasBinding(N)"},{section:"x10.2.1.2.2",name:"10.2.1.2.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.2.3",name:"10.2.1.2.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.2.4",name:"10.2.1.2.4 GetBindingValue(N,S)"},{section:"x10.2.1.2.5",name:"10.2.1.2.5 DeleteBinding (N)"},{section:"x10.2.1.2.6",name:"10.2.1.2.6 ImplicitThisValue()"},{section:"x10.2.2",name:"10.2.2 Lexical Environment Operations"},{section:"x10.2.2.1",name:"10.2.2.1 GetIdentifierReference (lex, name, strict)"},{section:"x10.2.2.2",name:"10.2.2.2 NewDeclarativeEnvironment (E)"},{section:"x10.2.2.3",name:"10.2.2.3 NewObjectEnvironment (O, E)"},{section:"x10.2.3",name:"10.2.3 The Global Environment"},{section:"x10.3",name:"10.3 Execution Contexts"},{section:"x10.3.1",name:"10.3.1 Identifier Resolution"},{section:"x10.4",name:"10.4 Establishing an Execution Context"},{section:"x10.4.1",name:"10.4.1 Entering Global Code"},{section:"x10.4.1.1",name:"10.4.1.1 Initial Global Execution Context"},{section:"x10.4.2",name:"10.4.2 Entering Eval Code"},{section:"x10.4.2.1",name:"10.4.2.1 Strict Mode Restrictions"},{section:"x10.4.3",name:"10.4.3 Entering Function Code"},{section:"x10.5",name:"10.5 Declaration Binding Instantiation"},{section:"x10.6",name:"10.6 Arguments Object"},{section:"x11",name:"11 Expressions"},{section:"x11.1",name:"11.1 Primary Expressions"},{section:"x11.1.1",name:"11.1.1 The this Keyword"},{section:"x11.1.2",name:"11.1.2 Identifier Reference"},{section:"x11.1.3",name:"11.1.3 Literal Reference"},{section:"x11.1.4",name:"11.1.4 Array Initialiser"},{section:"x11.1.5",name:"11.1.5 Object Initialiser"},{section:"x11.1.6",name:"11.1.6 The Grouping Operator"},{section:"x11.2",name:"11.2 Left-Hand-Side Expressions"},{section:"x11.2.1",name:"11.2.1 Property Accessors"},{section:"x11.2.2",name:"11.2.2 The new Operator"},{section:"x11.2.3",name:"11.2.3 Function Calls"},{section:"x11.2.4",name:"11.2.4 Argument Lists"},{section:"x11.2.5",name:"11.2.5 Function Expressions"},{section:"x11.3",name:"11.3 Postfix Expressions"},{section:"x11.3.1",name:"11.3.1 Postfix Increment Operator"},{section:"x11.3.2",name:"11.3.2 Postfix Decrement Operator"},{section:"x11.4",name:"11.4 Unary Operators"},{section:"x11.4.1",name:"11.4.1 The delete Operator"},{section:"x11.4.2",name:"11.4.2 The void Operator"},{section:"x11.4.3",name:"11.4.3 The typeof Operator"},{section:"x11.4.4",name:"11.4.4 Prefix Increment Operator"},{section:"x11.4.5",name:"11.4.5 Prefix Decrement Operator"},{section:"x11.4.6",name:"11.4.6 Unary + Operator"},{section:"x11.4.7",name:"11.4.7 Unary - Operator"},{section:"x11.4.8",name:"11.4.8 Bitwise NOT Operator ( ~ )"},{section:"x11.4.9",name:"11.4.9 Logical NOT Operator ( ! )"},{section:"x11.5",name:"11.5 Multiplicative Operators"},{section:"x11.5.1",name:"11.5.1 Applying the * Operator"},{section:"x11.5.2",name:"11.5.2 Applying the / Operator"},{section:"x11.5.3",name:"11.5.3 Applying the % Operator"},{section:"x11.6",name:"11.6 Additive Operators"},{section:"x11.6.1",name:"11.6.1 The Addition operator ( + )"},{section:"x11.6.2",name:"11.6.2 The Subtraction Operator ( - )"},{section:"x11.6.3",name:"11.6.3 Applying the Additive Operators to Numbers"},{section:"x11.7",name:"11.7 Bitwise Shift Operators"},{section:"x11.7.1",name:"11.7.1 The Left Shift Operator ( << )"},{section:"x11.7.2",name:"11.7.2 The Signed Right Shift Operator ( >> )"},{section:"x11.7.3",name:"11.7.3 The Unsigned Right Shift Operator ( >>> )"},{section:"x11.8",name:"11.8 Relational Operators"},{section:"x11.8.1",name:"11.8.1 The Less-than Operator ( < )"},{section:"x11.8.2",name:"11.8.2 The Greater-than Operator ( > )"},{section:"x11.8.3",name:"11.8.3 The Less-than-or-equal Operator ( <= )"},{section:"x11.8.4",name:"11.8.4 The Greater-than-or-equal Operator ( >= )"},{section:"x11.8.5",name:"11.8.5 The Abstract Relational Comparison Algorithm"},{section:"x11.8.6",name:"11.8.6 The instanceof operator"},{section:"x11.8.7",name:"11.8.7 The in operator"},{section:"x11.9",name:"11.9 Equality Operators"},{section:"x11.9.1",name:"11.9.1 The Equals Operator ( == )"},{section:"x11.9.2",name:"11.9.2 The Does-not-equals Operator ( != )"},{section:"x11.9.3",name:"11.9.3 The Abstract Equality Comparison Algorithm"},{section:"x11.9.4",name:"11.9.4 The Strict Equals Operator ( === )"},{section:"x11.9.5",name:"11.9.5 The Strict Does-not-equal Operator ( !== )"},{section:"x11.9.6",name:"11.9.6 The Strict Equality Comparison Algorithm"},{section:"x11.10",name:"11.10 Binary Bitwise Operators"},{section:"x11.11",name:"11.11 Binary Logical Operators"},{section:"x11.12",name:"11.12 Conditional Operator ( ? : )"},{section:"x11.13",name:"11.13 Assignment Operators"},{section:"x11.13.1",name:"11.13.1 Simple Assignment ( = )"},{section:"x11.13.2",name:"11.13.2 Compound Assignment ( op= )"},{section:"x11.14",name:"11.14 Comma Operator ( , )"},{section:"x12",name:"12 Statements"},{section:"x12.1",name:"12.1 Block"},{section:"x12.2",name:"12.2 Variable Statement"},{section:"x12.2.1",name:"12.2.1 Strict Mode Restrictions"},{section:"x12.3",name:"12.3 Empty Statement"},{section:"x12.4",name:"12.4 Expression Statement"},{section:"x12.5",name:"12.5 The if Statement"},{section:"x12.6",name:"12.6 Iteration Statements"},{section:"x12.6.1",name:"12.6.1 The do-while Statement"},{section:"x12.6.2",name:"12.6.2 The while Statement"},{section:"x12.6.3",name:"12.6.3 The for Statement"},{section:"x12.6.4",name:"12.6.4 The for-in Statement"},{section:"x12.7",name:"12.7 The continue Statement"},{section:"x12.8",name:"12.8 The break Statement"},{section:"x12.9",name:"12.9 The return Statement"},{section:"x12.10",name:"12.10 The with Statement"},{section:"x12.10.1",name:"12.10.1 Strict Mode Restrictions"},{section:"x12.11",name:"12.11 The switch Statement"},{section:"x12.12",name:"12.12 Labelled Statements"},{section:"x12.13",name:"12.13 The throw Statement"},{section:"x12.14",name:"12.14 The try Statement"},{section:"x12.14.1",name:"12.14.1 Strict Mode Restrictions"},{section:"x12.15",name:"12.15 The debugger statement"},{section:"x13",name:"13 Function Definition"},{section:"x13.1",name:"13.1 Strict Mode Restrictions"},{section:"x13.2",name:"13.2 Creating Function Objects"},{section:"x13.2.1",name:"13.2.1 [[Call]]"},{section:"x13.2.2",name:"13.2.2 [[Construct]]"},{section:"x13.2.3",name:"13.2.3 The Function Object"},{section:"x14",name:"14 Program"},{section:"x14.1",name:"14.1 Directive Prologues and the Use Strict Directive"},{section:"x15",name:"15 Standard Built-in ECMAScript Objects"},{section:"x15.1",name:"15.1 The Global Object"},{section:"x15.1.1",name:"15.1.1 Value Properties of the Global Object"},{section:"x15.1.1.1",name:"15.1.1.1 NaN"},{section:"x15.1.1.2",name:"15.1.1.2 Infinity"},{section:"x15.1.1.3",name:"15.1.1.3 undefined"},{section:"x15.1.2",name:"15.1.2 Function Properties of the Global Object"},{section:"x15.1.2.1",name:"15.1.2.1 eval (x)"},{section:"x15.1.2.1.1",name:"15.1.2.1.1 Direct Call to Eval"},{section:"x15.1.2.2",name:"15.1.2.2 parseInt (string , radix)"},{section:"x15.1.2.3",name:"15.1.2.3 parseFloat (string)"},{section:"x15.1.2.4",name:"15.1.2.4 isNaN (number)"},{section:"x15.1.2.5",name:"15.1.2.5 isFinite (number)"},{section:"x15.1.3",name:"15.1.3 URI Handling Function Properties"},{section:"x15.1.3.1",name:"15.1.3.1 decodeURI (encodedURI)"},{section:"x15.1.3.2",name:"15.1.3.2 decodeURIComponent (encodedURIComponent)"},{section:"x15.1.3.3",name:"15.1.3.3 encodeURI (uri)"},{section:"x15.1.3.4",name:"15.1.3.4 encodeURIComponent (uriComponent)"},{section:"x15.1.4",name:"15.1.4 Constructor Properties of the Global Object"},{section:"x15.1.4.1",name:"15.1.4.1 Object ( . . . )"},{section:"x15.1.4.2",name:"15.1.4.2 Function ( . . . )"},{section:"x15.1.4.3",name:"15.1.4.3 Array ( . . . )"},{section:"x15.1.4.4",name:"15.1.4.4 String ( . . . )"},{section:"x15.1.4.5",name:"15.1.4.5 Boolean ( . . . )"},{section:"x15.1.4.6",name:"15.1.4.6 Number ( . . . )"},{section:"x15.1.4.7",name:"15.1.4.7 Date ( . . . )"},{section:"x15.1.4.8",name:"15.1.4.8 RegExp ( . . . )"},{section:"x15.1.4.9",name:"15.1.4.9 Error ( . . . )"},{section:"x15.1.4.10",name:"15.1.4.10 EvalError ( . . . )"},{section:"x15.1.4.11",name:"15.1.4.11 RangeError ( . . . )"},{section:"x15.1.4.12",name:"15.1.4.12 ReferenceError ( . . . )"},{section:"x15.1.4.13",name:"15.1.4.13 SyntaxError ( . . . )"},{section:"x15.1.4.14",name:"15.1.4.14 TypeError ( . . . )"},{section:"x15.1.4.15",name:"15.1.4.15 URIError ( . . . )"},{section:"x15.1.5",name:"15.1.5 Other Properties of the Global Object"},{section:"x15.1.5.1",name:"15.1.5.1 Math"},{section:"x15.1.5.2",name:"15.1.5.2 JSON"},{section:"x15.2",name:"15.2 Object Objects"},{section:"x15.2.1",name:"15.2.1 The Object Constructor Called as a Function"},{section:"x15.2.1.1",name:"15.2.1.1 Object ( [ value ] )"},{section:"x15.2.2",name:"15.2.2 The Object Constructor"},{section:"x15.2.2.1",name:"15.2.2.1 new Object ( [ value ] )"},{section:"x15.2.3",name:"15.2.3 Properties of the Object Constructor"},{section:"x15.2.3.1",name:"15.2.3.1 Object.prototype"},{section:"x15.2.3.2",name:"15.2.3.2 Object.getPrototypeOf ( O )"},{section:"x15.2.3.3",name:"15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) "},{section:"x15.2.3.4",name:"15.2.3.4 Object.getOwnPropertyNames ( O )"},{section:"x15.2.3.5",name:"15.2.3.5 Object.create ( O [, Properties] )"},{section:"x15.2.3.6",name:"15.2.3.6 Object.defineProperty ( O, P, Attributes )"},{section:"x15.2.3.7",name:"15.2.3.7 Object.defineProperties ( O, Properties )"},{section:"x15.2.3.8",name:"15.2.3.8 Object.seal ( O )"},{section:"x15.2.3.9",name:"15.2.3.9 Object.freeze ( O )"},{section:"x15.2.3.10",name:"15.2.3.10 Object.preventExtensions ( O )"},{section:"x15.2.3.11",name:"15.2.3.11 Object.isSealed ( O )"},{section:"x15.2.3.12",name:"15.2.3.12 Object.isFrozen ( O )"},{section:"x15.2.3.13",name:"15.2.3.13 Object.isExtensible ( O )"},{section:"x15.2.3.14",name:"15.2.3.14 Object.keys ( O )"},{section:"x15.2.4",name:"15.2.4 Properties of the Object Prototype Object"},{section:"x15.2.4.1",name:"15.2.4.1 Object.prototype.constructor"},{section:"x15.2.4.2",name:"15.2.4.2 Object.prototype.toString ( )"},{section:"x15.2.4.3",name:"15.2.4.3 Object.prototype.toLocaleString ( )"},{section:"x15.2.4.4",name:"15.2.4.4 Object.prototype.valueOf ( )"},{section:"x15.2.4.5",name:"15.2.4.5 Object.prototype.hasOwnProperty (V)"},{section:"x15.2.4.6",name:"15.2.4.6 Object.prototype.isPrototypeOf (V)"},{section:"x15.2.4.7",name:"15.2.4.7 Object.prototype.propertyIsEnumerable (V)"},{section:"x15.2.5",name:"15.2.5 Properties of Object Instances"},{section:"x15.3",name:"15.3 Function Objects"},{section:"x15.3.1",name:"15.3.1 The Function Constructor Called as a Function"},{section:"x15.3.1.1",name:"15.3.1.1 Function (p1, p2, … , pn, body)"},{section:"x15.3.2",name:"15.3.2 The Function Constructor"},{section:"x15.3.2.1",name:"15.3.2.1 new Function (p1, p2, … , pn, body)"},{section:"x15.3.3",name:"15.3.3 Properties of the Function Constructor"},{section:"x15.3.3.1",name:"15.3.3.1 Function.prototype"},{section:"x15.3.3.2",name:"15.3.3.2 Function.length"},{section:"x15.3.4",name:"15.3.4 Properties of the Function Prototype Object"},{section:"x15.3.4.1",name:"15.3.4.1 Function.prototype.constructor"},{section:"x15.3.4.2",name:"15.3.4.2 Function.prototype.toString ( )"},{section:"x15.3.4.3",name:"15.3.4.3 Function.prototype.apply (thisArg, argArray)"},{section:"x15.3.4.4",name:"15.3.4.4 Function.prototype.call (thisArg [ , arg1 [ , arg2, … ] ] )"},{section:"x15.3.4.5",name:"15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, …]])"},{section:"x15.3.4.5.1",name:"15.3.4.5.1 [[Call]]"},{section:"x15.3.4.5.2",name:"15.3.4.5.2 [[Construct]]"},{section:"x15.3.4.5.3",name:"15.3.4.5.3 [[HasInstance]] (V)"},{section:"x15.3.5",name:"15.3.5 Properties of Function Instances"},{section:"x15.3.5.1",name:"15.3.5.1 length"},{section:"x15.3.5.2",name:"15.3.5.2 prototype"},{section:"x15.3.5.3",name:"15.3.5.3 [[HasInstance]] (V)"},{section:"x15.3.5.4",name:"15.3.5.4 [[Get]] (P)"},{section:"x15.4",name:"15.4 Array Objects"},{section:"x15.4.1",name:"15.4.1 The Array Constructor Called as a Function"},{section:"x15.4.1.1",name:"15.4.1.1 Array ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.2",name:"15.4.2 The Array Constructor"},{section:"x15.4.2.1",name:"15.4.2.1 new Array ( [ item0 [ , item1 [ , … ] ] ] )"},{section:"x15.4.2.2",name:"15.4.2.2 new Array (len)"},{section:"x15.4.3",name:"15.4.3 Properties of the Array Constructor"},{section:"x15.4.3.1",name:"15.4.3.1 Array.prototype"},{section:"x15.4.3.2",name:"15.4.3.2 Array.isArray ( arg )"},{section:"x15.4.4",name:"15.4.4 Properties of the Array Prototype Object"},{section:"x15.4.4.1",name:"15.4.4.1 Array.prototype.constructor"},{section:"x15.4.4.2",name:"15.4.4.2 Array.prototype.toString ( )"},{section:"x15.4.4.3",name:"15.4.4.3 Array.prototype.toLocaleString ( )"},{section:"x15.4.4.4",name:"15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.5",name:"15.4.4.5 Array.prototype.join (separator)"},{section:"x15.4.4.6",name:"15.4.4.6 Array.prototype.pop ( )"},{section:"x15.4.4.7",name:"15.4.4.7 Array.prototype.push ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.8",name:"15.4.4.8 Array.prototype.reverse ( )"},{section:"x15.4.4.9",name:"15.4.4.9 Array.prototype.shift ( )"},{section:"x15.4.4.10",name:"15.4.4.10 Array.prototype.slice (start, end)"},{section:"x15.4.4.11",name:"15.4.4.11 Array.prototype.sort (comparefn)"},{section:"x15.4.4.12",name:"15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.13",name:"15.4.4.13 Array.prototype.unshift ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.14",name:"15.4.4.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.15",name:"15.4.4.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.16",name:"15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.17",name:"15.4.4.17 Array.prototype.some ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.18",name:"15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.19",name:"15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.20",name:"15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.21",name:"15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue ] )"},{section:"x15.4.4.22",name:"15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )"},{section:"x15.4.5",name:"15.4.5 Properties of Array Instances"},{section:"x15.4.5.1",name:"15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )"},{section:"x15.4.5.2",name:"15.4.5.2 length"},{section:"x15.5",name:"15.5 String Objects"},{section:"x15.5.1",name:"15.5.1 The String Constructor Called as a Function"},{section:"x15.5.1.1",name:"15.5.1.1 String ( [ value ] )"},{section:"x15.5.2",name:"15.5.2 The String Constructor"},{section:"x15.5.2.1",name:"15.5.2.1 new String ( [ value ] )"},{section:"x15.5.3",name:"15.5.3 Properties of the String Constructor"},{section:"x15.5.3.1",name:"15.5.3.1 String.prototype"},{section:"x15.5.3.2",name:"15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] )"},{section:"x15.5.4",name:"15.5.4 Properties of the String Prototype Object"},{section:"x15.5.4.1",name:"15.5.4.1 String.prototype.constructor"},{section:"x15.5.4.2",name:"15.5.4.2 String.prototype.toString ( )"},{section:"x15.5.4.3",name:"15.5.4.3 String.prototype.valueOf ( )"},{section:"x15.5.4.4",name:"15.5.4.4 String.prototype.charAt (pos)"},{section:"x15.5.4.5",name:"15.5.4.5 String.prototype.charCodeAt (pos)"},{section:"x15.5.4.6",name:"15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] )"},{section:"x15.5.4.7",name:"15.5.4.7 String.prototype.indexOf (searchString, position)"},{section:"x15.5.4.8",name:"15.5.4.8 String.prototype.lastIndexOf (searchString, position)"},{section:"x15.5.4.9",name:"15.5.4.9 String.prototype.localeCompare (that)"},{section:"x15.5.4.10",name:"15.5.4.10 String.prototype.match (regexp)"},{section:"x15.5.4.11",name:"15.5.4.11 String.prototype.replace (searchValue, replaceValue)"},{section:"x15.5.4.12",name:"15.5.4.12 String.prototype.search (regexp)"},{section:"x15.5.4.13",name:"15.5.4.13 String.prototype.slice (start, end)"},{section:"x15.5.4.14",name:"15.5.4.14 String.prototype.split (separator, limit)"},{section:"x15.5.4.15",name:"15.5.4.15 String.prototype.substring (start, end)"},{section:"x15.5.4.16",name:"15.5.4.16 String.prototype.toLowerCase ( )"},{section:"x15.5.4.17",name:"15.5.4.17 String.prototype.toLocaleLowerCase ( )"},{section:"x15.5.4.18",name:"15.5.4.18 String.prototype.toUpperCase ( )"},{section:"x15.5.4.19",name:"15.5.4.19 String.prototype.toLocaleUpperCase ( )"},{section:"x15.5.4.20",name:"15.5.4.20 String.prototype.trim ( )"},{section:"x15.5.5",name:"15.5.5 Properties of String Instances"},{section:"x15.5.5.1",name:"15.5.5.1 length"},{section:"x15.5.5.2",name:"15.5.5.2 [[GetOwnProperty]] ( P )"},{section:"x15.6",name:"15.6 Boolean Objects"},{section:"x15.6.1",name:"15.6.1 The Boolean Constructor Called as a Function"},{section:"x15.6.1.1",name:"15.6.1.1 Boolean (value)"},{section:"x15.6.2",name:"15.6.2 The Boolean Constructor"},{section:"x15.6.2.1",name:"15.6.2.1 new Boolean (value)"},{section:"x15.6.3",name:"15.6.3 Properties of the Boolean Constructor"},{section:"x15.6.3.1",name:"15.6.3.1 Boolean.prototype"},{section:"x15.6.4",name:"15.6.4 Properties of the Boolean Prototype Object"},{section:"x15.6.4.1",name:"15.6.4.1 Boolean.prototype.constructor"},{section:"x15.6.4.2",name:"15.6.4.2 Boolean.prototype.toString ( )"},{section:"x15.6.4.3",name:"15.6.4.3 Boolean.prototype.valueOf ( )"},{section:"x15.6.5",name:"15.6.5 Properties of Boolean Instances"},{section:"x15.7",name:"15.7 Number Objects"},{section:"x15.7.1",name:"15.7.1 The Number Constructor Called as a Function"},{section:"x15.7.1.1",name:"15.7.1.1 Number ( [ value ] )"},{section:"x15.7.2",name:"15.7.2 The Number Constructor"},{section:"x15.7.2.1",name:"15.7.2.1 new Number ( [ value ] )"},{section:"x15.7.3",name:"15.7.3 Properties of the Number Constructor"},{section:"x15.7.3.1",name:"15.7.3.1 Number.prototype"},{section:"x15.7.3.2",name:"15.7.3.2 Number.MAX_VALUE"},{section:"x15.7.3.3",name:"15.7.3.3 Number.MIN_VALUE"},{section:"x15.7.3.4",name:"15.7.3.4 Number.NaN"},{section:"x15.7.3.5",name:"15.7.3.5 Number.NEGATIVE_INFINITY"},{section:"x15.7.3.6",name:"15.7.3.6 Number.POSITIVE_INFINITY"},{section:"x15.7.4",name:"15.7.4 Properties of the Number Prototype Object"},{section:"x15.7.4.1",name:"15.7.4.1 Number.prototype.constructor"},{section:"x15.7.4.2",name:"15.7.4.2 Number.prototype.toString ( [ radix ] )"},{section:"x15.7.4.3",name:"15.7.4.3 Number.prototype.toLocaleString()"},{section:"x15.7.4.4",name:"15.7.4.4 Number.prototype.valueOf ( )"},{section:"x15.7.4.5",name:"15.7.4.5 Number.prototype.toFixed (fractionDigits)"},{section:"x15.7.4.6",name:"15.7.4.6 Number.prototype.toExponential (fractionDigits)"},{section:"x15.7.4.7",name:"15.7.4.7 Number.prototype.toPrecision (precision)"},{section:"x15.7.5",name:"15.7.5 Properties of Number Instances"},{section:"x15.8",name:"15.8 The Math Object"},{section:"x15.8.1",name:"15.8.1 Value Properties of the Math Object"},{section:"x15.8.1.1",name:"15.8.1.1 E"},{section:"x15.8.1.2",name:"15.8.1.2 LN10"},{section:"x15.8.1.3",name:"15.8.1.3 LN2"},{section:"x15.8.1.4",name:"15.8.1.4 LOG2E"},{section:"x15.8.1.5",name:"15.8.1.5 LOG10E"},{section:"x15.8.1.6",name:"15.8.1.6 PI"},{section:"x15.8.1.7",name:"15.8.1.7 SQRT1_2"},{section:"x15.8.1.8",name:"15.8.1.8 SQRT2"},{section:"x15.8.2",name:"15.8.2 Function Properties of the Math Object"},{section:"x15.8.2.1",name:"15.8.2.1 abs (x)"},{section:"x15.8.2.2",name:"15.8.2.2 acos (x)"},{section:"x15.8.2.3",name:"15.8.2.3 asin (x)"},{section:"x15.8.2.4",name:"15.8.2.4 atan (x)"},{section:"x15.8.2.5",name:"15.8.2.5 atan2 (y, x)"},{section:"x15.8.2.6",name:"15.8.2.6 ceil (x)"},{section:"x15.8.2.7",name:"15.8.2.7 cos (x)"},{section:"x15.8.2.8",name:"15.8.2.8 exp (x)"},{section:"x15.8.2.9",name:"15.8.2.9 floor (x)"},{section:"x15.8.2.10",name:"15.8.2.10 log (x)"},{section:"x15.8.2.11",name:"15.8.2.11 max ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.12",name:"15.8.2.12 min ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.13",name:"15.8.2.13 pow (x, y)"},{section:"x15.8.2.14",name:"15.8.2.14 random ( )"},{section:"x15.8.2.15",name:"15.8.2.15 round (x)"},{section:"x15.8.2.16",name:"15.8.2.16 sin (x)"},{section:"x15.8.2.17",name:"15.8.2.17 sqrt (x)"},{section:"x15.8.2.18",name:"15.8.2.18 tan (x)"},{section:"x15.9",name:"15.9 Date Objects"},{section:"x15.9.1",name:"15.9.1 Overview of Date Objects and Definitions of Abstract Operators"},{section:"x15.9.1.1",name:"15.9.1.1 Time Values and Time Range"},{section:"x15.9.1.2",name:"15.9.1.2 Day Number and Time within Day"},{section:"x15.9.1.3",name:"15.9.1.3 Year Number"},{section:"x15.9.1.4",name:"15.9.1.4 Month Number"},{section:"x15.9.1.5",name:"15.9.1.5 Date Number"},{section:"x15.9.1.6",name:"15.9.1.6 Week Day"},{section:"x15.9.1.7",name:"15.9.1.7 Local Time Zone Adjustment"},{section:"x15.9.1.8",name:"15.9.1.8 Daylight Saving Time Adjustment"},{section:"x15.9.1.9",name:"15.9.1.9 Local Time"},{section:"x15.9.1.10",name:"15.9.1.10 Hours, Minutes, Second, and Milliseconds"},{section:"x15.9.1.11",name:"15.9.1.11 MakeTime (hour, min, sec, ms)"},{section:"x15.9.1.12",name:"15.9.1.12 MakeDay (year, month, date)"},{section:"x15.9.1.13",name:"15.9.1.13 MakeDate (day, time)"},{section:"x15.9.1.14",name:"15.9.1.14 TimeClip (time)"},{section:"x15.9.1.15",name:"15.9.1.15 Date Time String Format"},{section:"x15.9.1.15.1",name:"15.9.1.15.1 Extended years"},{section:"x15.9.2",name:"15.9.2 The Date Constructor Called as a Function"},{section:"x15.9.2.1",name:"15.9.2.1 Date ( [ year [, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] ] ] )"},{section:"x15.9.3",name:"15.9.3 The Date Constructor"},{section:"x15.9.3.1",name:"15.9.3.1 new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )"},{section:"x15.9.3.2",name:"15.9.3.2 new Date (value)"},{section:"x15.9.3.3",name:"15.9.3.3 new Date ( )"},{section:"x15.9.4",name:"15.9.4 Properties of the Date Constructor"},{section:"x15.9.4.1",name:"15.9.4.1 Date.prototype"},{section:"x15.9.4.2",name:"15.9.4.2 Date.parse (string)"},{section:"x15.9.4.3",name:"15.9.4.3 Date.UTC (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ])"},{section:"x15.9.4.4",name:"15.9.4.4 Date.now ( )"},{section:"x15.9.5",name:"15.9.5 Properties of the Date Prototype Object"},{section:"x15.9.5.1",name:"15.9.5.1 Date.prototype.constructor"},{section:"x15.9.5.2",name:"15.9.5.2 Date.prototype.toString ( )"},{section:"x15.9.5.3",name:"15.9.5.3 Date.prototype.toDateString ( )"},{section:"x15.9.5.4",name:"15.9.5.4 Date.prototype.toTimeString ( )"},{section:"x15.9.5.5",name:"15.9.5.5 Date.prototype.toLocaleString ( )"},{section:"x15.9.5.6",name:"15.9.5.6 Date.prototype.toLocaleDateString ( )"},{section:"x15.9.5.7",name:"15.9.5.7 Date.prototype.toLocaleTimeString ( )"},{section:"x15.9.5.8",name:"15.9.5.8 Date.prototype.valueOf ( )"},{section:"x15.9.5.9",name:"15.9.5.9 Date.prototype.getTime ( )"},{section:"x15.9.5.10",name:"15.9.5.10 Date.prototype.getFullYear ( )"},{section:"x15.9.5.11",name:"15.9.5.11 Date.prototype.getUTCFullYear ( )"},{section:"x15.9.5.12",name:"15.9.5.12 Date.prototype.getMonth ( )"},{section:"x15.9.5.13",name:"15.9.5.13 Date.prototype.getUTCMonth ( )"},{section:"x15.9.5.14",name:"15.9.5.14 Date.prototype.getDate ( )"},{section:"x15.9.5.15",name:"15.9.5.15 Date.prototype.getUTCDate ( )"},{section:"x15.9.5.16",name:"15.9.5.16 Date.prototype.getDay ( )"},{section:"x15.9.5.17",name:"15.9.5.17 Date.prototype.getUTCDay ( )"},{section:"x15.9.5.18",name:"15.9.5.18 Date.prototype.getHours ( )"},{section:"x15.9.5.19",name:"15.9.5.19 Date.prototype.getUTCHours ( )"},{section:"x15.9.5.20",name:"15.9.5.20 Date.prototype.getMinutes ( )"},{section:"x15.9.5.21",name:"15.9.5.21 Date.prototype.getUTCMinutes ( )"},{section:"x15.9.5.22",name:"15.9.5.22 Date.prototype.getSeconds ( )"},{section:"x15.9.5.23",name:"15.9.5.23 Date.prototype.getUTCSeconds ( )"},{section:"x15.9.5.24",name:"15.9.5.24 Date.prototype.getMilliseconds ( )"},{section:"x15.9.5.25",name:"15.9.5.25 Date.prototype.getUTCMilliseconds ( )"},{section:"x15.9.5.26",name:"15.9.5.26 Date.prototype.getTimezoneOffset ( )"},{section:"x15.9.5.27",name:"15.9.5.27 Date.prototype.setTime (time)"},{section:"x15.9.5.28",name:"15.9.5.28 Date.prototype.setMilliseconds (ms)"},{section:"x15.9.5.29",name:"15.9.5.29 Date.prototype.setUTCMilliseconds (ms)"},{section:"x15.9.5.30",name:"15.9.5.30 Date.prototype.setSeconds (sec [, ms ] )"},{section:"x15.9.5.31",name:"15.9.5.31 Date.prototype.setUTCSeconds (sec [, ms ] )"},{section:"x15.9.5.32",name:"15.9.5.32 Date.prototype.setMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.33",name:"15.9.5.33 Date.prototype.setUTCMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.34",name:"15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.35",name:"15.9.5.35 Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.36",name:"15.9.5.36 Date.prototype.setDate (date)"},{section:"x15.9.5.37",name:"15.9.5.37 Date.prototype.setUTCDate (date)"},{section:"x15.9.5.38",name:"15.9.5.38 Date.prototype.setMonth (month [, date ] )"},{section:"x15.9.5.39",name:"15.9.5.39 Date.prototype.setUTCMonth (month [, date ] )"},{section:"x15.9.5.40",name:"15.9.5.40 Date.prototype.setFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.41",name:"15.9.5.41 Date.prototype.setUTCFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.42",name:"15.9.5.42 Date.prototype.toUTCString ( )"},{section:"x15.9.5.43",name:"15.9.5.43 Date.prototype.toISOString ( )"},{section:"x15.9.5.44",name:"15.9.5.44 Date.prototype.toJSON ( key )"},{section:"x15.9.6",name:"15.9.6 Properties of Date Instances"},{section:"x15.10",name:"15.10 RegExp (Regular Expression) Objects"},{section:"x15.10.1",name:"15.10.1 Patterns"},{section:"x15.10.2",name:"15.10.2 Pattern Semantics"},{section:"x15.10.2.1",name:"15.10.2.1 Notation"},{section:"x15.10.2.2",name:"15.10.2.2 Pattern"},{section:"x15.10.2.3",name:"15.10.2.3 Disjunction"},{section:"x15.10.2.4",name:"15.10.2.4 Alternative"},{section:"x15.10.2.5",name:"15.10.2.5 Term"},{section:"x15.10.2.6",name:"15.10.2.6 Assertion"},{section:"x15.10.2.7",name:"15.10.2.7 Quantifier"},{section:"x15.10.2.8",name:"15.10.2.8 Atom"},{section:"x15.10.2.9",name:"15.10.2.9 AtomEscape"},{section:"x15.10.2.10",name:"15.10.2.10 CharacterEscape"},{section:"x15.10.2.11",name:"15.10.2.11 DecimalEscape"},{section:"x15.10.2.12",name:"15.10.2.12 CharacterClassEscape"},{section:"x15.10.2.13",name:"15.10.2.13 CharacterClass"},{section:"x15.10.2.14",name:"15.10.2.14 ClassRanges"},{section:"x15.10.2.15",name:"15.10.2.15 NonemptyClassRanges"},{section:"x15.10.2.16",name:"15.10.2.16 NonemptyClassRangesNoDash"},{section:"x15.10.2.17",name:"15.10.2.17 ClassAtom"},{section:"x15.10.2.18",name:"15.10.2.18 ClassAtomNoDash"},{section:"x15.10.2.19",name:"15.10.2.19 ClassEscape"},{section:"x15.10.3",name:"15.10.3 The RegExp Constructor Called as a Function"},{section:"x15.10.3.1",name:"15.10.3.1 RegExp(pattern, flags)"},{section:"x15.10.4",name:"15.10.4 The RegExp Constructor"},{section:"x15.10.4.1",name:"15.10.4.1 new RegExp(pattern, flags)"},{section:"x15.10.5",name:"15.10.5 Properties of the RegExp Constructor"},{section:"x15.10.5.1",name:"15.10.5.1 RegExp.prototype"},{section:"x15.10.6",name:"15.10.6 Properties of the RegExp Prototype Object"},{section:"x15.10.6.1",name:"15.10.6.1 RegExp.prototype.constructor"},{section:"x15.10.6.2",name:"15.10.6.2 RegExp.prototype.exec(string)"},{section:"x15.10.6.3",name:"15.10.6.3 RegExp.prototype.test(string)"},{section:"x15.10.6.4",name:"15.10.6.4 RegExp.prototype.toString()"},{section:"x15.10.7",name:"15.10.7 Properties of RegExp Instances"},{section:"x15.10.7.1",name:"15.10.7.1 source"},{section:"x15.10.7.2",name:"15.10.7.2 global"},{section:"x15.10.7.3",name:"15.10.7.3 ignoreCase"},{section:"x15.10.7.4",name:"15.10.7.4 multiline"},{section:"x15.10.7.5",name:"15.10.7.5 lastIndex"},{section:"x15.11",name:"15.11 Error Objects"},{section:"x15.11.1",name:"15.11.1 The Error Constructor Called as a Function"},{section:"x15.11.1.1",name:"15.11.1.1 Error (message)"},{section:"x15.11.2",name:"15.11.2 The Error Constructor"},{section:"x15.11.2.1",name:"15.11.2.1 new Error (message)"},{section:"x15.11.3",name:"15.11.3 Properties of the Error Constructor"},{section:"x15.11.3.1",name:"15.11.3.1 Error.prototype"},{section:"x15.11.4",name:"15.11.4 Properties of the Error Prototype Object"},{section:"x15.11.4.1",name:"15.11.4.1 Error.prototype.constructor"},{section:"x15.11.4.2",name:"15.11.4.2 Error.prototype.name"},{section:"x15.11.4.3",name:"15.11.4.3 Error.prototype.message"},{section:"x15.11.4.4",name:"15.11.4.4 Error.prototype.toString ( )"},{section:"x15.11.5",name:"15.11.5 Properties of Error Instances"},{section:"x15.11.6",name:"15.11.6 Native Error Types Used in This Standard"},{section:"x15.11.6.1",name:"15.11.6.1 EvalError"},{section:"x15.11.6.2",name:"15.11.6.2 RangeError"},{section:"x15.11.6.3",name:"15.11.6.3 ReferenceError"},{section:"x15.11.6.4",name:"15.11.6.4 SyntaxError"},{section:"x15.11.6.5",name:"15.11.6.5 TypeError"},{section:"x15.11.6.6",name:"15.11.6.6 URIError"},{section:"x15.11.7",name:"15.11.7 NativeError Object Structure"},{section:"x15.11.7.1",name:"15.11.7.1 NativeError Constructors Called as Functions"},{section:"x15.11.7.2",name:"15.11.7.2 NativeError (message)"},{section:"x15.11.7.3",name:"15.11.7.3 The NativeError Constructors"},{section:"x15.11.7.4",name:"15.11.7.4 New NativeError (message)"},{section:"x15.11.7.5",name:"15.11.7.5 Properties of the NativeError Constructors"},{section:"x15.11.7.6",name:"15.11.7.6 NativeError.prototype"},{section:"x15.11.7.7",name:"15.11.7.7 Properties of the NativeError Prototype Objects"},{section:"x15.11.7.8",name:"15.11.7.8 NativeError.prototype.constructor"},{section:"x15.11.7.9",name:"15.11.7.9 NativeError.prototype.name"},{section:"x15.11.7.10",name:"15.11.7.10 NativeError.prototype.message"},{section:"x15.11.7.11",name:"15.11.7.11 Properties of NativeError Instances"},{section:"x15.12",name:"15.12 The JSON Object"},{section:"x15.12.1",name:"15.12.1 The JSON Grammar "},{section:"x15.12.1.1",name:"15.12.1.1 The JSON Lexical Grammar"},{section:"x15.12.1.2",name:"15.12.1.2 The JSON Syntactic Grammar"},{section:"x15.12.2",name:"15.12.2 parse ( text [ , reviver ] )"},{section:"x15.12.3",name:"15.12.3 stringify ( value [ , replacer [ , space ] ] )"},{section:"x16",name:"16 Errors"},{section:"A",name:"Annex A (informative) Grammar Summary"},{section:"A.1",name:"A.1 Lexical Grammar"},{section:"A.2",name:"A.2 Number Conversions"},{section:"A.3",name:"A.3 Expressions"},{section:"A.4",name:"A.4 Statements"},{section:"A.5",name:"A.5 Functions and Programs"},{section:"A.6",name:"A.6 Universal Resource Identifier Character Classes"},{section:"A.7",name:"A.7 Regular Expressions"},{section:"A.8",name:"A.8 JSON"},{section:"A.8.1",name:"A.8.1 JSON Lexical Grammar"},{section:"A.8.2",name:"A.8.2 JSON Syntactic Grammar"},{section:"B",name:"Annex B (informative) Compatibility"},{section:"B.1",name:"B.1 Additional Syntax"},{section:"B.1.1",name:"B.1.1 Numeric Literals"},{section:"B.1.2",name:"B.1.2 String Literals"},{section:"B.2",name:"B.2 Additional Properties"},{section:"B.2.1",name:"B.2.1 escape (string)"},{section:"B.2.2",name:"B.2.2 unescape (string)"},{section:"B.2.3",name:"B.2.3 String.prototype.substr (start, length)"},{section:"B.2.4",name:"B.2.4 Date.prototype.getYear ( )"},{section:"B.2.5",name:"B.2.5 Date.prototype.setYear (year)"},{section:"B.2.6",name:"B.2.6 Date.prototype.toGMTString ( )"},{section:"C",name:"Annex C (informative) The Strict Mode of ECMAScript"},{section:"D",name:"Annex D (informative) Corrections and Clarifications in the 5th Edition with Possible 3rd Edition Compatibility Impact"},{section:"E",name:"Annex E (informative) Additions and Changes in the 5th Edition that Introduce Incompatibilities with the 3rd Edition"},{section:"bibliography",name:"Bibliography"}],bot.addCommand({name:"spec",fun:e,permissions:{del:"NONE"},description:"Find a section in the ES5 spec"}) +}(),function(){var e,t=/(which |what |give me a )?stargate|sg1( episode)?/i;e={SG1:{"Season 1":["Children of the Gods","The Enemy Within","Emancipation","The Broca Divide","The First Commandment","Brief Candle","Cold Lazarus","Thor's Hammer","The Torment of Tantalus","Bloodlines","Fire and Water","The Nox","Hathor","Singularity","Cor-ai","Enigma","Tin Man","Solitudes","There But for the Grace of God ","Politics ","Within the Serpent's Grasp "],"Season 2":["The Serpent's Lair ","In the Line of Duty","Prisoners","The Gamekeeper","Need","Thor's Chariot","Message in a Bottle","Family","Secrets","Bane","The Tok'ra","The Tok'ra (Part 2)","Spirits","Touchstone","A Matter of Time","The Fifth Race","Serpent's Song","Holiday","One False Step","Show and Tell","1969","Out of Mind "],"Season 3":["Into the Fire ","Seth","Fair Game","Legacy","Learning Curve","Point of View","Deadman Switch","Demons","Rules of Engagement","Forever in a Day","Past and Present","Jolinar's Memories ","The Devil You Know ","Foothold","Pretense","Urgo","A Hundred Days","Shades of Grey","New Ground","Maternal Instinct","Crystal Skull","Nemesis "],"Season 4":["Small Victories ","The Other Side","Upgrades","Crossroads","Divide and Conquer","Window of Opportunity","Watergate","The First Ones","Scorched Earth","Beneath the Surface","Point of No Return","Tangent","The Curse","The Serpent's Venom","Chain Reaction","2010","Absolute Power","The Light","Prodigy","Entity","Double Jeopardy ","Exodus "],"Season 5":["Enemies ","Threshold ","Ascension","The Fifth Man","Red Sky","Rite of Passage","Beast of Burden","The Tomb","Between Two Fires","2001","Desperate Measures","Wormhole X-Treme!","Proving Ground","48 Hours","Summit ","Last Stand ","Fail Safe","The Warrior","Menace","The Sentinel","Meridian","Revelations"],"Season 6":["Redemption","Redemption (Part 2)","Descent","Frozen","Nightwalkers","Abyss","Shadow Play","The Other Guys","Allegiance","Cure","Prometheus ","Unnatural Selection ","Sight Unseen","Smoke & Mirrors","Paradise Lost","Metamorphosis","Disclosure","Forsaken","The Changeling","Memento","Prophecy","Full Circle"],"Season 7":["Fallen ","Homecoming ","Fragile Balance","Orpheus","Revisions","Lifeboat","Enemy Mine","Space Race","Avenger 2.0","Birthright","Evolution","Evolution (Part 2)","Grace","Fallout","Chimera","Death Knell","Heroes","Heroes (Part 2)","Resurrection","Inauguration","Lost City","Lost City (Part 2)"],"Season 8":["New Order","New Order (Part 2)","Lockdown","Zero Hour","Icon","Avatar","Affinity","Covenant","Sacrifices","Endgame","Gemini","Prometheus Unbound","It's Good to Be King","Full Alert","Citizen Joe","Reckoning","Reckoning (Part 2)","Threads","Moebius","Moebius (Part 2)"],"Season 9":["Avalon","Avalon (Part 2)","Origin ","The Ties That Bind","The Powers That Be","Beachhead","Ex Deus Machina","Babylon","Prototype","The Fourth Horseman","The Fourth Horseman (Part 2)","Collateral Damage","Ripple Effect","Stronghold","Ethon","Off the Grid","The Scourge","Arthur's Mantle","Crusade","Camelot "],"Season 10":["Flesh and Blood ","Morpheus","The Pegasus Project","Insiders","Uninvited","200","Counterstrike","Memento Mori","Company of Thieves","The Quest","The Quest (Part 2)","Line in the Sand","The Road Not Taken","The Shroud","Bounty","Bad Guys","Talion","Family Ties","Dominion","Unending"]}};var n=function(t){if(-1===t.indexOf("episode")&&Math.random()<.05)return"Stargate (movie)";var n=function(e){var t=Math.rand(e.length-1);return{value:e[t],index:t}},o=n(Object.keys(e.SG1)),r=n(e.SG1[o.value]),i={season:o.value,index:r.index+1,episode:r.value};return"{season} episode #{index} - {episode}".supplant(i)};bot.listen(t,n)}(),function(){"use strict";function e(e,n){function o(n){if(n.error_message)return void r(n.error_message);var o,i=n.items[0];o=i?t(i,e):"User "+a+" not found",r(o)}function r(t){n?n(t):e.reply(t)}var i=e.parse(),a=i[0];return a?/^\d+$/.test(a)||(a=e.findUserId(i.length>1?a:i.join(" "))):a=e.get("user_id"),0>a?"User Elusio proved elusive.":Math.random()<=.1?void r("That dude sucks"):void IO.jsonp({url:"https://api.stackexchange.com/2.2/users/"+a,data:{site:bot.adapter.site,filter:"!P)usXx8OGi3Eq5LdDJke7ybvCSm_vuVGrSDZs3)UmEI"},fun:o})}function t(e,t){return e=n(e),e.user_id===t.get("user_id")?(e.display_name="You",e.indicative="have"):(e.display_name=IO.decodehtmlEntities(e.display_name),e.indicative="has"),r.supplant(e)}function n(e){return e=Object.merge({question_count:0,answer_count:0,reputation_change_day:0},e.badge_counts,e),e=Object.merge(e.badge_counts,e),e.avg_rep_post=(e.reputation/(e.question_count+e.answer_count)).maxDecimal(2),1/0===e.avg_rep_post&&(e.avg_rep_post="T͎͍̘͙̖̤̉̌̇̅ͯ͋͢͜͝H̖͙̗̗̺͚̱͕̒́͟E̫̺̯͖͎̗̒͑̅̈ ̈ͮ̽ͯ̆̋́͏͙͓͓͇̹<̩̟̳̫̪̇ͩ̑̆͗̽̇͆́ͅC̬͎ͪͩ̓̑͊ͮͪ̄̚̕Ě̯̰̤̗̜̗͓͛͝N̶̴̞͇̟̲̪̅̓ͯͅT͍̯̰͓̬͚̅͆̄E̠͇͇̬̬͕͖ͨ̔̓͞R͚̠̻̲̗̹̀>̇̏ͣ҉̳̖̟̫͕ ̧̛͈͙͇͂̓̚͡C͈̞̻̩̯̠̻ͥ̆͐̄ͦ́̀͟A̛̪̫͙̺̱̥̞̙ͦͧ̽͛̈́ͯ̅̍N̦̭͕̹̤͓͙̲̑͋̾͊ͣŅ̜̝͌͟O̡̝͍͚̲̝ͣ̔́͝Ť͈͢ ̪̘̳͔̂̒̋ͭ͆̽͠H̢͈̤͚̬̪̭͗ͧͬ̈́̈̀͌͒͡Ơ̮͍͇̝̰͍͚͖̿ͮ̀̍́L͐̆ͨ̏̎͡҉̧̱̯̤̹͓̗̻̭ͅḐ̲̰͙͑̂̒̐́̊"),e.ratio=o(e.question_count,e.answer_count),bot.log(e,"/stat normalized"),e}function o(e,t){if(!e&&t)return"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ";if(!t&&e)return"TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡";if(!t&&!e)return"http://i.imgur.com/F79hP.png";Math.gcd(e,t);return Math.ratio(e,t)}var r="{display_name} ({link}) {indicative} {reputation} reputation, earned {reputation_change_day} rep today, asked {question_count} questions, gave {answer_count} answers, for a q:a ratio of {ratio}.\navg. rep/post: {avg_rep_post}. Badges: {gold}g {silver}s {bronze}b ",i={name:"stat",fun:e,permissions:{del:"NONE"},description:"Gives useless stats on a user. `/stat usrid|usrname [extended]`",async:!0};bot.addCommand(i);var a=Object.merge(i,{name:"stats"});bot.addCommand(a)}(),function(){function e(e){var r=RegExp(e.matches[2],e.matches[4]),i=e.matches[3];if(!e.matches[2])return"Empty regex is empty";var a;a=e.matches[5]?Array.from(document.querySelectorAll("#message-"+e.matches[5]+" .content")):Array.from(document.getElementsByClassName("content")).reverse(),t(r,a,e.get("message_id"),function(t,a){function s(t){var n=t.replace(r,i)+" "+e.link("(source)",c);e.reply(n)}if(t)return void e.reply(t);if(!a)return void e.reply("No matching message (are you sure we're in the right room?)");bot.log(a,"substitution found message");var c=n(a);a.getElementsByClassName("partial").length?o(a,s):s(a.textContent)})}function t(e,t,n,o){bot.log(e,t,n,"substitution getMatchingMessage args");var r={maxId:n,pattern:e,messages:t.map(function(e){return{id:Number(e.parentElement.id.match(/\d+/)[0]),text:e.textContent}})},i=function(){var e=arguments[1],t=null;e.messages.some(function(n,o){return n.id-1?void this.removeMultiple(e.split(" "),n):void("~"===e[0]?this.byLookback(e.slice(1),n):"*"===e[0]||"x"===e[0]?this.byPrevious(e.slice(1),n):/^:?\d+$/.test(e)?this.remove(e.replace(/^:/,""),n):e.content?n("I'm not sure how to handle that, see `/help undo`"):this.ids.length?this.remove(this.ids[this.ids.length-1],n):n("I haven't said a thing!"))},removeMultiple:function(e,t){e.forEach(function(e){this.remove(e,t)},this)},byLookback:function(e,t){var n=Number(e.replace("~",""));return bot.log(e,n,this.ids.length-n,"/undo byLookback"),!n||n>this.ids.length?void t("I can't quite see that far back without my glasses"):void this.remove(this.ids[this.ids.length-n],t)},byPrevious:function(e,t){var n=Number(e);return n?this.removeMultiple(this.ids.slice(-e),t):void t("Yeah, no")},remove:function(t,n){function o(o,r){if(409===r.status)return bot.log(r,"/undo remove finish 409"),void e.retry(t,n,o);var i;'"ok"'!==o&&(i=/it is too late/i.test(o)?"TimeError: Could not reach 88mph":/only delete your own/i.test(o)?"I can only delete my own messages":"I have no idea what happened: "+o,n(i))}console.log(t,"/undo remove");var r=this.ids.indexOf(t);r>-1&&this.ids.splice(r,1),IO.xhr({url:"/messages/"+t+"/delete",data:fkey(),method:"POST",complete:o})},retry:function(e,t,n){var o=/(\d+) seconds\s*$/i.exec(n),r=4;o&&o[1]&&(r=Number(o[1])),setTimeout(this.remove.bind(this,e,t),1e3*r)},update_id:function(e){this.ids.push(JSON.parse(e.responseText).id)}};IO.register("sendoutput",e.update_id,e),bot.addCommand({name:"undo",fun:e.command,thisArg:e,permissions:{del:"NONE",use:"OWNER"},description:"Undo (delete) specified or last message. `/undo [msgid0, msgid1, ...]` (omit for last message); `/undo xN` for last N; `/undo ~N` for the Nth message from the end"})}(),function(){function e(e,n){var o=bot.users[e.user_id],r=e.message_id;bot.log("[formatting] Lecturing user "+e.user_name),bot.adapter.out.add(bot.adapter.reply(e.user_name)+" "+t(n)),o&&o.reputation<2e3&&(bot.log("[formatting] Binning offending message"),bot.adapter.moveMessage(r,e.room_id,23262))}function t(e){var t=e.split("\n").length,n="Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the {0}.".supplant(bot.adapter.link("faq","/faq"));return t>=10&&(n+=" For posting large code blocks, use a paste site like https://gist.github.com, http://hastebin.com or http://pastie.org"),n}function n(e){var t=e.split("\n");if(t.length<4)return!1;var n=/^\}|^<\//;return t.some(/ /.test.bind(n))}if("stackoverflow"!==bot.adapter.site||17!==bot.adapter.roomid)return void bot.log("Not activating unformatted code checking; not in right room/site");var o=new Map;IO.register("rawinput",function(t){function r(){o.has(i)&&(bot.log("[formatting] Message {0} was fixed".supplant(i)),clearTimeout(o.get(i)),o["delete"](i))}var i=t.message_id;if((1===t.event_type||2===t.event_type)&&17===t.room_id&&!bot.isOwner(t.user_id)){if(!t.content.startsWith("
"))return void r();var a=bot.adapter["in"].breakMultilineMessage(t.content).map(function(e){return e.replace(/^ /,"")}).join("\n");if(a=IO.decodehtmlEntities(a),a.startsWith("
"))return void r();var s=n(a);if(!s)return void r();bot.log("[formatting] Message {0} is a naughty one".supplant(i));var c=setTimeout(e,1e4,t,a);o.set(i,c)}})}(),function(){"use strict";var e="unonebox-state",t=9e4,n={enablers:Object.TruthMap(["yes","on","true","start","1","enable"]),disablers:Object.TruthMap(["no","off","false","stop","0","disable"]),command:function(t){var n,o=t.toLowerCase(),r=!1;o?this.enablers[o]?(bot.log("/unonebox enabling"),this.enable(),n="un-onebox enabled",r=!0):this.disablers[o]?(bot.log("/unonebox disabling"),this.disable(),n="un-onebox disabled",r=!0):(bot.log("/unonebox invalid input"),n="That didn't make much sense. Please use `on` or `off` to toggle the command"):(bot.log("/unonebox getting state"),n="Functionality is "+bot.memory.get(e,"disabled")),r&&bot.memory.save(e),t.reply(n)},enable:function(){IO.register("input",this.unbox),bot.memory.set(e,"enabled")},disable:function(){IO.unregister("input",this.unbox),bot.memory.set(e,"disabled")},unbox:function(e){if(e.user_id===bot.adapter.user_id){var o=document.createElement("div");o.innerHTML=e.content;var r=o.querySelector(".onebox:not(.ob-youtube):not(.ob-message):not(.ob-wikipedia) a");r&&!r.parentNode.parentNode.classList.contains("quote")&&(bot.log(e,"/unonebox found matching message"),setTimeout(function(){n.actuallyUnbox(e.message_id,r.href)},t))}},actuallyUnbox:function(e,t){IO.xhr({url:"/messages/"+e,data:fkey({text:t+" ... "}),method:"POST",complete:function(e,t){bot.log(t,"/unonebox done unboxing")}})}};"enabled"===bot.memory.get(e,"disabled")&&(bot.log("enabling unonebox"),n.enable()),bot.addCommand({name:"unonebox",fun:n.command,thisArg:n,permissions:{del:"NONE"},description:"Get/toggle the unonebox listener. `/unonebox [on|off]x`"})}(),function(){function e(e,n){function o(n){var o;o="no_results"===n.result_type?"No definition found for "+s:c>n.list.length?"Nothing in that index. The last one is:\n"+i(n.list.pop()):i(n.list[c]),o.length>500&&(o=o.slice(0,450)+"(snip)"),t[e]=o,r(o)}function r(t){n&&n.call?n(t):e.reply(t)}function i(t){var n=t.definition.replace(/\[([^\]]+)\]/g,a);return e.link(t.word,t.permalink)+" "+n}function a(t,n){var o="http://urbandictionary.com/define.php?term="+encodeURIComponent(n);return e.link(t,o)}if(t[e])return r(t[e]);var s,c,u=e.parse();return u.length?(isNaN(u[1])?(bot.log("/urban input isNaN"),s=e.toString(),c=0):(bot.log("/urban input isn't NaN"),s=u[0],c=Number(u[1])),bot.log(s,c,"/urban input"),void IO.jsonp({url:"http://api.urbandictionary.com/v0/define",data:{term:s},jsonpName:"callback",fun:o})):"Y U NO PROVIDE ARGUMENTS!?"}var t={};bot.addCommand({name:"urban",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches UrbanDictionary definition. `/urban query [resultIndex=0]`",async:!0})}(),bot.addCommand({name:"user",fun:function(){return"Command deprecated. If you want it to stay, ping Zirak."},permissions:{del:"NONE",use:"ALL"},description:"Fetches user-link for specified user. `/user usr_id|usr_name`"}),IO.register("input",function(e){1386886===e.user_id&&Math.random()<.005&&bot.adapter.out.add(bot.adapter.reply(e.user_name)+" The Game")}),function(){var e,t,n,o=/^\s*(choose|should)?.*\sor\s[^$]/i,r=new RegExp("\\b("+["am","are","can","could","did","do","does","is","may","might","shall","should","will","would"].map(RegExp.escape).join("|")+")\\b","i"),i={he:"He",i:"You",it:"It",she:"She",they:"They",we:"You",you:"I"};t=["SSdtIG5vdCBzdXJl","RVJST1IgQ0FMQ1VMQVRJTkcgUkVTVUxU","SSBrbm93IGp1c3Qgb25lIHRoaW5nLCBhbmQgdGhhdCBpcyB0aGF0IEknbSBhIGx1bWJlcmphY2s="].map(atob),n=["VGhhdCdzIG5vdCByZWFsbHkgYSBjaG9pY2UsIG5vdyBpcyBpdD8=","U291bmRzIGxpa2UgeW91IGhhdmUgYWxyZWFkeSBkZWNpZGVk","Q2hlYXRlciBjaGVhdGVyIHlvdXIgaG91c2UgaXMgYSBoZWF0ZXI="].map(atob),e=["QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5","Q2VydGFpbmx5","Q2VydGFpbmx5","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","SSBjYW4gbmVpdGhlciBjb25maXJtIG5vciBkZW55","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSdtIG5vdCBzbyBzdXJlIGFueW1vcmUuIEl0IGNhbiBnbyBlaXRoZXIgd2F5","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW5kZWVk","SW5kZWVk","SW5kZWVk","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","Tm8gd2F5","Tm8gd2F5","Tm8gd2F5","Tm8=","Tm8=","Tm8=","Tm8=","Tm9wZQ==","Tm9wZQ==","Tm9wZQ==","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","TnVoLXVo","TnVoLXVo","TnVoLXVo","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","UHJvYmFibHk=","UHJvYmFibHk=","UHJvYmFibHk=","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5"].map(atob),bot.listen(o,function(e){function o(){var t;do t=s.random();while(t===l);e.reply("Wait, I changed my mind! "+r(t))}function r(e){return e.replace(/(should(?:n'?t)?) (\S+)/,a)}function a(e,t,n){var o,r=n.toLowerCase();return o=i.hasOwnProperty(r)?i[r]:n,o+" "+t}for(var s=e.replace(/^\s*choose\s/i,"").replace(/\?$/,"").split(/\s*\bor\b\s*/i).filter(Boolean),c=s.length,u=1,m=!0;c>u;u++)if(s[u]!==s[u-1]){m=!1;break}if(m)return n.random();if(Math.random()<.01)return 2===c?"Both!":"All of them!";if(Math.random()<.01)return 2===c?"Neither":"None of them!";if(Math.random()<.01)return t.random();var l=s.random();return Math.random()<.01&&(bot.log("weasel decision mind change jedi nun-chuck"),setTimeout(o,1e4)),r(l)}),bot.listen(r,function(){return e.random()})}(),function(){"use strict";function e(e){var t=o.exec(e);if(t)n.latlon(t[1],t[2],e.reply.bind(e));else{if(!e.content)return"See `/help weather` for usage info";n.city(e.content,e.reply.bind(e))}}var t=Object.TruthMap(["US","United States of America","United States","BZ","Belize","BS","Bahamas","KY","Cayam Islands"]),n={latlon:function(e,t,n){var o=Number(e),r=Number(t),i=[];return(-180>o||o>180)&&i.push("Latitude must be between -180 and 180"),(-180>r||r>180)&&i.push("Longitude must be between -180 and 180"),i.length?void n(i.join("; ")):void IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{lat:e,lon:t,cnt:1,type:"json"},fun:this.finishCb(n),error:this.errorCb(n)})},city:function(e,t){IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{q:e,type:"json"},fun:this.finishCb(t),error:this.errorCb(t)})},finishCb:function(e){var t=this;return function(n){e(t.format(n))}},errorCb:function(e){return e},format:function(e){var t=e.main;return t?this.formatter(e):(console.error(e),"Sorry, I couldn't get the data: "+e.message)},formatter:function(e){var n,o=e.main;o.celsius=(o.temp-273.15).maxDecimal(4),n=bot.adapter.link(e.name,"http://openweathermap.org/city/"+e.id)+": ",t[e.sys.country]?(o.fahrenheit=(9*o.temp/5-459.67).maxDecimal(4),n+="{fahrenheit}F ({celsius}C, {temp}K)".supplant(o)):n+="{celsius}C ({temp}K)".supplant(o);var r=(e.weather||[]).map(function(e){return e.description}).join(", ");return r&&(n+=", "+r),n}},o=/\((-?\d+\.?\d*),\s*(-?\d+\.?\d*)\)/;bot.addCommand({name:"weather",fun:e,permissions:{del:"NONE"},async:!0,description:"Gets current weather: `/weather (lan, lon)` or `/weather city`"})}(),function(){"use strict";function e(e,t){bot.adapter.out.add(bot.adapter.reply(e)+" "+o,t)}var t=bot.memory.get("users"),n=17,o="Welcome to the JavaScript chat! Please review the "+bot.adapter.link("room pseudo-rules","http://rlemon.github.com/so-chat-javascript-rules/")+". Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.";IO.register("input",function(o){function r(t){var o,r=t.querySelector("#room-"+n+" .room-message-count");o=r?Number(/^\d+/.exec(r.title))<2:!0,o&&e(c.name,u),i()}function i(e){e?delete t[s]:t[s]=!0,bot.memory.save("users")}function a(e){return bot.isOwner(e.id)||e.reputation>1e3||e.reputation<20}var s=o.user_id,c=bot.users[o.user_id],u=o.room_id,m=c&&a(c);return Number(u)!==n||m||t[o.user_id]?void(m&&i(!0)):void IO.xhr({method:"GET",url:"/users/"+s,document:!0,complete:r})}),bot.addCommand({name:"welcome",fun:function(t){return t.length?void e(t,t.get("room_id")):o},permission:{del:"NONE"},description:"Welcomes a user. `/welcome user`"})}(),function(){"use strict";function e(e,t){function n(n){var o=n[3][0],r=!0;o||(r=!1,o=["No result found","The Wikipedia contains no knowledge of such a thing","The Gods of Wikipedia did not bless us"].random()),t&&t.call?t(o):r?e.directreply(o):e.reply(o)}IO.jsonp({url:"http://en.wikipedia.org/w/api.php",jsonpName:"callback",data:{action:"opensearch",search:e.toString(),limit:1,format:"json"},fun:n})}bot.addCommand({name:"wiki",fun:e,permissions:{del:"NONE"},description:"Search Wikipedia. `/wiki term`",async:!0})}(),function(){function e(e,t){function n(e){var t=e.num;i?"new"===i&&r(a+t):r(a+Math.rand(1,t))}function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results;if(!t.length)return void r("Seems like you hallucinated this comic");var n=t[0],o=n.url,i=/xkcd.com\/(\d+)/.exec(o);i||(o="Search didn't yield a comic; got "+n.unescapedUrl),r(o)}function r(n){bot.log(n,"/xkcd finish"),n=n.replace(/^https:/,"http:"),t&&t.call?t(n):e.directreply(n)}var i=(e.parse()[0]||"").toLowerCase(),a="http://xkcd.com/";return/^\d+$/.test(i)?(bot.log("/xkcd specific",i),void r(a+i)):i&&"new"!==i?(bot.log("/xkcd search",e.toString()),void IO.jsonp.google(e.toString()+" site:xkcd.com -forums.xkcd -m.xkcd -fora.xkcd",o)):(bot.log("/xkcd random/latest",i),void IO.jsonp({url:"http://dynamic.xkcd.com/api-0/jsonp/comic",jsonpName:"callback",fun:n}))}bot.addCommand({name:"xkcd",fun:e,permissions:{del:"NONE"},description:"Returns an XKCD. Call with no args for random, `new` for latest, or a number for a specific one.",async:!0})}(),function(){function e(e,n){function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var n=e.responseData.results[0];bot.log(n,"/youtube result"),r(n?decodeURIComponent(n.url):t.random())}function r(t){n&&n.call?n(t):e.directreply(t)}IO.jsonp.google(e.toString()+" site:youtube.com/watch",o)}var t=["Video not found (rule 35?)","I could not find such a video","The Lords of YouTube did not find your query favorable"];bot.addCommand({name:"youtube",fun:e,permissions:{del:"NONE"},description:"Search Youtube. `/youtube query`",async:!0})}(),function(){var e=function(e){var t,n,o,r=function(e){return Math.floor(Math.random()*e)},i=e.split(""),a=[0,1,2].random(),s=["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈́","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],c=["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],u=["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͏","͜","͝","͞","͟","͠","͢","̸","̷","͡","҉"],m="",l=0,d="A̪̗̐̿̄̔̉̏̾L̹͓̲̈́ͮL̜̼͓͉̞̘̩̇̊",p=i.length;1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2);var h;h="T̷̂͒̃̽H̸͒̿̒̚̕͜E͋ͥ̋̈̉̏̏̔̔͞ ̏ͥ̊͠P̷̑̌̀O̵̔̑̇̐͌̓̀̚Ǹ͌̍̾̈҉Y͛̈́̉҉͘";for(var l=0;p>l;l++){m+=i[l],d++,a||(t=r(8),n=r(8),o=r(6)),1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2),2==a&&(t=r(64)/4+3,n=r(64)/4+3,o=r(16)/4+1);for(var f=0;t>f;f++)m+=s.random();for(var f=0;o>f;f++)m+=u.random();for(var f=0;n>f;f++)m+=c.random()}return m||/<([a-z]+) *[^\/]*?>/};bot.addCommand({name:"zalgo",fun:e,permissions:{del:"NONE"},description:"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ http://stackoverflow.com/a/1732454/1216976"})}();
\ No newline at end of file
diff --git a/socket-saver.user.js b/socket-saver.user.js
new file mode 100644
index 0000000..fe79761
--- /dev/null
+++ b/socket-saver.user.js
@@ -0,0 +1,27 @@
+// ==UserScript==
+// @name         SO-Chat-Socket-Saver
+// @namespace    http://awal.js.org/
+// @version      0.1
+// @description  i dunno what to put this is a template lmao
+// @author       awal
+// @match        *://chat.stackoverflow.com/rooms/*
+// @match        *://meta.chat.stackexchange.com/rooms/*
+// @match        *://chat.stackexchange.com/rooms/*
+// @grant        none
+// @run-at       document-start
+// ==/UserScript==
+
+if (document.body) {
+	console.warn('Socket Saver: Not properly running at document-start, setup shit properly FFS!');
+} else {
+    // we are running at document-start properly. yipee!!
+    Object.defineProperty(WebSocket.prototype, 'onopen', {
+        set: function (val) {
+            if (this.url.startsWith('wss://chat.sockets.stackexchange.com')) {
+                console.info('Socket Saver: socket saved properly, use it with window.__stackexchange_chat_saved_socket');
+                window.__stackexchangeChatSavedSocket = this;
+                window.dispatchEvent(new CustomEvent('stackexchange-socket-saved'));
+            }
+        }
+    });
+}
diff --git a/source/adapter.js b/source/adapter.js
index 726b680..12a0628 100644
--- a/source/adapter.js
+++ b/source/adapter.js
@@ -288,22 +288,32 @@ var polling = bot.adapter.in = {
 	},
 
 	openSocket : function ( url, discard ) {
-		//chat sends an l query string parameter. seems to be the same as the
-		// since xhr parameter, but I didn't know what that was either so...
-		//putting in 0 got the last shitload of messages, so what does a high
-		// number do? (spoiler: it "works")
-		var socket = new WebSocket( url + '?l=99999999999' );
-
-		if ( discard ) {
-			socket.onmessage = function () {
-				socket.close();
-			};
-		}
-		else {
-			this.socket = socket;
-			socket.onmessage = this.ondata.bind( this );
-			socket.onclose = this.socketFail.bind( this );
+		var socket;
+		// socket-saver extension specific code:
+		if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' ) {
+			var potentialSocket = window.__stackexchangeChatSavedSocket;
+			console.assert( potentialSocket.constructor === window.WebSocket );
+			console.assert( potentialSocket.url.startsWith( 'wss://chat.sockets.stackexchange.com' ) );
+			socket = potentialSocket;
+		} else {
+			//chat sends an l query string parameter. seems to be the same as the
+			// since xhr parameter, but I didn't know what that was either so...
+			//putting in 0 got the last shitload of messages, so what does a high
+			// number do? (spoiler: it "works")
+			socket = new WebSocket( url + '?l=99999999999' );
+
+			if ( discard ) {
+				socket.onmessage = function () {
+					socket.close();
+				};
+				return;
+			}
 		}
+		this.socket = socket;
+		socket.addEventListener( 'message', this.ondata.bind( this ) );
+		socket.addEventListener( 'close', this.socketFail.bind( this ) );
+		// socket.onmessage = this.ondata.bind( this );
+		// socket.onclose = this.socketFail.bind( this );
 	},
 
 	ondata : function ( messageEvent ) {

From bb14f2883c86933577f06664cc4331c0d17d53b2 Mon Sep 17 00:00:00 2001
From: awalGarg 
Date: Tue, 22 Sep 2015 14:31:58 +0530
Subject: [PATCH 2/3] fix join in a way

---
 master.js         | 2 +-
 master.min.js     | 2 +-
 source/adapter.js | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/master.js b/master.js
index fc3db06..e7b7fe7 100644
--- a/master.js
+++ b/master.js
@@ -2675,7 +2675,7 @@ var polling = bot.adapter.in = {
 	openSocket : function ( url, discard ) {
 		var socket;
 		// socket-saver extension specific code:
-		if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' ) {
+		if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' && !discard ) {
 			var potentialSocket = window.__stackexchangeChatSavedSocket;
 			console.assert( potentialSocket.constructor === window.WebSocket );
 			console.assert( potentialSocket.url.startsWith( 'wss://chat.sockets.stackexchange.com' ) );
diff --git a/master.min.js b/master.min.js
index dd26a6a..ec4afcb 100644
--- a/master.min.js
+++ b/master.min.js
@@ -1,3 +1,3 @@
-var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(t.toString()):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var r=e[t];return Array.isArray(r)?n(t,r):o(t,r)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.htmlToMarkdown=function(){var e={i:"*",b:"**",strike:"---",code:"`",a:function(e,t,n){var o=/href="([^"]+?)"/.exec(e);return o?"["+n+"]("+o[1]+")":e}},t=/<(\S+)[^\>]*>([^<]+)<\/\1>/g;return function(n){function o(t,n,o){return e.hasOwnProperty(n)?(r=e[n],r.apply?e[n].apply(e,arguments):r+o+r):t}var r;return n.replace(t,o)}}(),IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",zwnj:"",zwsp:""};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return t?"#"===t[0]?r(t):e.hasOwnProperty(t)?e[t]:"&"+t+";":""},r=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.relativeUrlToAbsolute=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.href},IO.injectScript=function(e){var t=document.createElement("script");return t.src=e,document.head.appendChild(t),t},IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),e.document&&(t.responseType="document"),t.addEventListener("load",function(){e.complete.call(e.thisArg,t.response,t)}),Object.iterate(e.headers,t.setRequestHeader.bind(t)),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+="&"+this.urlstringify(e.data),n.onerror=e.error,n.src=e.url,document.head.appendChild(n)},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},Object.iterate=function(e,t,n){Object.keys(e).forEach(function(o){t.call(n,o,e[o],e)})},Object.TruthMap=function(e){function t(e,t){return e[t]=!0,e}return(e||[]).reduce(t,Object.create(null))},Array.from=function(e,t){return[].slice.call(e,t)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){function t(t){var o=t;return t[e]&&t[e].apply&&(o=t[e].apply(t,n)),o}var n=Array.from(arguments,1);return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"pluck",{value:function(e){function t(t){try{return t[e]}catch(n){return t}}return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"random",{value:function(){return this[Math.floor(Math.random()*this.length)]},configurable:!0,writable:!0}),["forEach","map","filter","reduce"].forEach(function(e){var t=[][e];Array[e]=function(){return t.call.apply(t,arguments)}}),String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.supplant=function(e){function t(e,t){return n.hasOwnProperty(t)?n[t]:e}var n=Object(e)===e?e:arguments;return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Function.prototype.throttle=function(e){var t=this,n=-1,o=function(){clearTimeout(n);var o=this,r=arguments;n=setTimeout(function(){t.apply(o,r)},e)};return o},Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this;return e=e||function(e){return e},function(){function o(){t[a]=arguments,i.apply(null,arguments)}var r=Array.from(arguments),i=r.pop(),a=e.apply(null,arguments);return a in t?void i.apply(null,t[a]):(r.push(o),void n.apply(this,r))}},Function.prototype.stringContents=function(){return this.toString().replace(/^function\*?\s+\([^)]*\)\s*\{/,"").replace(/\}$/,"")},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Number.prototype.fallsAfter=function(e){e=e.slice();for(var t,n=e.shift(),o=this.valueOf(),r=0,i=e.length;i>r&&(t=e[r],!(t>o));r++)n=t;return o>=n?n:null},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},Math.rand=function(e,t){return"undefined"==typeof e?(e=0,t=9):"undefined"==typeof t&&(t=e,e=0),Math.floor(Math.random()*(t-e+1))+e},Object.defineProperty(RegExp.prototype,"toJSON",{value:function(){return this.toString()},configurable:!0,writable:!0}),RegExp.escape=function(e){return e.replace(/[-^$\\\/\.*+?()[\]{}|]/g,"\\$&")},Date.timeSince=function(e,t){function n(e,t){return e=Math.floor(e),t+=1===e?"":"s",e+" "+t}t=t||new Date;for(var o,r=t-e,i=[{delta:31536e6,suffix:"year"},{delta:2592e6,suffix:"month"},{delta:864e5,suffix:"day"},{delta:36e5,suffix:"hour"},{delta:6e4,suffix:"minute"},{delta:1e3,suffix:"second"}];i.length;)if(o=i.shift(),r>=o.delta)return n(r/o.delta,o.suffix);return n(r,"millisecond")},function(){"use strict";var bot=window.bot={invocationPattern:"!!",commands:{},commandDictionary:null,listeners:[],info:{invoked:0,learned:0,forgotten:0,start:new Date},users:{},parseMessage:function(e){if(!this.validateMessage(e))return void bot.log(e,"parseMessage invalid");var t=this.prepareMessage(e),n=t.get("user_id");if(bot.log(t,"parseMessage valid"),this.banlist.contains(n))return bot.log(e,"parseMessage banned"),void(this.banlist[n].told||(t.reply("You iz in mindjail"),this.banlist[n].told=!0));try{/^c?>/.test(t)?this.prettyEval(t.toString(),t.directreply.bind(t)):this.invokeAction(t)}catch(o){var r="Could not process input. Error: "+o.message;o.lineNumber&&(r+=" on line "+o.lineNumber),o.column&&(r+=" on column "+o.column),t.directreply(r),console.error(o.stack)}finally{this.info.invoked+=1}},invokeAction:function(e){var t=e.trim().replace(/^\/\s*/,"").split(" ")[0],n=this.getCommand(t),o=e.startsWith("/")?!n.error:!0;n.error?o&&(o=this.callListeners(e)):this.execCommand(n,e),o||e.reply(this.giveUpMessage(n.guesses))},giveUpMessage:function(e){var t="That didn't make much sense.";return t+=e&&e.length?" Maybe you meant: "+e.join(", "):" Use the `!!/help` command to learn more."},execCommand:function(e,t){if(bot.log(e,"execCommand calling"),!e.canUse(t.get("user_id")))return void t.reply(["You do not have permission to use the command "+e.name,"I'm afraid I can't let you do that, "+t.get("user_name")].random());var n=this.Message(t.replace(/^\/\s*/,"").slice(e.name.length).trim(),t.get()),o=e.exec(n);o&&t.reply(o)},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.htmlToMarkdown(e.content);return t=IO.decodehtmlEntities(t),t=t.replace(/\u200b|\u200c/g,""),this.Message(t.slice(this.invocationPattern.length).trim(),e)},validateMessage:function(e){var t=e.content.trim();return"!!"===this.invocationPattern&&/^!!!+$/.test(t)?(console.log("special skip"),!1):e.user_id!==bot.adapter.user_id&&e.user_id>0&&t.startsWith(this.invocationPattern)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),e.learned&&(this.info.learned+=1),e.invoked=0,this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){var t=e.toLowerCase();if(this.commandExists(t))return this.commands[t];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var n="Command "+e+" does not exist.",o=this.commandDictionary.search(e);return o.length&&(n+=" Did you mean: "+o.join(", ")),{error:n,guesses:o}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(e){function t(t){var n,o=e.exec(t.pattern);return o?(n=t.fun.call(t.thisArg,e),bot.log(o,n),n&&e.reply(n),n!==!1):void 0}return this.listeners.some(t)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1},devMode:!1,activateDevMode:function(e){this.devMode=!0,this.invocationPattern=e||"beer!",IO.events.userjoin.length=0,this.validateMessage=function(e){return e.content.trim().startsWith(this.invocationPattern)}}};bot.memory={saveInterval:9e5,data:{},get:function(e,t){return this.data[e]||this.set(e,t||{}),this.data[e]},set:function(e,t){this.data[e]=t},loadAll:function(){var e=this;Object.iterate(localStorage,function(t,n){t.startsWith("bot_")&&(console.log(t,n),e.set(t.replace(/^bot_/,""),JSON.parse(n)))})},save:function(e){if(e)return void(localStorage["bot_"+e]=JSON.stringify(this.data[e]));var t=this;Object.keys(this.data).forEach(function(e){t.save(e)}),this.saveLoop()},saveLoop:function(){clearTimeout(this.saveIntervalId),setTimeout(this.saveLoop.bind(this),this.saveInterval)}},bot.memory.loadAll(),window.addEventListener("beforeunload",function(){bot.memory.save()}),bot.memory.saveLoop(),bot.banlist=bot.memory.get("ban"),bot.banlist.contains=function(e){return this.hasOwnProperty(e)},bot.banlist.add=function(e){this[e]={told:!1},bot.memory.save("ban")},bot.banlist.remove=function(e){this.contains(e)&&(delete this[e],bot.memory.save("ban"))},bot.Command=function(e){return e.name=e.name.toLowerCase(),e.thisArg=e.thisArg||e,e.permissions=e.permissions||{},e.permissions.use=e.permissions.use||"ALL",e.permissions.del=e.permissions.del||"NONE",e.description=e.description||"",e.creator=e.creator||"God",e.invoked=0,["Use","Del"].forEach(function(t){var n=t.toLowerCase();e["can"+t]=function(e){var t=this.permissions[n];return"ALL"===t?!0:"NONE"===t?!1:bot.isOwner(e)?!0:t.indexOf(e)>-1}}),e.exec=function(){return this.invoked+=1,this.fun.apply(this.thisArg,arguments)},e.del=function(){bot.info.forgotten+=1,delete bot.commands[e.name],bot.commandDictionary.trie.del(e.name)},e},bot.CommunityCommand=function(e,t){function n(e){if(s.call(r,e))return!1;o();var n=Object.keys(i).length,a=t-n;return bot.log(i,n,t),e in i?"Already registered; still need {0} more".supplant(a):(i[e]=new Date,a-=1,a>0?c.supplant(a):(bot.log("should execute"),!1))}function o(){function e(e,n){return e[n]500||t&&t.length>500)throw"Exception: too many items";return e.apply(this,arguments)}}(Array.prototype.join)});var exec=function(code,arg){return eval("undefined;\n"+code)},console={_items:[],log:function(){console._items.push.apply(console._items,arguments)}};console.error=console.info=console.debug=console.log,function(){global.onmessage=function(e){global.postMessage({event:"start"});var t,n=JSON.stringify,o=setTimeout,r=0,i=function(e){global.postMessage({answer:n(e,s),log:n(console._items,s).slice(1,-1)})},a=function(e){1>r&&i(e)},s=function(e,t){var n;return n=u(t)?""+t:t},c={Function:!0,Error:!0,Undefined:!0,RegExp:!0},u=function(e){var t={}.toString.call(e).slice(8,-1);return t in c?!0:e!==e||1/0===e};self.setTimeout=function(e){function t(){r-=1,e.apply(self,arguments),a()}if(e){var n=[].slice.call(arguments);n[0]=t,r+=1,o.apply(self,n)}};try{t=exec(e.data.code,e.data.arg)}catch(m){t=m.toString()}t&&t.then&&t["catch"]?t.then(a)["catch"](a):a(t)}}()}.stringContents(),blob=new Blob([workerCode],{type:"application/javascript"}),codeUrl=window.URL.createObjectURL(blob);return function(e,t,n){function o(){i||(i=window.setTimeout(function(){r("Maximum execution time exceeded")},500))}function r(e,t){clearTimeout(i),a.terminate(),n&&n.call?n(e,t):console.warn("eval did not get callback")}2===arguments.length&&(n=t,t=null);var i,a=new Worker(codeUrl);a.onmessage=function(e){bot.log(e,"eval worker.onmessage");var t=e.data.event;"start"===t?o():r(null,e.data)},a.onerror=function(e){bot.log(e,"eval worker.onerror"),r(e.message)},a.postMessage({code:e,arg:t})}}(),bot.prettyEval=function(e,t,n){function o(e,t){n(e?e:r(t))}function r(e){bot.log(e,"eval answerObj");var t,n=e.answer,o=e.log;return void 0===n?"Malformed output from web-worker. If you weren't just fooling around trying to break me, raise an issue or contact Zirak":(t=i(n),o&&o.length&&(t+=" Logged: "+i(o)),t)}function i(e){var t;return t=e.length>400?"`"+e.slice(0,400)+"` (snip)":"`"+e+"`"}return 2===arguments.length&&(n=t,t=null),e="c"===e[0]?CoffeeScript.compile(e.replace(/^c>/,""),{bare:1}):e.replace(/^>/,""),bot.eval(e,t,o)},function(){var e={create:function(){var e=Object.create(this);return e.separator=" ",e.escape="\\",e.quote='"',e},parse:function(e){this.source=e,this.pos=0;for(var t=[];!this.done();)t.push(this.nextArg());return t},nextArg:function(){var e=this.separator;return this.peek()===this.quote&&(this.nextChar(),e=this.quote),this.consumeUntil(e)},consumeUntil:function(e){for(var t=this.nextChar(),n=!1,o="";t&&t!==e;)t!==this.escape||n?o+=t:n=!0,t=this.nextChar();return o},nextChar:function(){var e=this.source[this.pos];return this.pos+=1,e},peek:function(){return this.source[this.pos]},done:function(){return this.pos>=this.source.length}},t=bot.commandArgsParser=e.create();bot.parseCommandArgs=t.parse.bind(t)}(),function(){var e={who:function(e){return e.get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=Array.filter(e,function(e){return Number(e.style.opacity)>=.5}).random();return t?t.getElementsByTagName("img")[0].title:"Nobody"},digit:function(){return Math.floor(10*Math.random())},encode:function(e,t){return encodeURIComponent(t)},rand:function(e,t,n){return t?n?(t=Number(t),n=Number(n)):(n=t,t=0):(t=0,n=10),Math.rand(t,n)}},t=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;bot.parseMacro=function n(o,r){function i(e,t,n){if(e.startsWith("$$"))return e.slice(1);var o="";"$"!==e[0]&&(o=e[0]);var r=s(t);return r?(bot.log(r,t,n,"/parse replaceMacro"),o+=r.apply?r.apply(null,a(n)):r):t}function a(e){if(bot.log(e,"/parse parseMacroArgs"),!e)return[o];var t=n(e,r);return[o].concat(t.split(",").invoke("trim"))}function s(t){function n(e){return e&&e.hasOwnProperty(t)}var o=[e,r].first(n);return(o||{})[t]}return o.replace(t,i)}}();var SuggestionDictionary=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=Number(n),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,r,i=[];for(void 0===t?(r=0,o=e):(r=e,o=t-r),n=0;o>n;++n)i[n]=r++;return i}function o(e,t,o){var i=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){r(o.children[n],n,e,a,i,t)}),i}function r(e,t,n,o,i,a){var s,c,u,m,l,d=n.length+1,p=[o[0]+1];for(s=1;d>s;++s)c=p[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],p.push(Math.min(c,u,m));l=p[p.length-1],a>=l&&null!==e.word&&i.push([e.word,l]),Math.min.apply(Math,p)<=a&&Object.keys(e.children).forEach(function(t){r(e.children[t],t,n,p,i,a)})}return e.prototype.add=function(t){for(var n,o=this,r=0;n=t.charAt(r++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},e.prototype.del=function(e,t){t=t||0;var n=this,o=e[t++];n.children[o]&&(n.children[o].del(e,t),0===Object.keys(n.children[o].children).length&&null===n.children[o].word&&delete n.children[o]),n.word===e&&(n.word=null)},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();bot.commandDictionary=new SuggestionDictionary(3),function(){var e={help:function(e){if(e&&e.length){var t=bot.getCommand(e.toLowerCase());if(t.error)return t.error;var n=t.description||"No info is available";return e+": "+n}return"Information on interacting with me can be found at [this page](https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot)"},listen:function(e){var t=bot.callListeners(e);return t?void 0:bot.giveUpMessage()},eval:function(e,t){return t=t||e.directreply.bind(e),bot.prettyEval(e,t)},coffee:function(t,n){var o=bot.Message("c> "+t,t.get());return e.eval(o,n)},refresh:function(){window.location.reload()},forget:function(e){var t=e.toLowerCase(),n=bot.getCommand(t);return n.error?n.error:n.canDel(e.get("user_id"))?(n.del(),"Command "+t+" forgotten."):"You are not authorized to delete the command "+e},info:function(e){function t(e){var t=bot.getCommand(e);if(t.error)return t.error;var n="Command {name}, created by {creator}".supplant(t);return t.date&&(n+=" on "+t.date.toUTCString()),n+=t.invoked?", invoked "+t.invoked+" times":" but hasn't been used yet"}function n(){var e="I awoke on {0} (that's about {1} ago)",t=r.start.toUTCString(),n=Date.timeSince(r.start);return e.supplant(t,n)}function o(){var e=[],t="";return r.invoked&&e.push("got invoked "+r.invoked+" times"),r.learned&&(t="but ",e.push("learned "+r.learned+" commands")),r.forgotten&&e.push(t+"forgotten "+r.forgotten+" commands"),Math.random()<.15&&e.push("teleported "+Math.rand(100)+" goats"),e.join(", ")||"haven't done anything yet!"}if(e.content)return t(e.content);var r=bot.info;return n()+", "+o()}};e.listcommands=function(){var e=function(e,t){var n=0,o=[],r=e.reduce(function(e,r){var i=r.length+2;return n+i>t&&(e.push(o),o=[],n=0),o.push(r),n+=i,e},[]);return o.length&&r.push(o),r};return function(t){var n=Object.keys(bot.commands),o=t.get("user_name"),r=498-o.length,i=e(n,r);return i.invoke("join",", ").join("\n")}}(),e.eval.async=e.coffee.async=!0,e.tell=function(e){function t(e){e&&(a?l(e):m(e))}var n=e.split(" ");bot.log(e.valueOf(),n,"/tell input");var o,r=n[0],i=n[1];if(!r||!i)return"Invalid /tell arguments. Use /help for usage info";if(i=i.toLowerCase(),o=bot.getCommand(i),o.error)return o.error+" (note that /tell works on commands, it's not an echo.)";if(o.unTellable)return"Command "+i+" cannot be used in `/tell`.";if(!o.canUse(e.get("user_id")))return"You do not have permission to use command "+i;if(/^@/.test(r))return"Don't be annoying, drop the @, nobody likes a double-ping.";var a=!1,s={};/^:?\d+$/.test(r)?(s.message_id=r.replace(/^:/,""),a=!0):s.user_name=r;var c=Object.merge(e.get(),s),u=bot.Message(n.slice(2).join(" "),c),m=u.reply.bind(u),l=u.directreply.bind(u);u.reply=u.directreply=u.send=t,bot.log(u,"/tell calling "+i),o.async?o.exec(u,t):t(o.exec(u))};var t={eval:"Forwards message to javascript code-eval",coffee:"Forwards message to coffeescript code-eval",forget:"Forgets a given command. `/forget cmdName`",help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",info:"Grabs some stats on my current instance or a command. `/info [cmdName]`",listcommands:"Lists commands. `/listcommands`",listen:"Forwards the message to my ears (as if called without the /)",refresh:"Reloads the browser window I live in",tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`"},n={die:!0,live:!0,ban:!0,unban:!0,refresh:!0},o={die:!0,ban:!0},r={tell:!0,forget:!0};Object.iterate(e,function(e,i){var a={name:e,fun:i,permissions:{del:"NONE",use:n[e]?"OWNER":"ALL"},description:t[e],pendingMessage:i.pendingMessage,unTellable:r[e],async:i.async};o[e]&&(a=bot.CommunityCommand(a,i.invokeReq)),bot.addCommand(a)})}(),function(){bot.listen(/^help(?: (\S+))?/,function(e){return bot.getCommand("help").exec(e.matches[1])});var e=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t){return t+". "+e}).join("\n");bot.listen(/^tell (me (your|the) )?(rule|law)s/,function(){return e}),bot.listen(/^give (.+?) a lick/,function(e){var t,n=e.matches[1];return"me"===n?(n="you",t=""):"yourself"===n?(n="I",t=""):t="s","Mmmm! "+n+" taste"+t+" just like raisin"});var t=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];bot.listen(t,function(e){var t=e.matches[1],n=bot.getCommand("define");n.exec(t,function(n){n=n.replace(t+":",""),e.reply(n)})})}()}(),function(){"use strict";var e="[{text}]({url})";bot.adapter={roomid:null,fkey:null,site:null,user_id:null,maxLineLength:500,init:function(){var e=document.getElementById("fkey");return e?(this.fkey=e.value,this.roomid=Number(/\d+/.exec(location)[0]),this.site=this.getCurrentSite(),this.user_id=CHAT.CURRENT_USER_ID,this["in"].init(),void this.out.init()):void console.error("bot.adapter could not find fkey; aborting")},getCurrentSite:function(){var e=/chat\.(\w+)/.exec(location)[1];if("stackexchange"!==e)return e;var t=document.getElementById("siterooms").href;return e=/host=(.+?)\./.exec(t)[1]},transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e){return"@"+e.replace(/\s/g,"")},directreply:function(e){return":"+e},codify:function(e){var t="    ",n=e.replace("	",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})},moveMessage:function(e,t,n,o){IO.xhr({method:"POST",url:"/admin/movePosts/"+t,data:{fkey:bot.adapter.fkey,to:n,ids:e},finish:o||function(){}})}};var t=bot.adapter["in"]={times:{},firstPoll:!0,interval:5e3,init:function(e){function t(e){e=JSON.parse(e),bot.log(e),n.openSocket(e.url,o)}var n=this,o=void 0!==e;e=e||bot.adapter.roomid,IO.xhr({url:"/ws-auth",data:fkey({roomid:e}),method:"POST",complete:t})},initialPoll:function(){function e(e){e=JSON.parse(e),bot.log(e),n.times["r"+t]=e.time,n.firstPoll=!1}bot.log("adapter: initial poll");var t=bot.adapter.roomid,n=this;IO.xhr({url:"/chats/"+t+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},openSocket:function(e,t){var n;if("undefined"!=typeof window.__stackexchangeChatSavedSocket){var o=window.__stackexchangeChatSavedSocket;console.assert(o.constructor===window.WebSocket),console.assert(o.url.startsWith("wss://chat.sockets.stackexchange.com")),n=o}else if(n=new WebSocket(e+"?l=99999999999"),t)return void(n.onmessage=function(){n.close()});this.socket=n,n.addEventListener("message",this.ondata.bind(this)),n.addEventListener("close",this.socketFail.bind(this))},ondata:function(e){this.pollComplete(e.data)},poll:function(){if(this.firstPoll)return void this.initialPoll();var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){e&&(e=JSON.parse(e),Object.iterate(e,function(e,t){t.t&&(this.times[e]=t.t),t.e&&t.e.forEach(this.handleMessageObject,this)},this),IO["in"].flush())},handleMessageObject:function(e){IO.fire("rawinput",e);var t=e.event_type;if(3===t||4===t)return void this.handleUserEvent(e);if(1===t||2===t)return e.content.startsWith("
")?void this.handleMultilineMessage(e):void IO["in"].receive(e)},handleMultilineMessage:function(e){this.breakMultilineMessage(e.content).forEach(function(t){var n=Object.merge(e,{content:t.trim()});IO["in"].receive(n)})},breakMultilineMessage:function(e){var t=e.slice(0,e.lastIndexOf("
")).replace("
","");return t.split("
")},handleUserEvent:function(e){var t=e.event_type;3===t?IO.fire("userjoin",e):4===t&&IO.fire("userleave",e)},leaveRoom:function(e,t){return e===bot.adapter.roomid?void t("base_room"):void IO.xhr({method:"POST",url:"/chats/leave/"+e,data:fkey({quiet:!0}),complete:function(){t()}})},socketFail:function(){bot.log("adapter: socket failed",this),this.socket.close(),this.socket=null,this.loopage()},loopage:function(){if(!this.socket){var e=this;setTimeout(function(){e.poll(),e.loopage()},this.interval)}}},n=bot.adapter.out={409:0,total:0,interval:t.interval+500,flushWait:500,init:function(){},add:function(e,t){IO.out.receive({text:e+"\n",room:t||bot.adapter.roomid}),IO.out.flush()},send:function(e){bot.stopped||setTimeout(function(){n.sendToRoom(e.text,e.room)},this.flushWait)},sendToRoom:function(e,t){function o(o,i){bot.log(i.status),409===i.status?(n[409]+=1,r(e,t)):500===i.status?n.add("Server error (status 500) occured (message probably too long)",t):200!==i.status?(console.error(i),n.add("Error "+i.status+" occured, I will call the maid (@Zirak)")):(n.total+=1,IO.fire("sendoutput",i,e,t))}function r(){setTimeout(function(){n.add(e,t)},n.interval)}IO.xhr({url:"/chats/"+t+"/messages/new",data:{text:e,fkey:fkey().fkey},method:"POST",complete:o})}};IO.register("output",n.send,n),bot.adapter.init()}(),function(){"use strict";function e(e,t,n){function o(e){e=JSON.parse(e),e.users.forEach(r)}function r(e){bot.users[e.id]=e,n(e)}Array.isArray(t)||(t=[t]),t.length&&IO.xhr({method:"POST",url:"/user/info",data:{ids:t.join(),roomId:e||bot.adapter.roomid},complete:o})}function t(){CHAT.RoomUsers.all().forEach(function(e){bot.users[e.id]=e})}bot.users={}; +var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(t.toString()):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var r=e[t];return Array.isArray(r)?n(t,r):o(t,r)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.htmlToMarkdown=function(){var e={i:"*",b:"**",strike:"---",code:"`",a:function(e,t,n){var o=/href="([^"]+?)"/.exec(e);return o?"["+n+"]("+o[1]+")":e}},t=/<(\S+)[^\>]*>([^<]+)<\/\1>/g;return function(n){function o(t,n,o){return e.hasOwnProperty(n)?(r=e[n],r.apply?e[n].apply(e,arguments):r+o+r):t}var r;return n.replace(t,o)}}(),IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",zwnj:"",zwsp:""};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return t?"#"===t[0]?r(t):e.hasOwnProperty(t)?e[t]:"&"+t+";":""},r=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.relativeUrlToAbsolute=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.href},IO.injectScript=function(e){var t=document.createElement("script");return t.src=e,document.head.appendChild(t),t},IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),e.document&&(t.responseType="document"),t.addEventListener("load",function(){e.complete.call(e.thisArg,t.response,t)}),Object.iterate(e.headers,t.setRequestHeader.bind(t)),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+="&"+this.urlstringify(e.data),n.onerror=e.error,n.src=e.url,document.head.appendChild(n)},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},Object.iterate=function(e,t,n){Object.keys(e).forEach(function(o){t.call(n,o,e[o],e)})},Object.TruthMap=function(e){function t(e,t){return e[t]=!0,e}return(e||[]).reduce(t,Object.create(null))},Array.from=function(e,t){return[].slice.call(e,t)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){function t(t){var o=t;return t[e]&&t[e].apply&&(o=t[e].apply(t,n)),o}var n=Array.from(arguments,1);return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"pluck",{value:function(e){function t(t){try{return t[e]}catch(n){return t}}return this.map(t)},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"random",{value:function(){return this[Math.floor(Math.random()*this.length)]},configurable:!0,writable:!0}),["forEach","map","filter","reduce"].forEach(function(e){var t=[][e];Array[e]=function(){return t.call.apply(t,arguments)}}),String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.supplant=function(e){function t(e,t){return n.hasOwnProperty(t)?n[t]:e}var n=Object(e)===e?e:arguments;return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Function.prototype.throttle=function(e){var t=this,n=-1,o=function(){clearTimeout(n);var o=this,r=arguments;n=setTimeout(function(){t.apply(o,r)},e)};return o},Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this;return e=e||function(e){return e},function(){function o(){t[a]=arguments,i.apply(null,arguments)}var r=Array.from(arguments),i=r.pop(),a=e.apply(null,arguments);return a in t?void i.apply(null,t[a]):(r.push(o),void n.apply(this,r))}},Function.prototype.stringContents=function(){return this.toString().replace(/^function\*?\s+\([^)]*\)\s*\{/,"").replace(/\}$/,"")},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Number.prototype.fallsAfter=function(e){e=e.slice();for(var t,n=e.shift(),o=this.valueOf(),r=0,i=e.length;i>r&&(t=e[r],!(t>o));r++)n=t;return o>=n?n:null},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},Math.rand=function(e,t){return"undefined"==typeof e?(e=0,t=9):"undefined"==typeof t&&(t=e,e=0),Math.floor(Math.random()*(t-e+1))+e},Object.defineProperty(RegExp.prototype,"toJSON",{value:function(){return this.toString()},configurable:!0,writable:!0}),RegExp.escape=function(e){return e.replace(/[-^$\\\/\.*+?()[\]{}|]/g,"\\$&")},Date.timeSince=function(e,t){function n(e,t){return e=Math.floor(e),t+=1===e?"":"s",e+" "+t}t=t||new Date;for(var o,r=t-e,i=[{delta:31536e6,suffix:"year"},{delta:2592e6,suffix:"month"},{delta:864e5,suffix:"day"},{delta:36e5,suffix:"hour"},{delta:6e4,suffix:"minute"},{delta:1e3,suffix:"second"}];i.length;)if(o=i.shift(),r>=o.delta)return n(r/o.delta,o.suffix);return n(r,"millisecond")},function(){"use strict";var bot=window.bot={invocationPattern:"!!",commands:{},commandDictionary:null,listeners:[],info:{invoked:0,learned:0,forgotten:0,start:new Date},users:{},parseMessage:function(e){if(!this.validateMessage(e))return void bot.log(e,"parseMessage invalid");var t=this.prepareMessage(e),n=t.get("user_id");if(bot.log(t,"parseMessage valid"),this.banlist.contains(n))return bot.log(e,"parseMessage banned"),void(this.banlist[n].told||(t.reply("You iz in mindjail"),this.banlist[n].told=!0));try{/^c?>/.test(t)?this.prettyEval(t.toString(),t.directreply.bind(t)):this.invokeAction(t)}catch(o){var r="Could not process input. Error: "+o.message;o.lineNumber&&(r+=" on line "+o.lineNumber),o.column&&(r+=" on column "+o.column),t.directreply(r),console.error(o.stack)}finally{this.info.invoked+=1}},invokeAction:function(e){var t=e.trim().replace(/^\/\s*/,"").split(" ")[0],n=this.getCommand(t),o=e.startsWith("/")?!n.error:!0;n.error?o&&(o=this.callListeners(e)):this.execCommand(n,e),o||e.reply(this.giveUpMessage(n.guesses))},giveUpMessage:function(e){var t="That didn't make much sense.";return t+=e&&e.length?" Maybe you meant: "+e.join(", "):" Use the `!!/help` command to learn more."},execCommand:function(e,t){if(bot.log(e,"execCommand calling"),!e.canUse(t.get("user_id")))return void t.reply(["You do not have permission to use the command "+e.name,"I'm afraid I can't let you do that, "+t.get("user_name")].random());var n=this.Message(t.replace(/^\/\s*/,"").slice(e.name.length).trim(),t.get()),o=e.exec(n);o&&t.reply(o)},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.htmlToMarkdown(e.content);return t=IO.decodehtmlEntities(t),t=t.replace(/\u200b|\u200c/g,""),this.Message(t.slice(this.invocationPattern.length).trim(),e)},validateMessage:function(e){var t=e.content.trim();return"!!"===this.invocationPattern&&/^!!!+$/.test(t)?(console.log("special skip"),!1):e.user_id!==bot.adapter.user_id&&e.user_id>0&&t.startsWith(this.invocationPattern)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),e.learned&&(this.info.learned+=1),e.invoked=0,this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){var t=e.toLowerCase();if(this.commandExists(t))return this.commands[t];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var n="Command "+e+" does not exist.",o=this.commandDictionary.search(e);return o.length&&(n+=" Did you mean: "+o.join(", ")),{error:n,guesses:o}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(e){function t(t){var n,o=e.exec(t.pattern);return o?(n=t.fun.call(t.thisArg,e),bot.log(o,n),n&&e.reply(n),n!==!1):void 0}return this.listeners.some(t)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1},devMode:!1,activateDevMode:function(e){this.devMode=!0,this.invocationPattern=e||"beer!",IO.events.userjoin.length=0,this.validateMessage=function(e){return e.content.trim().startsWith(this.invocationPattern)}}};bot.memory={saveInterval:9e5,data:{},get:function(e,t){return this.data[e]||this.set(e,t||{}),this.data[e]},set:function(e,t){this.data[e]=t},loadAll:function(){var e=this;Object.iterate(localStorage,function(t,n){t.startsWith("bot_")&&(console.log(t,n),e.set(t.replace(/^bot_/,""),JSON.parse(n)))})},save:function(e){if(e)return void(localStorage["bot_"+e]=JSON.stringify(this.data[e]));var t=this;Object.keys(this.data).forEach(function(e){t.save(e)}),this.saveLoop()},saveLoop:function(){clearTimeout(this.saveIntervalId),setTimeout(this.saveLoop.bind(this),this.saveInterval)}},bot.memory.loadAll(),window.addEventListener("beforeunload",function(){bot.memory.save()}),bot.memory.saveLoop(),bot.banlist=bot.memory.get("ban"),bot.banlist.contains=function(e){return this.hasOwnProperty(e)},bot.banlist.add=function(e){this[e]={told:!1},bot.memory.save("ban")},bot.banlist.remove=function(e){this.contains(e)&&(delete this[e],bot.memory.save("ban"))},bot.Command=function(e){return e.name=e.name.toLowerCase(),e.thisArg=e.thisArg||e,e.permissions=e.permissions||{},e.permissions.use=e.permissions.use||"ALL",e.permissions.del=e.permissions.del||"NONE",e.description=e.description||"",e.creator=e.creator||"God",e.invoked=0,["Use","Del"].forEach(function(t){var n=t.toLowerCase();e["can"+t]=function(e){var t=this.permissions[n];return"ALL"===t?!0:"NONE"===t?!1:bot.isOwner(e)?!0:t.indexOf(e)>-1}}),e.exec=function(){return this.invoked+=1,this.fun.apply(this.thisArg,arguments)},e.del=function(){bot.info.forgotten+=1,delete bot.commands[e.name],bot.commandDictionary.trie.del(e.name)},e},bot.CommunityCommand=function(e,t){function n(e){if(s.call(r,e))return!1;o();var n=Object.keys(i).length,a=t-n;return bot.log(i,n,t),e in i?"Already registered; still need {0} more".supplant(a):(i[e]=new Date,a-=1,a>0?c.supplant(a):(bot.log("should execute"),!1))}function o(){function e(e,n){return e[n]500||t&&t.length>500)throw"Exception: too many items";return e.apply(this,arguments)}}(Array.prototype.join)});var exec=function(code,arg){return eval("undefined;\n"+code)},console={_items:[],log:function(){console._items.push.apply(console._items,arguments)}};console.error=console.info=console.debug=console.log,function(){global.onmessage=function(e){global.postMessage({event:"start"});var t,n=JSON.stringify,o=setTimeout,r=0,i=function(e){global.postMessage({answer:n(e,s),log:n(console._items,s).slice(1,-1)})},a=function(e){1>r&&i(e)},s=function(e,t){var n;return n=u(t)?""+t:t},c={Function:!0,Error:!0,Undefined:!0,RegExp:!0},u=function(e){var t={}.toString.call(e).slice(8,-1);return t in c?!0:e!==e||1/0===e};self.setTimeout=function(e){function t(){r-=1,e.apply(self,arguments),a()}if(e){var n=[].slice.call(arguments);n[0]=t,r+=1,o.apply(self,n)}};try{t=exec(e.data.code,e.data.arg)}catch(m){t=m.toString()}t&&t.then&&t["catch"]?t.then(a)["catch"](a):a(t)}}()}.stringContents(),blob=new Blob([workerCode],{type:"application/javascript"}),codeUrl=window.URL.createObjectURL(blob);return function(e,t,n){function o(){i||(i=window.setTimeout(function(){r("Maximum execution time exceeded")},500))}function r(e,t){clearTimeout(i),a.terminate(),n&&n.call?n(e,t):console.warn("eval did not get callback")}2===arguments.length&&(n=t,t=null);var i,a=new Worker(codeUrl);a.onmessage=function(e){bot.log(e,"eval worker.onmessage");var t=e.data.event;"start"===t?o():r(null,e.data)},a.onerror=function(e){bot.log(e,"eval worker.onerror"),r(e.message)},a.postMessage({code:e,arg:t})}}(),bot.prettyEval=function(e,t,n){function o(e,t){n(e?e:r(t))}function r(e){bot.log(e,"eval answerObj");var t,n=e.answer,o=e.log;return void 0===n?"Malformed output from web-worker. If you weren't just fooling around trying to break me, raise an issue or contact Zirak":(t=i(n),o&&o.length&&(t+=" Logged: "+i(o)),t)}function i(e){var t;return t=e.length>400?"`"+e.slice(0,400)+"` (snip)":"`"+e+"`"}return 2===arguments.length&&(n=t,t=null),e="c"===e[0]?CoffeeScript.compile(e.replace(/^c>/,""),{bare:1}):e.replace(/^>/,""),bot.eval(e,t,o)},function(){var e={create:function(){var e=Object.create(this);return e.separator=" ",e.escape="\\",e.quote='"',e},parse:function(e){this.source=e,this.pos=0;for(var t=[];!this.done();)t.push(this.nextArg());return t},nextArg:function(){var e=this.separator;return this.peek()===this.quote&&(this.nextChar(),e=this.quote),this.consumeUntil(e)},consumeUntil:function(e){for(var t=this.nextChar(),n=!1,o="";t&&t!==e;)t!==this.escape||n?o+=t:n=!0,t=this.nextChar();return o},nextChar:function(){var e=this.source[this.pos];return this.pos+=1,e},peek:function(){return this.source[this.pos]},done:function(){return this.pos>=this.source.length}},t=bot.commandArgsParser=e.create();bot.parseCommandArgs=t.parse.bind(t)}(),function(){var e={who:function(e){return e.get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=Array.filter(e,function(e){return Number(e.style.opacity)>=.5}).random();return t?t.getElementsByTagName("img")[0].title:"Nobody"},digit:function(){return Math.floor(10*Math.random())},encode:function(e,t){return encodeURIComponent(t)},rand:function(e,t,n){return t?n?(t=Number(t),n=Number(n)):(n=t,t=0):(t=0,n=10),Math.rand(t,n)}},t=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;bot.parseMacro=function n(o,r){function i(e,t,n){if(e.startsWith("$$"))return e.slice(1);var o="";"$"!==e[0]&&(o=e[0]);var r=s(t);return r?(bot.log(r,t,n,"/parse replaceMacro"),o+=r.apply?r.apply(null,a(n)):r):t}function a(e){if(bot.log(e,"/parse parseMacroArgs"),!e)return[o];var t=n(e,r);return[o].concat(t.split(",").invoke("trim"))}function s(t){function n(e){return e&&e.hasOwnProperty(t)}var o=[e,r].first(n);return(o||{})[t]}return o.replace(t,i)}}();var SuggestionDictionary=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=Number(n),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,r,i=[];for(void 0===t?(r=0,o=e):(r=e,o=t-r),n=0;o>n;++n)i[n]=r++;return i}function o(e,t,o){var i=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){r(o.children[n],n,e,a,i,t)}),i}function r(e,t,n,o,i,a){var s,c,u,m,l,d=n.length+1,p=[o[0]+1];for(s=1;d>s;++s)c=p[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],p.push(Math.min(c,u,m));l=p[p.length-1],a>=l&&null!==e.word&&i.push([e.word,l]),Math.min.apply(Math,p)<=a&&Object.keys(e.children).forEach(function(t){r(e.children[t],t,n,p,i,a)})}return e.prototype.add=function(t){for(var n,o=this,r=0;n=t.charAt(r++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},e.prototype.del=function(e,t){t=t||0;var n=this,o=e[t++];n.children[o]&&(n.children[o].del(e,t),0===Object.keys(n.children[o].children).length&&null===n.children[o].word&&delete n.children[o]),n.word===e&&(n.word=null)},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();bot.commandDictionary=new SuggestionDictionary(3),function(){var e={help:function(e){if(e&&e.length){var t=bot.getCommand(e.toLowerCase());if(t.error)return t.error;var n=t.description||"No info is available";return e+": "+n}return"Information on interacting with me can be found at [this page](https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot)"},listen:function(e){var t=bot.callListeners(e);return t?void 0:bot.giveUpMessage()},eval:function(e,t){return t=t||e.directreply.bind(e),bot.prettyEval(e,t)},coffee:function(t,n){var o=bot.Message("c> "+t,t.get());return e.eval(o,n)},refresh:function(){window.location.reload()},forget:function(e){var t=e.toLowerCase(),n=bot.getCommand(t);return n.error?n.error:n.canDel(e.get("user_id"))?(n.del(),"Command "+t+" forgotten."):"You are not authorized to delete the command "+e},info:function(e){function t(e){var t=bot.getCommand(e);if(t.error)return t.error;var n="Command {name}, created by {creator}".supplant(t);return t.date&&(n+=" on "+t.date.toUTCString()),n+=t.invoked?", invoked "+t.invoked+" times":" but hasn't been used yet"}function n(){var e="I awoke on {0} (that's about {1} ago)",t=r.start.toUTCString(),n=Date.timeSince(r.start);return e.supplant(t,n)}function o(){var e=[],t="";return r.invoked&&e.push("got invoked "+r.invoked+" times"),r.learned&&(t="but ",e.push("learned "+r.learned+" commands")),r.forgotten&&e.push(t+"forgotten "+r.forgotten+" commands"),Math.random()<.15&&e.push("teleported "+Math.rand(100)+" goats"),e.join(", ")||"haven't done anything yet!"}if(e.content)return t(e.content);var r=bot.info;return n()+", "+o()}};e.listcommands=function(){var e=function(e,t){var n=0,o=[],r=e.reduce(function(e,r){var i=r.length+2;return n+i>t&&(e.push(o),o=[],n=0),o.push(r),n+=i,e},[]);return o.length&&r.push(o),r};return function(t){var n=Object.keys(bot.commands),o=t.get("user_name"),r=498-o.length,i=e(n,r);return i.invoke("join",", ").join("\n")}}(),e.eval.async=e.coffee.async=!0,e.tell=function(e){function t(e){e&&(a?l(e):m(e))}var n=e.split(" ");bot.log(e.valueOf(),n,"/tell input");var o,r=n[0],i=n[1];if(!r||!i)return"Invalid /tell arguments. Use /help for usage info";if(i=i.toLowerCase(),o=bot.getCommand(i),o.error)return o.error+" (note that /tell works on commands, it's not an echo.)";if(o.unTellable)return"Command "+i+" cannot be used in `/tell`.";if(!o.canUse(e.get("user_id")))return"You do not have permission to use command "+i;if(/^@/.test(r))return"Don't be annoying, drop the @, nobody likes a double-ping.";var a=!1,s={};/^:?\d+$/.test(r)?(s.message_id=r.replace(/^:/,""),a=!0):s.user_name=r;var c=Object.merge(e.get(),s),u=bot.Message(n.slice(2).join(" "),c),m=u.reply.bind(u),l=u.directreply.bind(u);u.reply=u.directreply=u.send=t,bot.log(u,"/tell calling "+i),o.async?o.exec(u,t):t(o.exec(u))};var t={eval:"Forwards message to javascript code-eval",coffee:"Forwards message to coffeescript code-eval",forget:"Forgets a given command. `/forget cmdName`",help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",info:"Grabs some stats on my current instance or a command. `/info [cmdName]`",listcommands:"Lists commands. `/listcommands`",listen:"Forwards the message to my ears (as if called without the /)",refresh:"Reloads the browser window I live in",tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`"},n={die:!0,live:!0,ban:!0,unban:!0,refresh:!0},o={die:!0,ban:!0},r={tell:!0,forget:!0};Object.iterate(e,function(e,i){var a={name:e,fun:i,permissions:{del:"NONE",use:n[e]?"OWNER":"ALL"},description:t[e],pendingMessage:i.pendingMessage,unTellable:r[e],async:i.async};o[e]&&(a=bot.CommunityCommand(a,i.invokeReq)),bot.addCommand(a)})}(),function(){bot.listen(/^help(?: (\S+))?/,function(e){return bot.getCommand("help").exec(e.matches[1])});var e=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t){return t+". "+e}).join("\n");bot.listen(/^tell (me (your|the) )?(rule|law)s/,function(){return e}),bot.listen(/^give (.+?) a lick/,function(e){var t,n=e.matches[1];return"me"===n?(n="you",t=""):"yourself"===n?(n="I",t=""):t="s","Mmmm! "+n+" taste"+t+" just like raisin"});var t=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];bot.listen(t,function(e){var t=e.matches[1],n=bot.getCommand("define");n.exec(t,function(n){n=n.replace(t+":",""),e.reply(n)})})}()}(),function(){"use strict";var e="[{text}]({url})";bot.adapter={roomid:null,fkey:null,site:null,user_id:null,maxLineLength:500,init:function(){var e=document.getElementById("fkey");return e?(this.fkey=e.value,this.roomid=Number(/\d+/.exec(location)[0]),this.site=this.getCurrentSite(),this.user_id=CHAT.CURRENT_USER_ID,this["in"].init(),void this.out.init()):void console.error("bot.adapter could not find fkey; aborting")},getCurrentSite:function(){var e=/chat\.(\w+)/.exec(location)[1];if("stackexchange"!==e)return e;var t=document.getElementById("siterooms").href;return e=/host=(.+?)\./.exec(t)[1]},transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e){return"@"+e.replace(/\s/g,"")},directreply:function(e){return":"+e},codify:function(e){var t=" ",n=e.replace(" ",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})},moveMessage:function(e,t,n,o){IO.xhr({method:"POST",url:"/admin/movePosts/"+t,data:{fkey:bot.adapter.fkey,to:n,ids:e},finish:o||function(){}})}};var t=bot.adapter["in"]={times:{},firstPoll:!0,interval:5e3,init:function(e){function t(e){e=JSON.parse(e),bot.log(e),n.openSocket(e.url,o)}var n=this,o=void 0!==e;e=e||bot.adapter.roomid,IO.xhr({url:"/ws-auth",data:fkey({roomid:e}),method:"POST",complete:t})},initialPoll:function(){function e(e){e=JSON.parse(e),bot.log(e),n.times["r"+t]=e.time,n.firstPoll=!1}bot.log("adapter: initial poll");var t=bot.adapter.roomid,n=this;IO.xhr({url:"/chats/"+t+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},openSocket:function(e,t){var n;if("undefined"==typeof window.__stackexchangeChatSavedSocket||t){if(n=new WebSocket(e+"?l=99999999999"),t)return void(n.onmessage=function(){n.close()})}else{var o=window.__stackexchangeChatSavedSocket;console.assert(o.constructor===window.WebSocket),console.assert(o.url.startsWith("wss://chat.sockets.stackexchange.com")),n=o}this.socket=n,n.addEventListener("message",this.ondata.bind(this)),n.addEventListener("close",this.socketFail.bind(this))},ondata:function(e){this.pollComplete(e.data)},poll:function(){if(this.firstPoll)return void this.initialPoll();var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){e&&(e=JSON.parse(e),Object.iterate(e,function(e,t){t.t&&(this.times[e]=t.t),t.e&&t.e.forEach(this.handleMessageObject,this)},this),IO["in"].flush())},handleMessageObject:function(e){IO.fire("rawinput",e);var t=e.event_type;if(3===t||4===t)return void this.handleUserEvent(e);if(1===t||2===t)return e.content.startsWith("
")?void this.handleMultilineMessage(e):void IO["in"].receive(e)},handleMultilineMessage:function(e){this.breakMultilineMessage(e.content).forEach(function(t){var n=Object.merge(e,{content:t.trim()});IO["in"].receive(n)})},breakMultilineMessage:function(e){var t=e.slice(0,e.lastIndexOf("
")).replace("
","");return t.split("
")},handleUserEvent:function(e){var t=e.event_type;3===t?IO.fire("userjoin",e):4===t&&IO.fire("userleave",e)},leaveRoom:function(e,t){return e===bot.adapter.roomid?void t("base_room"):void IO.xhr({method:"POST",url:"/chats/leave/"+e,data:fkey({quiet:!0}),complete:function(){t()}})},socketFail:function(){bot.log("adapter: socket failed",this),this.socket.close(),this.socket=null,this.loopage()},loopage:function(){if(!this.socket){var e=this;setTimeout(function(){e.poll(),e.loopage()},this.interval)}}},n=bot.adapter.out={409:0,total:0,interval:t.interval+500,flushWait:500,init:function(){},add:function(e,t){IO.out.receive({text:e+"\n",room:t||bot.adapter.roomid}),IO.out.flush()},send:function(e){bot.stopped||setTimeout(function(){n.sendToRoom(e.text,e.room)},this.flushWait)},sendToRoom:function(e,t){function o(o,i){bot.log(i.status),409===i.status?(n[409]+=1,r(e,t)):500===i.status?n.add("Server error (status 500) occured (message probably too long)",t):200!==i.status?(console.error(i),n.add("Error "+i.status+" occured, I will call the maid (@Zirak)")):(n.total+=1,IO.fire("sendoutput",i,e,t))}function r(){setTimeout(function(){n.add(e,t)},n.interval)}IO.xhr({url:"/chats/"+t+"/messages/new",data:{text:e,fkey:fkey().fkey},method:"POST",complete:o})}};IO.register("output",n.send,n),bot.adapter.init()}(),function(){"use strict";function e(e,t,n){function o(e){e=JSON.parse(e),e.users.forEach(r)}function r(e){bot.users[e.id]=e,n(e)}Array.isArray(t)||(t=[t]),t.length&&IO.xhr({method:"POST",url:"/user/info",data:{ids:t.join(),roomId:e||bot.adapter.roomid},complete:o})}function t(){CHAT.RoomUsers.all().forEach(function(e){bot.users[e.id]=e})}bot.users={}; var n=[],o=function(e,t){n.push(e.user_id),r(t)};IO.register("userjoin",function(e){function t(t){IO.fire("userregister",t,e.room_id)}bot.log(e,"userjoin");var n=bot.users[e.user_id];n?t(n):o(e,t)});var r=function(t){bot.log(n,"user addInfos"),e(null,n,t),n=[]}.throttle(1e3);bot.users.request=e,bot.users.findUserId=function(e){function t(t){return n(bot.users[t].name)===e}function n(e){return e.toLowerCase().replace(/\s/g,"")}var o=Object.keys(bot.users);return e=n(e),o.first(t)||-1}.memoize(),bot.users.findUsername=function(){var e={};return function(t,n){function o(e){r(e.name)}function r(o){n(e[t]=o)}e[t]?r(e[t]):bot.users[t]?r(bot.users[t].name):bot.users.request(bot.adapter.roomid,t,o)}}(),t()}(),bot.personality={bitchiness:0,thanks:{0:["You kiss-ass","Most welcome"],.5:["Thank you for noticing","teehee"],1:["Took you long enough","My pleasure","Don't mention it"]},apologies:{0:["What for?"],.5:["It was nothing...","No worries"],1:["You're forgiven. For now. Don't push it."]},stuff:{0:["Life is just *perfect*","What's there to bitch about, as long as I have *you*..."],1:["Oh don't mind me, that isn't difficult at all..."],1.2:["You don't appreciate me enough. Not that I need to be thanked.."],1.3:['The occasional "thanks" or "I\'m sorry" would be nice...'],2:["*sigh* Remember laughter? I don't. You ripped it out of me. Heartless bastard."]},insanity:{},okayCommands:{hangman:!0,help:!0,info:!0},check:function(e){return!this.okayCommands.hasOwnProperty(e)},bitch:function(){return this.getResp(this.stuff)},command:function(){this.bitchiness+=this.getDB()},thank:function(){return this.unbitch(this.thanks)},apologize:function(){return this.unbitch(this.apologies)},unbitch:function(e,t){var n=this.getResp(e);return this.bitchiness-=t||this.bitchiness,n},getResp:function(e){return e[this.bitchiness.fallsAfter(Object.keys(e).map(Number).sort())].random()},isABitch:function(){return this.bitchiness>=1},looksLikeABitch:function(){return!1},getDB:function(){return this.isThatTimeOfTheMonth()?.075:.025},isThatTimeOfTheMonth:function(){var e=(new Date).getDate();return 2>e||e>27}},bot.listen(/thank(s| you)/i,bot.personality.thank,bot.personality),bot.listen(/(I('m| am))?\s*sorry/i,bot.personality.apologize,bot.personality),bot.listen(/^bitch/i,bot.personality.bitch,bot.personality),function(){var e={STOP:"HAMMERTIME!",STAHP:"HAMMAHTIME!",HALT:"HAMMERZEIT!",STOY:"ZABIVAT' VREMYA!",SISTITE:"MALLEUS TEMPUS!"},t=new RegExp("("+Object.keys(e).map(RegExp.escape).join("|")+")[\\.!?]?$");IO.register("input",function(n){var o=n.content.toUpperCase(),r=t.exec(o);r&&bot.adapter.out.add(e[r[1]],n.room_id)})}(),function(){"use strict";var e=bot.memory.get("afk"),t=3e5,n=12e4,o=[{outgoing:"Why are you leaving me!?",incoming:["Welcome back!","Where were you!?","You saw that whore again, didn't you!?"]},{outgoing:"Just go already!",incoming:["Oh, it's you again...","Look at what the cat dragged in...","You've got some balls, coming back here after what you did."]},{outgoing:"Nobody cares.",incoming:["I already told you, nobody cares.","There goes the neighbourhood."]},{outgoing:"Hurry back, ok?",incoming:["I thought you'd never come back!","It's been 20 years. You can't just waltz back into my life like this."]},{outgoing:"Stay safe.",incoming:["Were you bitten!? Strip! Prove you weren't bitten."]},{outgoing:"Can you pick up some milk on your way back?",incoming:["Where's the milk?","Turns out I already have milk. Oops."]},{outgoing:"Apricots are people too!",incoming:["You taste just like raisin.","I am a banana!","My spoon is too big!","BROOOOOOOOOOOO."]}],r=function(o,r){function i(){var e="{user} is afk{sep}{rest}",t={user:o,sep:".",rest:""};return s.msg&&(t.sep=": ",t.rest=s.msg),e.supplant(t)}function a(){var e=s.lastPing[c];return u-s.afkSince>=n&&(!e||u-e>=t)}var s=e[o],c=r.get("room_id"),u=Date.now();a()&&(r.directreply(i()),s.lastPing[c]=u,bot.memory.save("afk"))},i=function(t,n,o){var r=!1;bot.log("/afk goAFK ",t),0===n.indexOf("!")&&(n=n.substring(1),r=!0),e[t]={afkSince:Date.now(),lastPing:{},msg:n.trim(),returnMsg:o},r&&(e[t].noReturn=1)},a=function(t){bot.log("/afk clearAFK",t),delete e[t]},s=function(t){var n,r,s=t.get("user_name").replace(/\s/g,""),c=t.content;bot.log("/afk input",s,c),e.hasOwnProperty(s)?(n=e[s].returnMsg,a(s)):(r=o.random(),n=r.outgoing,i(s,c,r.incoming.random())),bot.memory.save("afk")};bot.addCommand({name:"afk",fun:s,permissions:{del:"NONE"},description:"Set an afk message: `/afk `. Invoke `/afk` again to return.",unTellable:!0}),IO.register("input",function(t){function o(){var t=new RegExp("^"+RegExp.escape(bot.invocationPattern)+"\\s*/?\\s*AFK");return e.hasOwnProperty(c)&&!t.test(i)&&u-e[c].afkSince>=n}var i=t.content.toUpperCase(),a=bot.prepareMessage(t),c=t.user_name.replace(/\s/g,""),u=Date.now();t.user_id!==bot.adapter.user_id&&(o()&&(bot.log("/afk he returned!",t),s(a)),i.indexOf("@")<0||Object.keys(e).forEach(function(e){var t=new RegExp("(^|\b)"+RegExp.escape("@"+e)+"\\b","i");t.test(i)&&(bot.log("/afk responding for "+e),r(e,a))}))})}(),function(){"use strict";var e={added:0,0:"{0} added to mindjail.",notFound:1,1:"I couldn't find {0}.",owner:2,2:"I can't mindjail {0}, they're an owner.",alreadyIn:3,3:"{0} is already in mindjail.",notIn:4,4:"{0} isn't in mindjail.",freed:5,5:"{0} freed from mindjail!"},t={name:"ban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){if(!t)return Object.keys(bot.banlist).filter(Number);var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/ban argument"),0>o?n=e.notFound:bot.isOwner(o)?n=e.owner:bot.banlist.contains(o)?n=e.alreadyIn:(bot.banlist.add(o),n=e.added),{code:n,usrid:t}},format:function(t){return Array.isArray(t)?t.map(this.formatUser).join(", ")||"Nothing to show.":e[t.code].supplant(t.usrid)},formatUser:function(e){var t=bot.users[e],n=t?t.name:"?";return"{0} ({1})".supplant(e,n)},permissions:{del:"NONE",use:"OWNER"},description:"Bans a user from using me. Lacking arguments, prints the ban list. `/ban [usr_id|usr_name]`",pendingMessage:"The user will be thrown into mindjail in {0} more invocations"},n={name:"unban",fun:function(e){return this.format(this.logic(e.toString()))},logic:function(t){var n,o=Number(t);return isNaN(o)&&(o=bot.users.findUserId(t.replace(/^@/,""))),bot.log(t,o,"/unban argument"),0>o?n=e.notFound:bot.banlist.contains(o)?(bot.banlist.remove(o),n=e.freed):n=e.notIn,{code:n,usrid:t}},format:function(t){return e[t.code].supplant(t.usrid)},permissions:{del:"NONE",use:"OWNER"},description:"Frees a user from my mindjail. `/unban usr_id|usr_name`"};bot.addCommand(bot.CommunityCommand(t)),bot.addCommand(n)}(),function(){"use strict";function e(e){var t=e.toUpperCase();return r.hasOwnProperty(t)?r[t]:a.hasOwnProperty(e)?a[e]:e}function t(e,t,n){bot.log(e,t,"/convert unit broken"),n(i[t]?i[t](e):{error:"Confuse converter with "+t+", receive error message"})}function n(){return Object.keys(i)}var o,r,i={C:function(e){return{F:1.8*e+32,K:e+273.15}},F:function(e){return{C:(e-32)/1.8,K:5*(e+459.67)/9}},K:function(e){return 0>e?{C:0,F:0}:{C:e-273.15,F:1.8*e-459.67}},m:function(e){return{f:3.280839895*e}},f:function(e){return{m:e/3.28083989}},km:function(e){return i.m(1e3*e)},cm:function(e){return i.m(e/100)},mm:function(e){return i.m(e/1e3)},i:function(e){return i.f(e/12)},d:function(e){return{r:e*Math.PI/180}},r:function(e){return{d:180*e/Math.PI}},g:function(e){return{lb:.0022*e,st:157473e-9*e}},lb:function(e){return{g:453.592*e,st:.0714286*e}},st:function(e){return{g:6350.29*e,lb:14*e}},kg:function(e){return i.g(1e3*e)}},a={lbs:"lb",ft:"f",foot:"f",metres:"m",millimetres:"mm",killometres:"km",degrees:"d",radians:"r",grams:"g",kilograms:"kg",inches:"i",stones:"st"};o={AED:!0,ANG:!0,ARS:!0,AUD:!0,BDT:!0,BGN:!0,BHD:!0,BND:!0,BOB:!0,BRL:!0,BWP:!0,CAD:!0,CHF:!0,CLP:!0,CNY:!0,COP:!0,CRC:!0,CZK:!0,DKK:!0,DOP:!0,DZD:!0,EEK:!0,EGP:!0,EUR:!0,FJD:!0,GBP:!0,HKD:!0,HNL:!0,HRK:!0,HUF:!0,IDR:!0,ILS:!0,INR:!0,JMD:!0,JOD:!0,JPY:!0,KES:!0,KRW:!0,KWD:!0,KYD:!0,KZT:!0,LBP:!0,LKR:!0,LTL:!0,LVL:!0,MAD:!0,MDL:!0,MKD:!0,MUR:!0,MVR:!0,MXN:!0,MYR:!0,NAD:!0,NGN:!0,NIO:!0,NIS:!0,NOK:!0,NPR:!0,NZD:!0,OMR:!0,PEN:!0,PGK:!0,PHP:!0,PKR:!0,PLN:!0,PYG:!0,QAR:!0,RON:!0,RSD:!0,RUB:!0,SAR:!0,SCR:!0,SEK:!0,SGD:!0,SKK:!0,SLL:!0,SVC:!0,THB:!0,TND:!0,TRY:!0,TTD:!0,TWD:!0,TZS:!0,UAH:!0,UGX:!0,USD:!0,UYU:!0,UZS:!0,VEF:!0,VND:!0,XOF:!0,YER:!0,ZAR:!0,ZMK:!0},r={"€":"EUR","£":"GBP","₤":"GBP","₨":"INR","₹":"INR","¥":"JPY","¥":"JPY","₪":"ILS",$:"USD"};var s=/(-?\d+\.?\d*)\s*(\S+)(\s+(?:(?:to|in)\s+)?(\S+))?$/,c=function(r,i){function a(e){bot.log(e,"/convert answer");var t;t=e.substr?e:e.error?e.error:c(e),i&&i.call?i(t):r.reply(t)}function c(e){function t(e){return!p||p===e}function n(t){return e[t].maxDecimal(4)+t}var o=Object.keys(e);return o.length?o.filter(t).map(n).join(", "):"Could not convert {0} to {1}".supplant(d,p)}if("list"===r.toLowerCase())return void a(n().join(", "));var m=s.exec(r);if(!m)return void a({error:"Unidentified format; please see `/help convert`"});var l=Number(m[1]),d=m[2],p=m[4]||"",h=!1;bot.log(l,d,p,"/convert input"),d=e(d),p=e(p),o[d.toUpperCase()]&&(h=!0),h?u.convert(l,d,p,a):t(l,d,a)},u={ratesCache:{},convert:function(e,t,n,o){this.from=t,this.to=n,this.upFrom=t.toUpperCase(),this.upTo=n.toUpperCase();var r=this.errorMessage();return r?void o({error:r}):(bot.log(e,t,n,"/convert money broken"),void this.getRate(function(t){var r={};r[n]=e*t,o(r)}))},getRate:function(e){function t(t){o=t.rate,n.updateCache(o),e(o)}var n=this,o=this.checkCache();return o?void e(o):void IO.jsonp({url:"http://rate-exchange.appspot.com/currency",jsonpName:"callback",data:{from:n.from,to:n.to},fun:t})},updateCache:function(e){this.ratesCache[this.upFrom]=this.ratesCache[this.upFrom]||{},this.ratesCache[this.upFrom][this.upTo]={rate:e,time:Date.now()}},checkCache:function(){var e,t=Date.now(),n=this.ratesCache[this.upFrom]&&(e=this.ratesCache[this.upFrom][this.upTo])&&e.time-t<=18e6;return console.log(this.ratesCache,n),n?e.rate:!1},errorMessage:function(){return this.to?o[this.upTo]?void 0:this.to+" aint no currency I ever heard of":"What do you want to convert "+this.from+" to?"}};bot.addCommand({name:"convert",fun:c,permissions:{del:"NONE"},description:"Converts several units and currencies, case sensitive. `/convert [to|in ]` Pass in list for supported units `/convert list`",async:!0})}();var cowsay=function(){"use strict";function e(e,t){function n(e,n){var r=n.length;return o+r>t&&(e+="\n",o=0),o+=r+1,e+n+" "}var o=0;return e.split(" ").reduce(n,"")}function t(e,t,n){return n=n||" ",(e+Array(t).join(n)).slice(0,t)}var n={defaults:{e:"oo",T:" ",t:!1,W:40},cow:[""," L ^__^"," L (e)\\_______"," (__)\\ )\\/\\"," T ||----w |"," || ||"].join("\n"),moo:function(n,o){var r=this.defaults;return this.eyes=t(o.e||r.e,2).slice(0,2),this.tongue=t(o.T||r.T,2).slice(0,2),this.line=o.t?"O":"\\",this.thinking=o.t,this.message=e(n,o.W||r.W).trim(),this.makeBalloon()+this.makeCow()},makeCow:function(){return this.cow.replace(/e/g,this.eyes).replace(/T/g,this.tongue).replace(/L/g,this.line)},makeBalloon:function(){function e(e,n){var o;return o=0===n?a.slice(0,2):n===i-1?a.slice(2,4):a.slice(2),o[0]+" "+t(e,r)+" "+o[1]}function n(e,t){return t.length>e?t.length:e}var o=this.message.split("\n"),r=o.reduce(n,0),i=o.length,a=this.chooseBorders(i),s=o.map(e),c=new Array(r+2);return s.unshift(" "+c.join("_")),s.push(" "+c.join("-")),s.join("\n")},chooseBorders:function(e){var t;return t=this.thinking?["(",")","(",")","(",")"]:1===e?["<",">"]:["/","\\","\\","/","|","|"]}};return n}();bot.listen(/cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/,function(e){function t(e){for(var t={},n=0,o=e.length;o>n;n+=2)e[n]&&e[n+1]&&(t[e[n]]=e[n+1]);return t}var n=t(e.matches.slice(2,-1));n.t="think"===e.matches[1],bot.log(n,"cowsay opts");var o=cowsay.moo(e.matches.pop(),n);e.send(e.codify(o))}),function(){"use strict";var e=["No definition found.","It means I aint got time to learn your $5 words.","My pocket dictionary just isn't good enough for you."],t="http://en.wiktionary.org",n=/(alternative (spelling|term)|common misspelling|informal form|archaic spelling) (of|for) (.+?)\.?$/i,o={command:function(n,o){function r(r){bot.log(r,"/define result");var i,a=r.pageid;i=0>a?e.random():bot.adapter.link(r.name,t+"/wiki?curid="+a)+" "+r.text,r.overflow&&(i="Index too large; showing last definition. "+i),o&&o.call?o(i):n.reply(i)}var i=n.parse(),a=Number(i.pop()),s=i.join(" ");a||(a=0,s=n.toString()),bot.log(n,s,a,"/define input");this.fetchDefinition(s,a,r)},fetchDefinition:function(e,t,n){function o(e){var i=e.query,a=i.pageids[0],s=i.pages[a],c=s.extract;if("-1"===a)return void n({pageid:-1});var u=document.createElement("body");u.innerHTML=c;var m=r.extractDefinitions(u),l=m[0],d=!1;return bot.log(m,"/define got definitions"),l.alternative?(bot.log(l.alternative,"/define found alternative"),void r.fetchData(l.alternative,o)):(l=m[t],l||(l=m[m.length-1],d=!0),void n({name:s.title,text:l.text,pageid:a,overflow:d}))}var r=this;this.fetchData(e,o)},extractDefinitions:function(e){var t=e.getElementsByTagName("ol")[0];return console.log(t,"/define definition list"),Array.from(t.children).map(this.extractSingleDefinition,this)},extractSingleDefinition:function(e){function n(e){var n=t+e.getAttribute("href"),o=bot.adapter.link(e.textContent,n),r=document.createTextNode(o);e.parentNode.replaceChild(r,e)}var o=this.extractAlternative(e.textContent);Array.from(e.children).forEach(function(t){"UL"===t.tagName&&e.removeChild(t)});for(var r=e.getElementsByTagName("a");r.length;)n(r[0]);return{alternative:o,text:e.textContent}},extractAlternative:function(e){return(n.exec(e)||[]).pop()},fetchData:function(e,t){var n=this;IO.jsonp({url:"http://en.wiktionary.org/w/api.php",jsonpName:"callback",data:{action:"query",titles:e,format:"json",prop:"extracts",indexpageids:!0},fun:function(e){t.call(n,e)}})}};bot.addCommand({name:"define",fun:o.command,thisArg:o,permissions:{del:"NONE"},description:"Fetches definition for a given word. `/define something`",async:!0})}(),function(){"use strict";function e(e,t){t+=2*Math.random()*r.jitter-r.jitter;for(var n=0;t>n;n++)e=" "+e;return e}function t(e){return" "+e+"\r"}function n(e){return e.sort(function(){return Math.random()-.5})}function o(o){for(var i=(o.length>0?o.toString():r.message).split(","),a=n(r.words.slice(0)),s=t(e("wow",4+4*Math.random()|0));i.length>a.length;)a=a.concat(n(r.words.slice(0)));for(;i.length;){var c="";a.length&&(c+=a.shift()+" "),c+=i.shift(),s+=t(e(c,r.spaces[i.length%3-1]))}o.send(s+"\r ")}var r={message:"fail,user,pro",spaces:[25,14,1],jitter:4,words:["so","very","such","much","many"]};bot.addCommand({fun:o,name:"doge",permissions:{del:"NONE"},description:"so shibe, much doge, wow `/doge one,two,three[,nth]",unTellable:!0})}(),bot.listen(/(which |what |give me a )?firefly( episode)?/i,function(e){var t=["Serenity","The Train Job","Bushwhacked","Shindig","Safe","Our Mrs. Reynolds","Jaynestown","Out of Gas","Ariel","War Stories","Trash","The Message","Heart of Gold","Objects in Space"];if(-1===e.indexOf("episode")&&Math.random()<.05)return"Serenity (movie)";var n=Math.floor(14*Math.random());return"Episode {0} - {1}".supplant(n+1,t[n])}),function(){var e=["The Google contains no such knowledge","There are no search results. Run.","My Google Fu has failed."],t={name:"google",fun:function(e,t){function n(n){var r=o.format(n);t&&t.call?t(r):e.directreply(r)}var o=this;this.logic(e,n)},logic:function(e,t){function n(n){if(bot.log(n,"/google response"),200!==n.responseStatus)return void finish("My Google-Fu is on vacation; status "+n.responseStatus);var o=n.responseData.results.slice(0,3);o.query=e,bot.log(o,"/google results"),t(o)}IO.jsonp.google(String(e)+" -site:w3schools.com",n)},format:function(t){function n(e){var t=IO.decodehtmlEntities(e.titleNoFormatting);return bot.adapter.link(t,e.unescapedUrl)}function o(e){var t="http://google.com/search?q="+encodeURIComponent(e);return bot.adapter.link("*",t)}if(!t.length)return e.random();var r=o(t.query)+" "+t.map(n).join(" ; ");return r.length>bot.adapter.maxLineLength&&(r=t.pluck("unescapedUrl").join(" ; ")),r},permissions:{del:"NONE"},description:"Search Google. `/google query`",async:!0};bot.addCommand(t)}(),function(){"use strict";var e=function(e,t){function n(e){t(e.word.toLowerCase().trim())}var o="http://sleepy-bastion-8674.herokuapp.com/";Number(e)&&(o+="?length="+e),IO.jsonp({url:o,jsonpName:"callback",fun:n})},t={dude:[" +---+"," | |"," | 413"," | 2"," | 5 6","__+__"].join("\n"),parts:["","O","|","/","\\","/","\\"],word:"",revealed:"",guesses:[],guessNum:0,maxGuess:6,end:!0,msg:null,validGuessRegex:/^[a-zA-Z]+$/,receiveMessage:function(e){return this.msg=e,this.end?void this["new"](e):this.handleGuess(e)},"new":function(n){function o(e){bot.log(e+" /hang random"),t.word=e,r.revealed=new Array(e.length+1).join("-"),r.guesses=[],r.guessNum=0,r.guessMade(),r.end=!1,n.length&&!Number(n)&&r.receiveMessage(n)}var r=this;e(n,o)},handleGuess:function(e){var t=e.slice().toLowerCase();bot.log(t,"handleGuess");var n=this.checkGuess(t);if(n)return n;var o=this.word.indexesOf(t);return o.forEach(function(e){this.uncoverPart(t,e)},this),o.length||this.guessNum++,this.guesses.push(t),this.guessMade(),bot.log(t,"handleGuess handled"),this.loseCheck()?this.lose():this.winCheck()?this.win():void 0},checkGuess:function(e){return!e.length||Number(e)?"We're already playing!":this.validGuessRegex.test(e)?this.guesses.indexOf(e)>-1?e+" was already submitted":e.length>this.word.length?bot.adapter.codify(e)+" is too long to fit":void 0:"I will only accept alpha characters"},uncoverPart:function(e,t){this.revealed=this.revealed.slice(0,t)+e+this.revealed.slice(t+e.length)},preparePrint:function(){if(!this.end){var e=this,t=this.dude.replace(/\d/g,function(t){return t>e.guessNum?" ":e.parts[t]}),n=this.guesses.sort().join(", ")+"\n"+this.revealed,o=this.msg.codify(t+"\n"+n);bot.log(o,this.msg),this.msg.send(o)}},win:function(){return this.end=!0,"Correct! The word is "+this.word+"."},lose:function(){return this.end=!0,"You people suck. The word is "+this.word},winCheck:function(){return this.word===this.revealed},loseCheck:function(){return this.guessNum>=this.maxGuess},guessMade:function(){clearTimeout(this.printTimeout),this.printTimeout=setTimeout(this.preparePrint.bind(this),2e3)}};bot.addCommand({name:"hang",fun:t.receiveMessage,thisArg:t})}(),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/imdb result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:imdb.com",n)})}bot.addCommand({name:"imdb",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches imdb page. `/imdb what`",async:!0})}(),function(){function e(n){if(!n.content)return t;var o=n.parse(!0);if(o.length>1)return o.map(e).join(" ");var r,i=n.trim().replace(/^\$/,"jQuery"),a=i.split("."),s=!1,c=i;return bot.log(i,a,"/jquery input"),3===a.length&&(a=[a[2]]),"jQuery"===a[0]&&jQuery[a[1]]?s=!0:1===a.length&&jQuery.prototype[a[0]]?(c=a[0],s=!0):jQuery[a[0]]&&(c="jQuery."+a[0],s=!0),r=s?t+c:t+"?s="+encodeURIComponent(n),bot.log(r,"/jquery link"),r}var t="http://api.jquery.com/";bot.addCommand({name:"jquery",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches documentation link from jQuery API. `/jquery what`"})}(),function(){"use strict";function e(e){bot.log(e,"/learn input");var n=e.parse(),r={name:n[0],output:n[1],input:n[2]||".*",creator:e.get("user_name"),creatorID:e.get("user_id"),date:new Date};r.name=r.name.toLowerCase();var a=o(r);return a?a:(r.input=new RegExp(r.input),r.description=["User-taught command:",n[3]||"",e.codify(r.output)].join(" "),bot.log(r,"/learn parsed"),t(r),i(r),"Command "+r.name+" learned")}function t(e){var t=bot.Command({name:e.name,description:e.description,creator:e.creator,date:e.date,fun:n(e),permissions:{use:"ALL",del:e.creatorID?[e.creatorID]:"OWNER"}});t.learned=!0,t.del=function(n){return function(){a(e.name),n.call(t)}}(t.del),bot.log(t,"/learn addCustomCommand"),bot.addCommand(t)}function n(e){function t(){var t=c.exec(e.output)||[,"user"],n=t[1];return n.slice(1,-1)}var n=e.output.replace(c,"").trim(),o=t();return bot.log(e,"/learn makeCustomCommand"),function(t){bot.log(t,e.name+" input");var r=bot.Message(n,t.get()),i=e.input.exec(t);if(!i)return m.supplant(e);var a=bot.parseMacro(r,i);switch(o){case"":t.send(a);break;case"msg":t.directreply(a);break;default:t.reply(a)}}}function o(e){function t(e){if(!bot.commandExists(e))return!0;var t=bot.getCommand(e);return t.learned&&t.date.getTime()+3e5>Date.now()}var n,o=Object.keys(e).some(function(t){return!e[t]});return o?n="Illegal `/learn` object; see `/help learn`":/\s/.test(e.name)?n="Invalid command name":t(e.name)?u.test(e.output)&&(n="Please enter some output"):n="Command "+e.name+" already exists",n}function r(){function e(e,o){o=JSON.parse(o),o.input=n(o.input),o.date=new Date(Date.parse(o.date)),t(o)}function n(e){var t=e.toString().split("/");return new RegExp(t.slice(1,-1).join("/"),t[t.length-1])}Object.iterate(s,e)}function i(e){s[e.name]=JSON.stringify(e),bot.memory.save("learn")}function a(e){delete s[e],bot.memory.save("learn")}var s=bot.memory.get("learn"),c=/^(<>||)/i,u=new RegExp(c.source+"$","i"),m="Input not matching `{input}`. Help: {description}";bot.addCommand({name:"learn",fun:e,privileges:{del:"NONE"},description:"Teaches me a command. `/learn cmdName outputPattern [inputRegex [description]]`"}),r()}(),bot.addCommand({name:"live",fun:function(){return bot.stopped?(bot["continue"](),"And on this day, you shall paint eggs for a giant bunny."):"I'm not dead! Honest!"},permissions:{del:"NONE",use:"OWNER"},description:"Resurrects me (:D) if I'm down (D:)"}),bot.addCommand(bot.CommunityCommand({name:"die",fun:function(){return bot.stopped?"Kill me once, shame on you, kill me twice...":(bot.stop(),"You killed me!")},permissions:{del:"NONE",use:"OWNER"},description:"Kills me :(",pendingMessage:"I will shut up after {0} more invocations."})),function(){function e(e,t){function n(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results[0];bot.log(t,"/mdn result");var n=IO.decodehtmlEntities(t.titleNoFormatting.split(" -")[0].trim());a.formatted.push(bot.adapter.link(n,t.url)),a.unescapedUrls.push(t.url),a.formatted.length===i.length&&o()}function o(){var e=a.formatted.join(", ");e.length>bot.adapter.maxLineLength&&(e=a.unescapedUrls.join(", ")),r(e)}function r(n){t&&t.call?t(n):e.reply(n)}var i=e.toString().split(/,\s*/g),a={unescapedUrls:[],formatted:[]};i.forEach(function(e){IO.jsonp.google(e+" site:developer.mozilla.org",n)})}bot.addCommand({name:"mdn",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches mdn documentation. `/mdn what`",async:!0})}(),function(){function e(e){return t+o[e]+"."+n}var t="http://cdn.alltheragefaces.com/img/faces/png/",n="png",o={deskflip:"angry-desk-flip",fuu:"rage-classic",iseewhatyoudidthere:"happy-i-see-what-you-did-there-(clean)",no:"angry-no",notbad:"obama-not-bad",ohyou:"happy-oh-stop-it-you",okay:"okay-okay-clean",troll:"troll-troll-face",trollface:"troll-troll-face",youdontsay:"misc-you-dont-say"},r=new RegExp("^("+Object.keys(o).map(RegExp.escape).join("|")+")\\.(jpe?g|png)$");IO.register("input",function(t){var n=t.content.toLowerCase(),o=r.exec(n);if(o){var i=e(o[1]);bot.adapter.out.add(bot.adapter.directreply(t.message_id)+" "+i,t.room_id)}}),bot.addCommand({name:"meme",fun:function(t){var n=t.replace(/\.\w+$/,"");return n&&"list"!==n?o.hasOwnProperty(n)?void t.directreply(e(n)):"Sorry, I don't know that one.":Object.keys(o).join(", ")},permissions:{del:"NONE"},description:"Return a simple meme link. Pass no arguments or `list` to get a list of known memes. `/meme [memeName]`."})}(),function(){"use strict";function e(e){function o(t){bot.log(t,"/mustache finish"),e.directreply("http://mustachify.me/"+i.mustache+"?src="+t)}function r(e){var t=e.parse(),n=t.pop(),o={};return t.length>0&&!/\D/.test(n)?(o.usrid=t.join(" "),o.mustache=n):(o.usrid=e.content,o.mustache=Math.rand(0,5)),o}var i=r(e),a=i.usrid;if(bot.log(i,"/mustache input"),t(a))return void o(encodeURIComponent(a));if(a?/\D/.test(a)&&(a=e.findUserId(a)):a=e.get("user_id"),bot.log(a,"/mustache mapped"),!bot.users.hasOwnProperty(a))return n.supplant(a,bot.adapter.roomid);if(Number(a)===bot.adapter.user_id)return["Nobody puts a mustache on me. Again.","Mustache me once, shame on you. Mustache me ---twice--- 9 times..."].random();var s=bot.users[a].email_hash;o("!"===s[0]?encodeURIComponent(s.slice(1))+"#.png":"http%3A%2F%2Fwww.gravatar.com%2Favatar%2F{0}%3Fs%3D256%26d%3Didenticon#.png".supplant(s))}function t(e){return e.startsWith("http")||e.startsWith("www")}var n="User {0} was not found in room {1} (sorry, mustache only works there).",o={name:"mustache",fun:e,privileges:{del:"NONE"},description:"Mustachifies a user. `/mustache [link|usrid|username] [mustache=rand(0,5)]`"};bot.addCommand(o);var r=Object.merge(o,{name:"moustache"});bot.addCommand(r)}(),function(){function e(){Date.now();a=a.filter(function(e){return e.time-=c,e.time<=0?(t(e),!1):!0}),setTimeout(e,c)}function t(e){bot.log(e,"nudge fire"),e.msg.reply(e.message)}function n(e,t,n){var o;if(bot.log(e,t,"/nudge input"),e=parseFloat(e),o=6e4*e,isNaN(o))return"Many things can be labeled Not a Number; a delay should not be one of them.";s+=1;var r={msg:n,message:"*nudge* "+t,register:Date.now(),time:o,id:s};return a.push(r),bot.log(r,a,"/nudge register"),"Nudge #"+s+" registered."}function o(e,t){var n,o;return a.some(function(t,r){return t.id===e?(n=t,o=r,!0):void 0}),n?n.msg.get("user_name")!==t.get("user_name")?"It's not nice to try and remove a nudge which ain't yours":(bot.log(a[o],"/nudge remove #"+e),a.splice(o,1),"Nudge annhiliated"):["Nudge not found. Maybe it was already triggered, or this is a parallal universe.","I looked for nudge #"+e+", but all I found was this goat."].random()}function r(e){var t=e.parse(),r=t[0],i=t.slice(1).join(" ");return"remove"===r?o(Number(t[1]),e):n(r,i,e)}function i(e){return n(e.matches[1],e.matches[2],e)}var a=[],s=0,c=6e3;setTimeout(e,c),bot.addCommand({name:"nudge",fun:r,permissions:{del:"NONE"},description:"Register a nudge after an interval. `/nudge intervalInMinutes message`, `/nudge remove id` to remove, or the listener, `nudge|remind|poke me? in? intervalInMinutes message`",unTellable:!0}),bot.listen(/(?:nudge|remind|poke)\s(?:me\s)?(?:in\s)?(\d+m?)\s?(.*)$/,i)}(),function(){function e(e){function n(e){return e.name.toLowerCase().indexOf(i)>-1}function o(t){var n=e.escape(t.name);return"["+n+"](http://es5.github.com/#"+t.section+")"}var r,i=e.content.toLowerCase();return r=t.filter(n).map(o),bot.log(r,"/spec done"),r.length?r.join(", "):e+" not found in spec"}var t;t=[{section:"introduction",name:"Introduction"},{section:"x1",name:"1 Scope"},{section:"x2",name:"2 Conformance"},{section:"x3",name:"3 Normative references"},{section:"x4",name:"4 Overview"},{section:"x4.1",name:"4.1 Web Scripting"},{section:"x4.2",name:"4.2 Language Overview"},{section:"x4.2.1",name:"4.2.1 Objects"},{section:"x4.2.2",name:"4.2.2 The Strict Variant of ECMAScript"},{section:"x4.3",name:"4.3 Definitions"},{section:"x4.3.1",name:"4.3.1 type"},{section:"x4.3.2",name:"4.3.2 primitive value"},{section:"x4.3.3",name:"4.3.3 object"},{section:"x4.3.4",name:"4.3.4 constructor"},{section:"x4.3.5",name:"4.3.5 prototype"},{section:"x4.3.6",name:"4.3.6 native object"},{section:"x4.3.7",name:"4.3.7 built-in object"},{section:"x4.3.8",name:"4.3.8 host object"},{section:"x4.3.9",name:"4.3.9 undefined value"},{section:"x4.3.10",name:"4.3.10 Undefined type"},{section:"x4.3.11",name:"4.3.11 null value"},{section:"x4.3.12",name:"4.3.12 Null type"},{section:"x4.3.13",name:"4.3.13 Boolean value"},{section:"x4.3.14",name:"4.3.14 Boolean type"},{section:"x4.3.15",name:"4.3.15 Boolean object"},{section:"x4.3.16",name:"4.3.16 String value"},{section:"x4.3.17",name:"4.3.17 String type"},{section:"x4.3.18",name:"4.3.18 String object"},{section:"x4.3.19",name:"4.3.19 Number value"},{section:"x4.3.20",name:"4.3.20 Number type"},{section:"x4.3.21",name:"4.3.21 Number object"},{section:"x4.3.22",name:"4.3.22 Infinity"},{section:"x4.3.23",name:"4.3.23 NaN"},{section:"x4.3.24",name:"4.3.24 function"},{section:"x4.3.25",name:"4.3.25 built-in function"},{section:"x4.3.26",name:"4.3.26 property"},{section:"x4.3.27",name:"4.3.27 method"},{section:"x4.3.28",name:"4.3.28 built-in method"},{section:"x4.3.29",name:"4.3.29 attribute"},{section:"x4.3.30",name:"4.3.30 own property"},{section:"x4.3.31",name:"4.3.31 inherited property"},{section:"x5",name:"5 Notational Conventions"},{section:"x5.1",name:"5.1 Syntactic and Lexical Grammars"},{section:"x5.1.1",name:"5.1.1 Context-Free Grammars"},{section:"x5.1.2",name:"5.1.2 The Lexical and RegExp Grammars"},{section:"x5.1.3",name:"5.1.3 The Numeric String Grammar"},{section:"x5.1.4",name:"5.1.4 The Syntactic Grammar"},{section:"x5.1.5",name:"5.1.5 The JSON Grammar"},{section:"x5.1.6",name:"5.1.6 Grammar Notation"},{section:"x5.2",name:"5.2 Algorithm Conventions"},{section:"x6",name:"6 Source Text"},{section:"x7",name:"7 Lexical Conventions"},{section:"x7.1",name:"7.1 Unicode Format-Control Characters"},{section:"x7.2",name:"7.2 White Space"},{section:"x7.3",name:"7.3 Line Terminators"},{section:"x7.4",name:"7.4 Comments"},{section:"x7.5",name:"7.5 Tokens"},{section:"x7.6",name:"7.6 Identifier Names and Identifiers"},{section:"x7.6.1",name:"7.6.1 Reserved Words"},{section:"x7.6.1.1",name:"7.6.1.1 Keywords"},{section:"x7.6.1.2",name:"7.6.1.2 Future Reserved Words"},{section:"x7.7",name:"7.7 Punctuators"},{section:"x7.8",name:"7.8 Literals"},{section:"x7.8.1",name:"7.8.1 Null Literals"},{section:"x7.8.2",name:"7.8.2 Boolean Literals"},{section:"x7.8.3",name:"7.8.3 Numeric Literals"},{section:"x7.8.4",name:"7.8.4 String Literals"},{section:"x7.8.5",name:"7.8.5 Regular Expression Literals"},{section:"x7.9",name:"7.9 Automatic Semicolon Insertion"},{section:"x7.9.1",name:"7.9.1 Rules of Automatic Semicolon Insertion"},{section:"x7.9.2",name:"7.9.2 Examples of Automatic Semicolon Insertion"},{section:"x8",name:"8 Types"},{section:"x8.1",name:"8.1 The Undefined Type"},{section:"x8.2",name:"8.2 The Null Type"},{section:"x8.3",name:"8.3 The Boolean Type"},{section:"x8.4",name:"8.4 The String Type"},{section:"x8.5",name:"8.5 The Number Type"},{section:"x8.6",name:"8.6 The Object Type"},{section:"x8.6.1",name:"8.6.1 Property Attributes"},{section:"x8.6.2",name:"8.6.2 Object Internal Properties and Methods"},{section:"x8.7",name:"8.7 The Reference Specification Type"},{section:"x8.7.1",name:"8.7.1 GetValue (V)"},{section:"x8.7.2",name:"8.7.2 PutValue (V, W)"},{section:"x8.8",name:"8.8 The List Specification Type"},{section:"x8.9",name:"8.9 The Completion Specification Type"},{section:"x8.10",name:"8.10 The Property Descriptor and Property Identifier Specification Types"},{section:"x8.10.1",name:"8.10.1 IsAccessorDescriptor ( Desc )"},{section:"x8.10.2",name:"8.10.2 IsDataDescriptor ( Desc )"},{section:"x8.10.3",name:"8.10.3 IsGenericDescriptor ( Desc )"},{section:"x8.10.4",name:"8.10.4 FromPropertyDescriptor ( Desc )"},{section:"x8.10.5",name:"8.10.5 ToPropertyDescriptor ( Obj )"},{section:"x8.11",name:"8.11 The Lexical Environment and Environment Record Specification Types"},{section:"x8.12",name:"8.12 Algorithms for Object Internal Methods"},{section:"x8.12.1",name:"8.12.1 [[GetOwnProperty]] (P)"},{section:"x8.12.2",name:"8.12.2 [[GetProperty]] (P)"},{section:"x8.12.3",name:"8.12.3 [[Get]] (P)"},{section:"x8.12.4",name:"8.12.4 [[CanPut]] (P)"},{section:"x8.12.5",name:"8.12.5 [[Put]] ( P, V, Throw )"},{section:"x8.12.6",name:"8.12.6 [[HasProperty]] (P)"},{section:"x8.12.7",name:"8.12.7 [[Delete]] (P, Throw)"},{section:"x8.12.8",name:"8.12.8 [[DefaultValue]] (hint)"},{section:"x8.12.9",name:"8.12.9 [[DefineOwnProperty]] (P, Desc, Throw)"},{section:"x9",name:"9 Type Conversion and Testing"},{section:"x9.1",name:"9.1 ToPrimitive"},{section:"x9.2",name:"9.2 ToBoolean"},{section:"x9.3",name:"9.3 ToNumber"},{section:"x9.3.1",name:"9.3.1 ToNumber Applied to the String Type"},{section:"x9.4",name:"9.4 ToInteger"},{section:"x9.5",name:"9.5 ToInt32: (Signed 32 Bit Integer)"},{section:"x9.6",name:"9.6 ToUint32: (Unsigned 32 Bit Integer)"},{section:"x9.7",name:"9.7 ToUint16: (Unsigned 16 Bit Integer)"},{section:"x9.8",name:"9.8 ToString"},{section:"x9.8.1",name:"9.8.1 ToString Applied to the Number Type"},{section:"x9.9",name:"9.9 ToObject"},{section:"x9.10",name:"9.10 CheckObjectCoercible"},{section:"x9.11",name:"9.11 IsCallable"},{section:"x9.12",name:"9.12 The SameValue Algorithm"},{section:"x10",name:"10 Executable Code and Execution Contexts"},{section:"x10.1",name:"10.1 Types of Executable Code"},{section:"x10.1.1",name:"10.1.1 Strict Mode Code"},{section:"x10.2",name:"10.2 Lexical Environments"},{section:"x10.2.1",name:"10.2.1 Environment Records"},{section:"x10.2.1.1",name:"10.2.1.1 Declarative Environment Records"},{section:"x10.2.1.1.1",name:"10.2.1.1.1 HasBinding(N)"},{section:"x10.2.1.1.2",name:"10.2.1.1.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.1.3",name:"10.2.1.1.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.1.4",name:"10.2.1.1.4 GetBindingValue(N,S)"},{section:"x10.2.1.1.5",name:"10.2.1.1.5 DeleteBinding (N)"},{section:"x10.2.1.1.6",name:"10.2.1.1.6 ImplicitThisValue()"},{section:"x10.2.1.1.7",name:"10.2.1.1.7 CreateImmutableBinding (N)"},{section:"x10.2.1.1.8",name:"10.2.1.1.8 InitializeImmutableBinding (N,V)"},{section:"x10.2.1.2",name:"10.2.1.2 Object Environment Records"},{section:"x10.2.1.2.1",name:"10.2.1.2.1 HasBinding(N)"},{section:"x10.2.1.2.2",name:"10.2.1.2.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.2.3",name:"10.2.1.2.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.2.4",name:"10.2.1.2.4 GetBindingValue(N,S)"},{section:"x10.2.1.2.5",name:"10.2.1.2.5 DeleteBinding (N)"},{section:"x10.2.1.2.6",name:"10.2.1.2.6 ImplicitThisValue()"},{section:"x10.2.2",name:"10.2.2 Lexical Environment Operations"},{section:"x10.2.2.1",name:"10.2.2.1 GetIdentifierReference (lex, name, strict)"},{section:"x10.2.2.2",name:"10.2.2.2 NewDeclarativeEnvironment (E)"},{section:"x10.2.2.3",name:"10.2.2.3 NewObjectEnvironment (O, E)"},{section:"x10.2.3",name:"10.2.3 The Global Environment"},{section:"x10.3",name:"10.3 Execution Contexts"},{section:"x10.3.1",name:"10.3.1 Identifier Resolution"},{section:"x10.4",name:"10.4 Establishing an Execution Context"},{section:"x10.4.1",name:"10.4.1 Entering Global Code"},{section:"x10.4.1.1",name:"10.4.1.1 Initial Global Execution Context"},{section:"x10.4.2",name:"10.4.2 Entering Eval Code"},{section:"x10.4.2.1",name:"10.4.2.1 Strict Mode Restrictions"},{section:"x10.4.3",name:"10.4.3 Entering Function Code"},{section:"x10.5",name:"10.5 Declaration Binding Instantiation"},{section:"x10.6",name:"10.6 Arguments Object"},{section:"x11",name:"11 Expressions"},{section:"x11.1",name:"11.1 Primary Expressions"},{section:"x11.1.1",name:"11.1.1 The this Keyword"},{section:"x11.1.2",name:"11.1.2 Identifier Reference"},{section:"x11.1.3",name:"11.1.3 Literal Reference"},{section:"x11.1.4",name:"11.1.4 Array Initialiser"},{section:"x11.1.5",name:"11.1.5 Object Initialiser"},{section:"x11.1.6",name:"11.1.6 The Grouping Operator"},{section:"x11.2",name:"11.2 Left-Hand-Side Expressions"},{section:"x11.2.1",name:"11.2.1 Property Accessors"},{section:"x11.2.2",name:"11.2.2 The new Operator"},{section:"x11.2.3",name:"11.2.3 Function Calls"},{section:"x11.2.4",name:"11.2.4 Argument Lists"},{section:"x11.2.5",name:"11.2.5 Function Expressions"},{section:"x11.3",name:"11.3 Postfix Expressions"},{section:"x11.3.1",name:"11.3.1 Postfix Increment Operator"},{section:"x11.3.2",name:"11.3.2 Postfix Decrement Operator"},{section:"x11.4",name:"11.4 Unary Operators"},{section:"x11.4.1",name:"11.4.1 The delete Operator"},{section:"x11.4.2",name:"11.4.2 The void Operator"},{section:"x11.4.3",name:"11.4.3 The typeof Operator"},{section:"x11.4.4",name:"11.4.4 Prefix Increment Operator"},{section:"x11.4.5",name:"11.4.5 Prefix Decrement Operator"},{section:"x11.4.6",name:"11.4.6 Unary + Operator"},{section:"x11.4.7",name:"11.4.7 Unary - Operator"},{section:"x11.4.8",name:"11.4.8 Bitwise NOT Operator ( ~ )"},{section:"x11.4.9",name:"11.4.9 Logical NOT Operator ( ! )"},{section:"x11.5",name:"11.5 Multiplicative Operators"},{section:"x11.5.1",name:"11.5.1 Applying the * Operator"},{section:"x11.5.2",name:"11.5.2 Applying the / Operator"},{section:"x11.5.3",name:"11.5.3 Applying the % Operator"},{section:"x11.6",name:"11.6 Additive Operators"},{section:"x11.6.1",name:"11.6.1 The Addition operator ( + )"},{section:"x11.6.2",name:"11.6.2 The Subtraction Operator ( - )"},{section:"x11.6.3",name:"11.6.3 Applying the Additive Operators to Numbers"},{section:"x11.7",name:"11.7 Bitwise Shift Operators"},{section:"x11.7.1",name:"11.7.1 The Left Shift Operator ( << )"},{section:"x11.7.2",name:"11.7.2 The Signed Right Shift Operator ( >> )"},{section:"x11.7.3",name:"11.7.3 The Unsigned Right Shift Operator ( >>> )"},{section:"x11.8",name:"11.8 Relational Operators"},{section:"x11.8.1",name:"11.8.1 The Less-than Operator ( < )"},{section:"x11.8.2",name:"11.8.2 The Greater-than Operator ( > )"},{section:"x11.8.3",name:"11.8.3 The Less-than-or-equal Operator ( <= )"},{section:"x11.8.4",name:"11.8.4 The Greater-than-or-equal Operator ( >= )"},{section:"x11.8.5",name:"11.8.5 The Abstract Relational Comparison Algorithm"},{section:"x11.8.6",name:"11.8.6 The instanceof operator"},{section:"x11.8.7",name:"11.8.7 The in operator"},{section:"x11.9",name:"11.9 Equality Operators"},{section:"x11.9.1",name:"11.9.1 The Equals Operator ( == )"},{section:"x11.9.2",name:"11.9.2 The Does-not-equals Operator ( != )"},{section:"x11.9.3",name:"11.9.3 The Abstract Equality Comparison Algorithm"},{section:"x11.9.4",name:"11.9.4 The Strict Equals Operator ( === )"},{section:"x11.9.5",name:"11.9.5 The Strict Does-not-equal Operator ( !== )"},{section:"x11.9.6",name:"11.9.6 The Strict Equality Comparison Algorithm"},{section:"x11.10",name:"11.10 Binary Bitwise Operators"},{section:"x11.11",name:"11.11 Binary Logical Operators"},{section:"x11.12",name:"11.12 Conditional Operator ( ? : )"},{section:"x11.13",name:"11.13 Assignment Operators"},{section:"x11.13.1",name:"11.13.1 Simple Assignment ( = )"},{section:"x11.13.2",name:"11.13.2 Compound Assignment ( op= )"},{section:"x11.14",name:"11.14 Comma Operator ( , )"},{section:"x12",name:"12 Statements"},{section:"x12.1",name:"12.1 Block"},{section:"x12.2",name:"12.2 Variable Statement"},{section:"x12.2.1",name:"12.2.1 Strict Mode Restrictions"},{section:"x12.3",name:"12.3 Empty Statement"},{section:"x12.4",name:"12.4 Expression Statement"},{section:"x12.5",name:"12.5 The if Statement"},{section:"x12.6",name:"12.6 Iteration Statements"},{section:"x12.6.1",name:"12.6.1 The do-while Statement"},{section:"x12.6.2",name:"12.6.2 The while Statement"},{section:"x12.6.3",name:"12.6.3 The for Statement"},{section:"x12.6.4",name:"12.6.4 The for-in Statement"},{section:"x12.7",name:"12.7 The continue Statement"},{section:"x12.8",name:"12.8 The break Statement"},{section:"x12.9",name:"12.9 The return Statement"},{section:"x12.10",name:"12.10 The with Statement"},{section:"x12.10.1",name:"12.10.1 Strict Mode Restrictions"},{section:"x12.11",name:"12.11 The switch Statement"},{section:"x12.12",name:"12.12 Labelled Statements"},{section:"x12.13",name:"12.13 The throw Statement"},{section:"x12.14",name:"12.14 The try Statement"},{section:"x12.14.1",name:"12.14.1 Strict Mode Restrictions"},{section:"x12.15",name:"12.15 The debugger statement"},{section:"x13",name:"13 Function Definition"},{section:"x13.1",name:"13.1 Strict Mode Restrictions"},{section:"x13.2",name:"13.2 Creating Function Objects"},{section:"x13.2.1",name:"13.2.1 [[Call]]"},{section:"x13.2.2",name:"13.2.2 [[Construct]]"},{section:"x13.2.3",name:"13.2.3 The Function Object"},{section:"x14",name:"14 Program"},{section:"x14.1",name:"14.1 Directive Prologues and the Use Strict Directive"},{section:"x15",name:"15 Standard Built-in ECMAScript Objects"},{section:"x15.1",name:"15.1 The Global Object"},{section:"x15.1.1",name:"15.1.1 Value Properties of the Global Object"},{section:"x15.1.1.1",name:"15.1.1.1 NaN"},{section:"x15.1.1.2",name:"15.1.1.2 Infinity"},{section:"x15.1.1.3",name:"15.1.1.3 undefined"},{section:"x15.1.2",name:"15.1.2 Function Properties of the Global Object"},{section:"x15.1.2.1",name:"15.1.2.1 eval (x)"},{section:"x15.1.2.1.1",name:"15.1.2.1.1 Direct Call to Eval"},{section:"x15.1.2.2",name:"15.1.2.2 parseInt (string , radix)"},{section:"x15.1.2.3",name:"15.1.2.3 parseFloat (string)"},{section:"x15.1.2.4",name:"15.1.2.4 isNaN (number)"},{section:"x15.1.2.5",name:"15.1.2.5 isFinite (number)"},{section:"x15.1.3",name:"15.1.3 URI Handling Function Properties"},{section:"x15.1.3.1",name:"15.1.3.1 decodeURI (encodedURI)"},{section:"x15.1.3.2",name:"15.1.3.2 decodeURIComponent (encodedURIComponent)"},{section:"x15.1.3.3",name:"15.1.3.3 encodeURI (uri)"},{section:"x15.1.3.4",name:"15.1.3.4 encodeURIComponent (uriComponent)"},{section:"x15.1.4",name:"15.1.4 Constructor Properties of the Global Object"},{section:"x15.1.4.1",name:"15.1.4.1 Object ( . . . )"},{section:"x15.1.4.2",name:"15.1.4.2 Function ( . . . )"},{section:"x15.1.4.3",name:"15.1.4.3 Array ( . . . )"},{section:"x15.1.4.4",name:"15.1.4.4 String ( . . . )"},{section:"x15.1.4.5",name:"15.1.4.5 Boolean ( . . . )"},{section:"x15.1.4.6",name:"15.1.4.6 Number ( . . . )"},{section:"x15.1.4.7",name:"15.1.4.7 Date ( . . . )"},{section:"x15.1.4.8",name:"15.1.4.8 RegExp ( . . . )"},{section:"x15.1.4.9",name:"15.1.4.9 Error ( . . . )"},{section:"x15.1.4.10",name:"15.1.4.10 EvalError ( . . . )"},{section:"x15.1.4.11",name:"15.1.4.11 RangeError ( . . . )"},{section:"x15.1.4.12",name:"15.1.4.12 ReferenceError ( . . . )"},{section:"x15.1.4.13",name:"15.1.4.13 SyntaxError ( . . . )"},{section:"x15.1.4.14",name:"15.1.4.14 TypeError ( . . . )"},{section:"x15.1.4.15",name:"15.1.4.15 URIError ( . . . )"},{section:"x15.1.5",name:"15.1.5 Other Properties of the Global Object"},{section:"x15.1.5.1",name:"15.1.5.1 Math"},{section:"x15.1.5.2",name:"15.1.5.2 JSON"},{section:"x15.2",name:"15.2 Object Objects"},{section:"x15.2.1",name:"15.2.1 The Object Constructor Called as a Function"},{section:"x15.2.1.1",name:"15.2.1.1 Object ( [ value ] )"},{section:"x15.2.2",name:"15.2.2 The Object Constructor"},{section:"x15.2.2.1",name:"15.2.2.1 new Object ( [ value ] )"},{section:"x15.2.3",name:"15.2.3 Properties of the Object Constructor"},{section:"x15.2.3.1",name:"15.2.3.1 Object.prototype"},{section:"x15.2.3.2",name:"15.2.3.2 Object.getPrototypeOf ( O )"},{section:"x15.2.3.3",name:"15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) "},{section:"x15.2.3.4",name:"15.2.3.4 Object.getOwnPropertyNames ( O )"},{section:"x15.2.3.5",name:"15.2.3.5 Object.create ( O [, Properties] )"},{section:"x15.2.3.6",name:"15.2.3.6 Object.defineProperty ( O, P, Attributes )"},{section:"x15.2.3.7",name:"15.2.3.7 Object.defineProperties ( O, Properties )"},{section:"x15.2.3.8",name:"15.2.3.8 Object.seal ( O )"},{section:"x15.2.3.9",name:"15.2.3.9 Object.freeze ( O )"},{section:"x15.2.3.10",name:"15.2.3.10 Object.preventExtensions ( O )"},{section:"x15.2.3.11",name:"15.2.3.11 Object.isSealed ( O )"},{section:"x15.2.3.12",name:"15.2.3.12 Object.isFrozen ( O )"},{section:"x15.2.3.13",name:"15.2.3.13 Object.isExtensible ( O )"},{section:"x15.2.3.14",name:"15.2.3.14 Object.keys ( O )"},{section:"x15.2.4",name:"15.2.4 Properties of the Object Prototype Object"},{section:"x15.2.4.1",name:"15.2.4.1 Object.prototype.constructor"},{section:"x15.2.4.2",name:"15.2.4.2 Object.prototype.toString ( )"},{section:"x15.2.4.3",name:"15.2.4.3 Object.prototype.toLocaleString ( )"},{section:"x15.2.4.4",name:"15.2.4.4 Object.prototype.valueOf ( )"},{section:"x15.2.4.5",name:"15.2.4.5 Object.prototype.hasOwnProperty (V)"},{section:"x15.2.4.6",name:"15.2.4.6 Object.prototype.isPrototypeOf (V)"},{section:"x15.2.4.7",name:"15.2.4.7 Object.prototype.propertyIsEnumerable (V)"},{section:"x15.2.5",name:"15.2.5 Properties of Object Instances"},{section:"x15.3",name:"15.3 Function Objects"},{section:"x15.3.1",name:"15.3.1 The Function Constructor Called as a Function"},{section:"x15.3.1.1",name:"15.3.1.1 Function (p1, p2, … , pn, body)"},{section:"x15.3.2",name:"15.3.2 The Function Constructor"},{section:"x15.3.2.1",name:"15.3.2.1 new Function (p1, p2, … , pn, body)"},{section:"x15.3.3",name:"15.3.3 Properties of the Function Constructor"},{section:"x15.3.3.1",name:"15.3.3.1 Function.prototype"},{section:"x15.3.3.2",name:"15.3.3.2 Function.length"},{section:"x15.3.4",name:"15.3.4 Properties of the Function Prototype Object"},{section:"x15.3.4.1",name:"15.3.4.1 Function.prototype.constructor"},{section:"x15.3.4.2",name:"15.3.4.2 Function.prototype.toString ( )"},{section:"x15.3.4.3",name:"15.3.4.3 Function.prototype.apply (thisArg, argArray)"},{section:"x15.3.4.4",name:"15.3.4.4 Function.prototype.call (thisArg [ , arg1 [ , arg2, … ] ] )"},{section:"x15.3.4.5",name:"15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, …]])"},{section:"x15.3.4.5.1",name:"15.3.4.5.1 [[Call]]"},{section:"x15.3.4.5.2",name:"15.3.4.5.2 [[Construct]]"},{section:"x15.3.4.5.3",name:"15.3.4.5.3 [[HasInstance]] (V)"},{section:"x15.3.5",name:"15.3.5 Properties of Function Instances"},{section:"x15.3.5.1",name:"15.3.5.1 length"},{section:"x15.3.5.2",name:"15.3.5.2 prototype"},{section:"x15.3.5.3",name:"15.3.5.3 [[HasInstance]] (V)"},{section:"x15.3.5.4",name:"15.3.5.4 [[Get]] (P)"},{section:"x15.4",name:"15.4 Array Objects"},{section:"x15.4.1",name:"15.4.1 The Array Constructor Called as a Function"},{section:"x15.4.1.1",name:"15.4.1.1 Array ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.2",name:"15.4.2 The Array Constructor"},{section:"x15.4.2.1",name:"15.4.2.1 new Array ( [ item0 [ , item1 [ , … ] ] ] )"},{section:"x15.4.2.2",name:"15.4.2.2 new Array (len)"},{section:"x15.4.3",name:"15.4.3 Properties of the Array Constructor"},{section:"x15.4.3.1",name:"15.4.3.1 Array.prototype"},{section:"x15.4.3.2",name:"15.4.3.2 Array.isArray ( arg )"},{section:"x15.4.4",name:"15.4.4 Properties of the Array Prototype Object"},{section:"x15.4.4.1",name:"15.4.4.1 Array.prototype.constructor"},{section:"x15.4.4.2",name:"15.4.4.2 Array.prototype.toString ( )"},{section:"x15.4.4.3",name:"15.4.4.3 Array.prototype.toLocaleString ( )"},{section:"x15.4.4.4",name:"15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.5",name:"15.4.4.5 Array.prototype.join (separator)"},{section:"x15.4.4.6",name:"15.4.4.6 Array.prototype.pop ( )"},{section:"x15.4.4.7",name:"15.4.4.7 Array.prototype.push ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.8",name:"15.4.4.8 Array.prototype.reverse ( )"},{section:"x15.4.4.9",name:"15.4.4.9 Array.prototype.shift ( )"},{section:"x15.4.4.10",name:"15.4.4.10 Array.prototype.slice (start, end)"},{section:"x15.4.4.11",name:"15.4.4.11 Array.prototype.sort (comparefn)"},{section:"x15.4.4.12",name:"15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.13",name:"15.4.4.13 Array.prototype.unshift ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.14",name:"15.4.4.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.15",name:"15.4.4.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.16",name:"15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.17",name:"15.4.4.17 Array.prototype.some ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.18",name:"15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.19",name:"15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.20",name:"15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.21",name:"15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue ] )"},{section:"x15.4.4.22",name:"15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )"},{section:"x15.4.5",name:"15.4.5 Properties of Array Instances"},{section:"x15.4.5.1",name:"15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )"},{section:"x15.4.5.2",name:"15.4.5.2 length"},{section:"x15.5",name:"15.5 String Objects"},{section:"x15.5.1",name:"15.5.1 The String Constructor Called as a Function"},{section:"x15.5.1.1",name:"15.5.1.1 String ( [ value ] )"},{section:"x15.5.2",name:"15.5.2 The String Constructor"},{section:"x15.5.2.1",name:"15.5.2.1 new String ( [ value ] )"},{section:"x15.5.3",name:"15.5.3 Properties of the String Constructor"},{section:"x15.5.3.1",name:"15.5.3.1 String.prototype"},{section:"x15.5.3.2",name:"15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] )"},{section:"x15.5.4",name:"15.5.4 Properties of the String Prototype Object"},{section:"x15.5.4.1",name:"15.5.4.1 String.prototype.constructor"},{section:"x15.5.4.2",name:"15.5.4.2 String.prototype.toString ( )"},{section:"x15.5.4.3",name:"15.5.4.3 String.prototype.valueOf ( )"},{section:"x15.5.4.4",name:"15.5.4.4 String.prototype.charAt (pos)"},{section:"x15.5.4.5",name:"15.5.4.5 String.prototype.charCodeAt (pos)"},{section:"x15.5.4.6",name:"15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] )"},{section:"x15.5.4.7",name:"15.5.4.7 String.prototype.indexOf (searchString, position)"},{section:"x15.5.4.8",name:"15.5.4.8 String.prototype.lastIndexOf (searchString, position)"},{section:"x15.5.4.9",name:"15.5.4.9 String.prototype.localeCompare (that)"},{section:"x15.5.4.10",name:"15.5.4.10 String.prototype.match (regexp)"},{section:"x15.5.4.11",name:"15.5.4.11 String.prototype.replace (searchValue, replaceValue)"},{section:"x15.5.4.12",name:"15.5.4.12 String.prototype.search (regexp)"},{section:"x15.5.4.13",name:"15.5.4.13 String.prototype.slice (start, end)"},{section:"x15.5.4.14",name:"15.5.4.14 String.prototype.split (separator, limit)"},{section:"x15.5.4.15",name:"15.5.4.15 String.prototype.substring (start, end)"},{section:"x15.5.4.16",name:"15.5.4.16 String.prototype.toLowerCase ( )"},{section:"x15.5.4.17",name:"15.5.4.17 String.prototype.toLocaleLowerCase ( )"},{section:"x15.5.4.18",name:"15.5.4.18 String.prototype.toUpperCase ( )"},{section:"x15.5.4.19",name:"15.5.4.19 String.prototype.toLocaleUpperCase ( )"},{section:"x15.5.4.20",name:"15.5.4.20 String.prototype.trim ( )"},{section:"x15.5.5",name:"15.5.5 Properties of String Instances"},{section:"x15.5.5.1",name:"15.5.5.1 length"},{section:"x15.5.5.2",name:"15.5.5.2 [[GetOwnProperty]] ( P )"},{section:"x15.6",name:"15.6 Boolean Objects"},{section:"x15.6.1",name:"15.6.1 The Boolean Constructor Called as a Function"},{section:"x15.6.1.1",name:"15.6.1.1 Boolean (value)"},{section:"x15.6.2",name:"15.6.2 The Boolean Constructor"},{section:"x15.6.2.1",name:"15.6.2.1 new Boolean (value)"},{section:"x15.6.3",name:"15.6.3 Properties of the Boolean Constructor"},{section:"x15.6.3.1",name:"15.6.3.1 Boolean.prototype"},{section:"x15.6.4",name:"15.6.4 Properties of the Boolean Prototype Object"},{section:"x15.6.4.1",name:"15.6.4.1 Boolean.prototype.constructor"},{section:"x15.6.4.2",name:"15.6.4.2 Boolean.prototype.toString ( )"},{section:"x15.6.4.3",name:"15.6.4.3 Boolean.prototype.valueOf ( )"},{section:"x15.6.5",name:"15.6.5 Properties of Boolean Instances"},{section:"x15.7",name:"15.7 Number Objects"},{section:"x15.7.1",name:"15.7.1 The Number Constructor Called as a Function"},{section:"x15.7.1.1",name:"15.7.1.1 Number ( [ value ] )"},{section:"x15.7.2",name:"15.7.2 The Number Constructor"},{section:"x15.7.2.1",name:"15.7.2.1 new Number ( [ value ] )"},{section:"x15.7.3",name:"15.7.3 Properties of the Number Constructor"},{section:"x15.7.3.1",name:"15.7.3.1 Number.prototype"},{section:"x15.7.3.2",name:"15.7.3.2 Number.MAX_VALUE"},{section:"x15.7.3.3",name:"15.7.3.3 Number.MIN_VALUE"},{section:"x15.7.3.4",name:"15.7.3.4 Number.NaN"},{section:"x15.7.3.5",name:"15.7.3.5 Number.NEGATIVE_INFINITY"},{section:"x15.7.3.6",name:"15.7.3.6 Number.POSITIVE_INFINITY"},{section:"x15.7.4",name:"15.7.4 Properties of the Number Prototype Object"},{section:"x15.7.4.1",name:"15.7.4.1 Number.prototype.constructor"},{section:"x15.7.4.2",name:"15.7.4.2 Number.prototype.toString ( [ radix ] )"},{section:"x15.7.4.3",name:"15.7.4.3 Number.prototype.toLocaleString()"},{section:"x15.7.4.4",name:"15.7.4.4 Number.prototype.valueOf ( )"},{section:"x15.7.4.5",name:"15.7.4.5 Number.prototype.toFixed (fractionDigits)"},{section:"x15.7.4.6",name:"15.7.4.6 Number.prototype.toExponential (fractionDigits)"},{section:"x15.7.4.7",name:"15.7.4.7 Number.prototype.toPrecision (precision)"},{section:"x15.7.5",name:"15.7.5 Properties of Number Instances"},{section:"x15.8",name:"15.8 The Math Object"},{section:"x15.8.1",name:"15.8.1 Value Properties of the Math Object"},{section:"x15.8.1.1",name:"15.8.1.1 E"},{section:"x15.8.1.2",name:"15.8.1.2 LN10"},{section:"x15.8.1.3",name:"15.8.1.3 LN2"},{section:"x15.8.1.4",name:"15.8.1.4 LOG2E"},{section:"x15.8.1.5",name:"15.8.1.5 LOG10E"},{section:"x15.8.1.6",name:"15.8.1.6 PI"},{section:"x15.8.1.7",name:"15.8.1.7 SQRT1_2"},{section:"x15.8.1.8",name:"15.8.1.8 SQRT2"},{section:"x15.8.2",name:"15.8.2 Function Properties of the Math Object"},{section:"x15.8.2.1",name:"15.8.2.1 abs (x)"},{section:"x15.8.2.2",name:"15.8.2.2 acos (x)"},{section:"x15.8.2.3",name:"15.8.2.3 asin (x)"},{section:"x15.8.2.4",name:"15.8.2.4 atan (x)"},{section:"x15.8.2.5",name:"15.8.2.5 atan2 (y, x)"},{section:"x15.8.2.6",name:"15.8.2.6 ceil (x)"},{section:"x15.8.2.7",name:"15.8.2.7 cos (x)"},{section:"x15.8.2.8",name:"15.8.2.8 exp (x)"},{section:"x15.8.2.9",name:"15.8.2.9 floor (x)"},{section:"x15.8.2.10",name:"15.8.2.10 log (x)"},{section:"x15.8.2.11",name:"15.8.2.11 max ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.12",name:"15.8.2.12 min ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.13",name:"15.8.2.13 pow (x, y)"},{section:"x15.8.2.14",name:"15.8.2.14 random ( )"},{section:"x15.8.2.15",name:"15.8.2.15 round (x)"},{section:"x15.8.2.16",name:"15.8.2.16 sin (x)"},{section:"x15.8.2.17",name:"15.8.2.17 sqrt (x)"},{section:"x15.8.2.18",name:"15.8.2.18 tan (x)"},{section:"x15.9",name:"15.9 Date Objects"},{section:"x15.9.1",name:"15.9.1 Overview of Date Objects and Definitions of Abstract Operators"},{section:"x15.9.1.1",name:"15.9.1.1 Time Values and Time Range"},{section:"x15.9.1.2",name:"15.9.1.2 Day Number and Time within Day"},{section:"x15.9.1.3",name:"15.9.1.3 Year Number"},{section:"x15.9.1.4",name:"15.9.1.4 Month Number"},{section:"x15.9.1.5",name:"15.9.1.5 Date Number"},{section:"x15.9.1.6",name:"15.9.1.6 Week Day"},{section:"x15.9.1.7",name:"15.9.1.7 Local Time Zone Adjustment"},{section:"x15.9.1.8",name:"15.9.1.8 Daylight Saving Time Adjustment"},{section:"x15.9.1.9",name:"15.9.1.9 Local Time"},{section:"x15.9.1.10",name:"15.9.1.10 Hours, Minutes, Second, and Milliseconds"},{section:"x15.9.1.11",name:"15.9.1.11 MakeTime (hour, min, sec, ms)"},{section:"x15.9.1.12",name:"15.9.1.12 MakeDay (year, month, date)"},{section:"x15.9.1.13",name:"15.9.1.13 MakeDate (day, time)"},{section:"x15.9.1.14",name:"15.9.1.14 TimeClip (time)"},{section:"x15.9.1.15",name:"15.9.1.15 Date Time String Format"},{section:"x15.9.1.15.1",name:"15.9.1.15.1 Extended years"},{section:"x15.9.2",name:"15.9.2 The Date Constructor Called as a Function"},{section:"x15.9.2.1",name:"15.9.2.1 Date ( [ year [, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] ] ] )"},{section:"x15.9.3",name:"15.9.3 The Date Constructor"},{section:"x15.9.3.1",name:"15.9.3.1 new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )"},{section:"x15.9.3.2",name:"15.9.3.2 new Date (value)"},{section:"x15.9.3.3",name:"15.9.3.3 new Date ( )"},{section:"x15.9.4",name:"15.9.4 Properties of the Date Constructor"},{section:"x15.9.4.1",name:"15.9.4.1 Date.prototype"},{section:"x15.9.4.2",name:"15.9.4.2 Date.parse (string)"},{section:"x15.9.4.3",name:"15.9.4.3 Date.UTC (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ])"},{section:"x15.9.4.4",name:"15.9.4.4 Date.now ( )"},{section:"x15.9.5",name:"15.9.5 Properties of the Date Prototype Object"},{section:"x15.9.5.1",name:"15.9.5.1 Date.prototype.constructor"},{section:"x15.9.5.2",name:"15.9.5.2 Date.prototype.toString ( )"},{section:"x15.9.5.3",name:"15.9.5.3 Date.prototype.toDateString ( )"},{section:"x15.9.5.4",name:"15.9.5.4 Date.prototype.toTimeString ( )"},{section:"x15.9.5.5",name:"15.9.5.5 Date.prototype.toLocaleString ( )"},{section:"x15.9.5.6",name:"15.9.5.6 Date.prototype.toLocaleDateString ( )"},{section:"x15.9.5.7",name:"15.9.5.7 Date.prototype.toLocaleTimeString ( )"},{section:"x15.9.5.8",name:"15.9.5.8 Date.prototype.valueOf ( )"},{section:"x15.9.5.9",name:"15.9.5.9 Date.prototype.getTime ( )"},{section:"x15.9.5.10",name:"15.9.5.10 Date.prototype.getFullYear ( )"},{section:"x15.9.5.11",name:"15.9.5.11 Date.prototype.getUTCFullYear ( )"},{section:"x15.9.5.12",name:"15.9.5.12 Date.prototype.getMonth ( )"},{section:"x15.9.5.13",name:"15.9.5.13 Date.prototype.getUTCMonth ( )"},{section:"x15.9.5.14",name:"15.9.5.14 Date.prototype.getDate ( )"},{section:"x15.9.5.15",name:"15.9.5.15 Date.prototype.getUTCDate ( )"},{section:"x15.9.5.16",name:"15.9.5.16 Date.prototype.getDay ( )"},{section:"x15.9.5.17",name:"15.9.5.17 Date.prototype.getUTCDay ( )"},{section:"x15.9.5.18",name:"15.9.5.18 Date.prototype.getHours ( )"},{section:"x15.9.5.19",name:"15.9.5.19 Date.prototype.getUTCHours ( )"},{section:"x15.9.5.20",name:"15.9.5.20 Date.prototype.getMinutes ( )"},{section:"x15.9.5.21",name:"15.9.5.21 Date.prototype.getUTCMinutes ( )"},{section:"x15.9.5.22",name:"15.9.5.22 Date.prototype.getSeconds ( )"},{section:"x15.9.5.23",name:"15.9.5.23 Date.prototype.getUTCSeconds ( )"},{section:"x15.9.5.24",name:"15.9.5.24 Date.prototype.getMilliseconds ( )"},{section:"x15.9.5.25",name:"15.9.5.25 Date.prototype.getUTCMilliseconds ( )"},{section:"x15.9.5.26",name:"15.9.5.26 Date.prototype.getTimezoneOffset ( )"},{section:"x15.9.5.27",name:"15.9.5.27 Date.prototype.setTime (time)"},{section:"x15.9.5.28",name:"15.9.5.28 Date.prototype.setMilliseconds (ms)"},{section:"x15.9.5.29",name:"15.9.5.29 Date.prototype.setUTCMilliseconds (ms)"},{section:"x15.9.5.30",name:"15.9.5.30 Date.prototype.setSeconds (sec [, ms ] )"},{section:"x15.9.5.31",name:"15.9.5.31 Date.prototype.setUTCSeconds (sec [, ms ] )"},{section:"x15.9.5.32",name:"15.9.5.32 Date.prototype.setMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.33",name:"15.9.5.33 Date.prototype.setUTCMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.34",name:"15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.35",name:"15.9.5.35 Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.36",name:"15.9.5.36 Date.prototype.setDate (date)"},{section:"x15.9.5.37",name:"15.9.5.37 Date.prototype.setUTCDate (date)"},{section:"x15.9.5.38",name:"15.9.5.38 Date.prototype.setMonth (month [, date ] )"},{section:"x15.9.5.39",name:"15.9.5.39 Date.prototype.setUTCMonth (month [, date ] )"},{section:"x15.9.5.40",name:"15.9.5.40 Date.prototype.setFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.41",name:"15.9.5.41 Date.prototype.setUTCFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.42",name:"15.9.5.42 Date.prototype.toUTCString ( )"},{section:"x15.9.5.43",name:"15.9.5.43 Date.prototype.toISOString ( )"},{section:"x15.9.5.44",name:"15.9.5.44 Date.prototype.toJSON ( key )"},{section:"x15.9.6",name:"15.9.6 Properties of Date Instances"},{section:"x15.10",name:"15.10 RegExp (Regular Expression) Objects"},{section:"x15.10.1",name:"15.10.1 Patterns"},{section:"x15.10.2",name:"15.10.2 Pattern Semantics"},{section:"x15.10.2.1",name:"15.10.2.1 Notation"},{section:"x15.10.2.2",name:"15.10.2.2 Pattern"},{section:"x15.10.2.3",name:"15.10.2.3 Disjunction"},{section:"x15.10.2.4",name:"15.10.2.4 Alternative"},{section:"x15.10.2.5",name:"15.10.2.5 Term"},{section:"x15.10.2.6",name:"15.10.2.6 Assertion"},{section:"x15.10.2.7",name:"15.10.2.7 Quantifier"},{section:"x15.10.2.8",name:"15.10.2.8 Atom"},{section:"x15.10.2.9",name:"15.10.2.9 AtomEscape"},{section:"x15.10.2.10",name:"15.10.2.10 CharacterEscape"},{section:"x15.10.2.11",name:"15.10.2.11 DecimalEscape"},{section:"x15.10.2.12",name:"15.10.2.12 CharacterClassEscape"},{section:"x15.10.2.13",name:"15.10.2.13 CharacterClass"},{section:"x15.10.2.14",name:"15.10.2.14 ClassRanges"},{section:"x15.10.2.15",name:"15.10.2.15 NonemptyClassRanges"},{section:"x15.10.2.16",name:"15.10.2.16 NonemptyClassRangesNoDash"},{section:"x15.10.2.17",name:"15.10.2.17 ClassAtom"},{section:"x15.10.2.18",name:"15.10.2.18 ClassAtomNoDash"},{section:"x15.10.2.19",name:"15.10.2.19 ClassEscape"},{section:"x15.10.3",name:"15.10.3 The RegExp Constructor Called as a Function"},{section:"x15.10.3.1",name:"15.10.3.1 RegExp(pattern, flags)"},{section:"x15.10.4",name:"15.10.4 The RegExp Constructor"},{section:"x15.10.4.1",name:"15.10.4.1 new RegExp(pattern, flags)"},{section:"x15.10.5",name:"15.10.5 Properties of the RegExp Constructor"},{section:"x15.10.5.1",name:"15.10.5.1 RegExp.prototype"},{section:"x15.10.6",name:"15.10.6 Properties of the RegExp Prototype Object"},{section:"x15.10.6.1",name:"15.10.6.1 RegExp.prototype.constructor"},{section:"x15.10.6.2",name:"15.10.6.2 RegExp.prototype.exec(string)"},{section:"x15.10.6.3",name:"15.10.6.3 RegExp.prototype.test(string)"},{section:"x15.10.6.4",name:"15.10.6.4 RegExp.prototype.toString()"},{section:"x15.10.7",name:"15.10.7 Properties of RegExp Instances"},{section:"x15.10.7.1",name:"15.10.7.1 source"},{section:"x15.10.7.2",name:"15.10.7.2 global"},{section:"x15.10.7.3",name:"15.10.7.3 ignoreCase"},{section:"x15.10.7.4",name:"15.10.7.4 multiline"},{section:"x15.10.7.5",name:"15.10.7.5 lastIndex"},{section:"x15.11",name:"15.11 Error Objects"},{section:"x15.11.1",name:"15.11.1 The Error Constructor Called as a Function"},{section:"x15.11.1.1",name:"15.11.1.1 Error (message)"},{section:"x15.11.2",name:"15.11.2 The Error Constructor"},{section:"x15.11.2.1",name:"15.11.2.1 new Error (message)"},{section:"x15.11.3",name:"15.11.3 Properties of the Error Constructor"},{section:"x15.11.3.1",name:"15.11.3.1 Error.prototype"},{section:"x15.11.4",name:"15.11.4 Properties of the Error Prototype Object"},{section:"x15.11.4.1",name:"15.11.4.1 Error.prototype.constructor"},{section:"x15.11.4.2",name:"15.11.4.2 Error.prototype.name"},{section:"x15.11.4.3",name:"15.11.4.3 Error.prototype.message"},{section:"x15.11.4.4",name:"15.11.4.4 Error.prototype.toString ( )"},{section:"x15.11.5",name:"15.11.5 Properties of Error Instances"},{section:"x15.11.6",name:"15.11.6 Native Error Types Used in This Standard"},{section:"x15.11.6.1",name:"15.11.6.1 EvalError"},{section:"x15.11.6.2",name:"15.11.6.2 RangeError"},{section:"x15.11.6.3",name:"15.11.6.3 ReferenceError"},{section:"x15.11.6.4",name:"15.11.6.4 SyntaxError"},{section:"x15.11.6.5",name:"15.11.6.5 TypeError"},{section:"x15.11.6.6",name:"15.11.6.6 URIError"},{section:"x15.11.7",name:"15.11.7 NativeError Object Structure"},{section:"x15.11.7.1",name:"15.11.7.1 NativeError Constructors Called as Functions"},{section:"x15.11.7.2",name:"15.11.7.2 NativeError (message)"},{section:"x15.11.7.3",name:"15.11.7.3 The NativeError Constructors"},{section:"x15.11.7.4",name:"15.11.7.4 New NativeError (message)"},{section:"x15.11.7.5",name:"15.11.7.5 Properties of the NativeError Constructors"},{section:"x15.11.7.6",name:"15.11.7.6 NativeError.prototype"},{section:"x15.11.7.7",name:"15.11.7.7 Properties of the NativeError Prototype Objects"},{section:"x15.11.7.8",name:"15.11.7.8 NativeError.prototype.constructor"},{section:"x15.11.7.9",name:"15.11.7.9 NativeError.prototype.name"},{section:"x15.11.7.10",name:"15.11.7.10 NativeError.prototype.message"},{section:"x15.11.7.11",name:"15.11.7.11 Properties of NativeError Instances"},{section:"x15.12",name:"15.12 The JSON Object"},{section:"x15.12.1",name:"15.12.1 The JSON Grammar "},{section:"x15.12.1.1",name:"15.12.1.1 The JSON Lexical Grammar"},{section:"x15.12.1.2",name:"15.12.1.2 The JSON Syntactic Grammar"},{section:"x15.12.2",name:"15.12.2 parse ( text [ , reviver ] )"},{section:"x15.12.3",name:"15.12.3 stringify ( value [ , replacer [ , space ] ] )"},{section:"x16",name:"16 Errors"},{section:"A",name:"Annex A (informative) Grammar Summary"},{section:"A.1",name:"A.1 Lexical Grammar"},{section:"A.2",name:"A.2 Number Conversions"},{section:"A.3",name:"A.3 Expressions"},{section:"A.4",name:"A.4 Statements"},{section:"A.5",name:"A.5 Functions and Programs"},{section:"A.6",name:"A.6 Universal Resource Identifier Character Classes"},{section:"A.7",name:"A.7 Regular Expressions"},{section:"A.8",name:"A.8 JSON"},{section:"A.8.1",name:"A.8.1 JSON Lexical Grammar"},{section:"A.8.2",name:"A.8.2 JSON Syntactic Grammar"},{section:"B",name:"Annex B (informative) Compatibility"},{section:"B.1",name:"B.1 Additional Syntax"},{section:"B.1.1",name:"B.1.1 Numeric Literals"},{section:"B.1.2",name:"B.1.2 String Literals"},{section:"B.2",name:"B.2 Additional Properties"},{section:"B.2.1",name:"B.2.1 escape (string)"},{section:"B.2.2",name:"B.2.2 unescape (string)"},{section:"B.2.3",name:"B.2.3 String.prototype.substr (start, length)"},{section:"B.2.4",name:"B.2.4 Date.prototype.getYear ( )"},{section:"B.2.5",name:"B.2.5 Date.prototype.setYear (year)"},{section:"B.2.6",name:"B.2.6 Date.prototype.toGMTString ( )"},{section:"C",name:"Annex C (informative) The Strict Mode of ECMAScript"},{section:"D",name:"Annex D (informative) Corrections and Clarifications in the 5th Edition with Possible 3rd Edition Compatibility Impact"},{section:"E",name:"Annex E (informative) Additions and Changes in the 5th Edition that Introduce Incompatibilities with the 3rd Edition"},{section:"bibliography",name:"Bibliography"}],bot.addCommand({name:"spec",fun:e,permissions:{del:"NONE"},description:"Find a section in the ES5 spec"}) }(),function(){var e,t=/(which |what |give me a )?stargate|sg1( episode)?/i;e={SG1:{"Season 1":["Children of the Gods","The Enemy Within","Emancipation","The Broca Divide","The First Commandment","Brief Candle","Cold Lazarus","Thor's Hammer","The Torment of Tantalus","Bloodlines","Fire and Water","The Nox","Hathor","Singularity","Cor-ai","Enigma","Tin Man","Solitudes","There But for the Grace of God ","Politics ","Within the Serpent's Grasp "],"Season 2":["The Serpent's Lair ","In the Line of Duty","Prisoners","The Gamekeeper","Need","Thor's Chariot","Message in a Bottle","Family","Secrets","Bane","The Tok'ra","The Tok'ra (Part 2)","Spirits","Touchstone","A Matter of Time","The Fifth Race","Serpent's Song","Holiday","One False Step","Show and Tell","1969","Out of Mind "],"Season 3":["Into the Fire ","Seth","Fair Game","Legacy","Learning Curve","Point of View","Deadman Switch","Demons","Rules of Engagement","Forever in a Day","Past and Present","Jolinar's Memories ","The Devil You Know ","Foothold","Pretense","Urgo","A Hundred Days","Shades of Grey","New Ground","Maternal Instinct","Crystal Skull","Nemesis "],"Season 4":["Small Victories ","The Other Side","Upgrades","Crossroads","Divide and Conquer","Window of Opportunity","Watergate","The First Ones","Scorched Earth","Beneath the Surface","Point of No Return","Tangent","The Curse","The Serpent's Venom","Chain Reaction","2010","Absolute Power","The Light","Prodigy","Entity","Double Jeopardy ","Exodus "],"Season 5":["Enemies ","Threshold ","Ascension","The Fifth Man","Red Sky","Rite of Passage","Beast of Burden","The Tomb","Between Two Fires","2001","Desperate Measures","Wormhole X-Treme!","Proving Ground","48 Hours","Summit ","Last Stand ","Fail Safe","The Warrior","Menace","The Sentinel","Meridian","Revelations"],"Season 6":["Redemption","Redemption (Part 2)","Descent","Frozen","Nightwalkers","Abyss","Shadow Play","The Other Guys","Allegiance","Cure","Prometheus ","Unnatural Selection ","Sight Unseen","Smoke & Mirrors","Paradise Lost","Metamorphosis","Disclosure","Forsaken","The Changeling","Memento","Prophecy","Full Circle"],"Season 7":["Fallen ","Homecoming ","Fragile Balance","Orpheus","Revisions","Lifeboat","Enemy Mine","Space Race","Avenger 2.0","Birthright","Evolution","Evolution (Part 2)","Grace","Fallout","Chimera","Death Knell","Heroes","Heroes (Part 2)","Resurrection","Inauguration","Lost City","Lost City (Part 2)"],"Season 8":["New Order","New Order (Part 2)","Lockdown","Zero Hour","Icon","Avatar","Affinity","Covenant","Sacrifices","Endgame","Gemini","Prometheus Unbound","It's Good to Be King","Full Alert","Citizen Joe","Reckoning","Reckoning (Part 2)","Threads","Moebius","Moebius (Part 2)"],"Season 9":["Avalon","Avalon (Part 2)","Origin ","The Ties That Bind","The Powers That Be","Beachhead","Ex Deus Machina","Babylon","Prototype","The Fourth Horseman","The Fourth Horseman (Part 2)","Collateral Damage","Ripple Effect","Stronghold","Ethon","Off the Grid","The Scourge","Arthur's Mantle","Crusade","Camelot "],"Season 10":["Flesh and Blood ","Morpheus","The Pegasus Project","Insiders","Uninvited","200","Counterstrike","Memento Mori","Company of Thieves","The Quest","The Quest (Part 2)","Line in the Sand","The Road Not Taken","The Shroud","Bounty","Bad Guys","Talion","Family Ties","Dominion","Unending"]}};var n=function(t){if(-1===t.indexOf("episode")&&Math.random()<.05)return"Stargate (movie)";var n=function(e){var t=Math.rand(e.length-1);return{value:e[t],index:t}},o=n(Object.keys(e.SG1)),r=n(e.SG1[o.value]),i={season:o.value,index:r.index+1,episode:r.value};return"{season} episode #{index} - {episode}".supplant(i)};bot.listen(t,n)}(),function(){"use strict";function e(e,n){function o(n){if(n.error_message)return void r(n.error_message);var o,i=n.items[0];o=i?t(i,e):"User "+a+" not found",r(o)}function r(t){n?n(t):e.reply(t)}var i=e.parse(),a=i[0];return a?/^\d+$/.test(a)||(a=e.findUserId(i.length>1?a:i.join(" "))):a=e.get("user_id"),0>a?"User Elusio proved elusive.":Math.random()<=.1?void r("That dude sucks"):void IO.jsonp({url:"https://api.stackexchange.com/2.2/users/"+a,data:{site:bot.adapter.site,filter:"!P)usXx8OGi3Eq5LdDJke7ybvCSm_vuVGrSDZs3)UmEI"},fun:o})}function t(e,t){return e=n(e),e.user_id===t.get("user_id")?(e.display_name="You",e.indicative="have"):(e.display_name=IO.decodehtmlEntities(e.display_name),e.indicative="has"),r.supplant(e)}function n(e){return e=Object.merge({question_count:0,answer_count:0,reputation_change_day:0},e.badge_counts,e),e=Object.merge(e.badge_counts,e),e.avg_rep_post=(e.reputation/(e.question_count+e.answer_count)).maxDecimal(2),1/0===e.avg_rep_post&&(e.avg_rep_post="T͎͍̘͙̖̤̉̌̇̅ͯ͋͢͜͝H̖͙̗̗̺͚̱͕̒́͟E̫̺̯͖͎̗̒͑̅̈ ̈ͮ̽ͯ̆̋́͏͙͓͓͇̹<̩̟̳̫̪̇ͩ̑̆͗̽̇͆́ͅC̬͎ͪͩ̓̑͊ͮͪ̄̚̕Ě̯̰̤̗̜̗͓͛͝N̶̴̞͇̟̲̪̅̓ͯͅT͍̯̰͓̬͚̅͆̄E̠͇͇̬̬͕͖ͨ̔̓͞R͚̠̻̲̗̹̀>̇̏ͣ҉̳̖̟̫͕ ̧̛͈͙͇͂̓̚͡C͈̞̻̩̯̠̻ͥ̆͐̄ͦ́̀͟A̛̪̫͙̺̱̥̞̙ͦͧ̽͛̈́ͯ̅̍N̦̭͕̹̤͓͙̲̑͋̾͊ͣŅ̜̝͌͟O̡̝͍͚̲̝ͣ̔́͝Ť͈͢ ̪̘̳͔̂̒̋ͭ͆̽͠H̢͈̤͚̬̪̭͗ͧͬ̈́̈̀͌͒͡Ơ̮͍͇̝̰͍͚͖̿ͮ̀̍́L͐̆ͨ̏̎͡҉̧̱̯̤̹͓̗̻̭ͅḐ̲̰͙͑̂̒̐́̊"),e.ratio=o(e.question_count,e.answer_count),bot.log(e,"/stat normalized"),e}function o(e,t){if(!e&&t)return"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ";if(!t&&e)return"TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡";if(!t&&!e)return"http://i.imgur.com/F79hP.png";Math.gcd(e,t);return Math.ratio(e,t)}var r="{display_name} ({link}) {indicative} {reputation} reputation, earned {reputation_change_day} rep today, asked {question_count} questions, gave {answer_count} answers, for a q:a ratio of {ratio}.\navg. rep/post: {avg_rep_post}. Badges: {gold}g {silver}s {bronze}b ",i={name:"stat",fun:e,permissions:{del:"NONE"},description:"Gives useless stats on a user. `/stat usrid|usrname [extended]`",async:!0};bot.addCommand(i);var a=Object.merge(i,{name:"stats"});bot.addCommand(a)}(),function(){function e(e){var r=RegExp(e.matches[2],e.matches[4]),i=e.matches[3];if(!e.matches[2])return"Empty regex is empty";var a;a=e.matches[5]?Array.from(document.querySelectorAll("#message-"+e.matches[5]+" .content")):Array.from(document.getElementsByClassName("content")).reverse(),t(r,a,e.get("message_id"),function(t,a){function s(t){var n=t.replace(r,i)+" "+e.link("(source)",c);e.reply(n)}if(t)return void e.reply(t);if(!a)return void e.reply("No matching message (are you sure we're in the right room?)");bot.log(a,"substitution found message");var c=n(a);a.getElementsByClassName("partial").length?o(a,s):s(a.textContent)})}function t(e,t,n,o){bot.log(e,t,n,"substitution getMatchingMessage args");var r={maxId:n,pattern:e,messages:t.map(function(e){return{id:Number(e.parentElement.id.match(/\d+/)[0]),text:e.textContent}})},i=function(){var e=arguments[1],t=null;e.messages.some(function(n,o){return n.id-1?void this.removeMultiple(e.split(" "),n):void("~"===e[0]?this.byLookback(e.slice(1),n):"*"===e[0]||"x"===e[0]?this.byPrevious(e.slice(1),n):/^:?\d+$/.test(e)?this.remove(e.replace(/^:/,""),n):e.content?n("I'm not sure how to handle that, see `/help undo`"):this.ids.length?this.remove(this.ids[this.ids.length-1],n):n("I haven't said a thing!"))},removeMultiple:function(e,t){e.forEach(function(e){this.remove(e,t)},this)},byLookback:function(e,t){var n=Number(e.replace("~",""));return bot.log(e,n,this.ids.length-n,"/undo byLookback"),!n||n>this.ids.length?void t("I can't quite see that far back without my glasses"):void this.remove(this.ids[this.ids.length-n],t)},byPrevious:function(e,t){var n=Number(e);return n?this.removeMultiple(this.ids.slice(-e),t):void t("Yeah, no")},remove:function(t,n){function o(o,r){if(409===r.status)return bot.log(r,"/undo remove finish 409"),void e.retry(t,n,o);var i;'"ok"'!==o&&(i=/it is too late/i.test(o)?"TimeError: Could not reach 88mph":/only delete your own/i.test(o)?"I can only delete my own messages":"I have no idea what happened: "+o,n(i))}console.log(t,"/undo remove");var r=this.ids.indexOf(t);r>-1&&this.ids.splice(r,1),IO.xhr({url:"/messages/"+t+"/delete",data:fkey(),method:"POST",complete:o})},retry:function(e,t,n){var o=/(\d+) seconds\s*$/i.exec(n),r=4;o&&o[1]&&(r=Number(o[1])),setTimeout(this.remove.bind(this,e,t),1e3*r)},update_id:function(e){this.ids.push(JSON.parse(e.responseText).id)}};IO.register("sendoutput",e.update_id,e),bot.addCommand({name:"undo",fun:e.command,thisArg:e,permissions:{del:"NONE",use:"OWNER"},description:"Undo (delete) specified or last message. `/undo [msgid0, msgid1, ...]` (omit for last message); `/undo xN` for last N; `/undo ~N` for the Nth message from the end"})}(),function(){function e(e,n){var o=bot.users[e.user_id],r=e.message_id;bot.log("[formatting] Lecturing user "+e.user_name),bot.adapter.out.add(bot.adapter.reply(e.user_name)+" "+t(n)),o&&o.reputation<2e3&&(bot.log("[formatting] Binning offending message"),bot.adapter.moveMessage(r,e.room_id,23262))}function t(e){var t=e.split("\n").length,n="Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the {0}.".supplant(bot.adapter.link("faq","/faq"));return t>=10&&(n+=" For posting large code blocks, use a paste site like https://gist.github.com, http://hastebin.com or http://pastie.org"),n}function n(e){var t=e.split("\n");if(t.length<4)return!1;var n=/^\}|^<\//;return t.some(/ /.test.bind(n))}if("stackoverflow"!==bot.adapter.site||17!==bot.adapter.roomid)return void bot.log("Not activating unformatted code checking; not in right room/site");var o=new Map;IO.register("rawinput",function(t){function r(){o.has(i)&&(bot.log("[formatting] Message {0} was fixed".supplant(i)),clearTimeout(o.get(i)),o["delete"](i))}var i=t.message_id;if((1===t.event_type||2===t.event_type)&&17===t.room_id&&!bot.isOwner(t.user_id)){if(!t.content.startsWith("
"))return void r();var a=bot.adapter["in"].breakMultilineMessage(t.content).map(function(e){return e.replace(/^ /,"")}).join("\n");if(a=IO.decodehtmlEntities(a),a.startsWith("
"))return void r();var s=n(a);if(!s)return void r();bot.log("[formatting] Message {0} is a naughty one".supplant(i));var c=setTimeout(e,1e4,t,a);o.set(i,c)}})}(),function(){"use strict";var e="unonebox-state",t=9e4,n={enablers:Object.TruthMap(["yes","on","true","start","1","enable"]),disablers:Object.TruthMap(["no","off","false","stop","0","disable"]),command:function(t){var n,o=t.toLowerCase(),r=!1;o?this.enablers[o]?(bot.log("/unonebox enabling"),this.enable(),n="un-onebox enabled",r=!0):this.disablers[o]?(bot.log("/unonebox disabling"),this.disable(),n="un-onebox disabled",r=!0):(bot.log("/unonebox invalid input"),n="That didn't make much sense. Please use `on` or `off` to toggle the command"):(bot.log("/unonebox getting state"),n="Functionality is "+bot.memory.get(e,"disabled")),r&&bot.memory.save(e),t.reply(n)},enable:function(){IO.register("input",this.unbox),bot.memory.set(e,"enabled")},disable:function(){IO.unregister("input",this.unbox),bot.memory.set(e,"disabled")},unbox:function(e){if(e.user_id===bot.adapter.user_id){var o=document.createElement("div");o.innerHTML=e.content;var r=o.querySelector(".onebox:not(.ob-youtube):not(.ob-message):not(.ob-wikipedia) a");r&&!r.parentNode.parentNode.classList.contains("quote")&&(bot.log(e,"/unonebox found matching message"),setTimeout(function(){n.actuallyUnbox(e.message_id,r.href)},t))}},actuallyUnbox:function(e,t){IO.xhr({url:"/messages/"+e,data:fkey({text:t+" ... "}),method:"POST",complete:function(e,t){bot.log(t,"/unonebox done unboxing")}})}};"enabled"===bot.memory.get(e,"disabled")&&(bot.log("enabling unonebox"),n.enable()),bot.addCommand({name:"unonebox",fun:n.command,thisArg:n,permissions:{del:"NONE"},description:"Get/toggle the unonebox listener. `/unonebox [on|off]x`"})}(),function(){function e(e,n){function o(n){var o;o="no_results"===n.result_type?"No definition found for "+s:c>n.list.length?"Nothing in that index. The last one is:\n"+i(n.list.pop()):i(n.list[c]),o.length>500&&(o=o.slice(0,450)+"(snip)"),t[e]=o,r(o)}function r(t){n&&n.call?n(t):e.reply(t)}function i(t){var n=t.definition.replace(/\[([^\]]+)\]/g,a);return e.link(t.word,t.permalink)+" "+n}function a(t,n){var o="http://urbandictionary.com/define.php?term="+encodeURIComponent(n);return e.link(t,o)}if(t[e])return r(t[e]);var s,c,u=e.parse();return u.length?(isNaN(u[1])?(bot.log("/urban input isNaN"),s=e.toString(),c=0):(bot.log("/urban input isn't NaN"),s=u[0],c=Number(u[1])),bot.log(s,c,"/urban input"),void IO.jsonp({url:"http://api.urbandictionary.com/v0/define",data:{term:s},jsonpName:"callback",fun:o})):"Y U NO PROVIDE ARGUMENTS!?"}var t={};bot.addCommand({name:"urban",fun:e,permissions:{del:"NONE",use:"ALL"},description:"Fetches UrbanDictionary definition. `/urban query [resultIndex=0]`",async:!0})}(),bot.addCommand({name:"user",fun:function(){return"Command deprecated. If you want it to stay, ping Zirak."},permissions:{del:"NONE",use:"ALL"},description:"Fetches user-link for specified user. `/user usr_id|usr_name`"}),IO.register("input",function(e){1386886===e.user_id&&Math.random()<.005&&bot.adapter.out.add(bot.adapter.reply(e.user_name)+" The Game")}),function(){var e,t,n,o=/^\s*(choose|should)?.*\sor\s[^$]/i,r=new RegExp("\\b("+["am","are","can","could","did","do","does","is","may","might","shall","should","will","would"].map(RegExp.escape).join("|")+")\\b","i"),i={he:"He",i:"You",it:"It",she:"She",they:"They",we:"You",you:"I"};t=["SSdtIG5vdCBzdXJl","RVJST1IgQ0FMQ1VMQVRJTkcgUkVTVUxU","SSBrbm93IGp1c3Qgb25lIHRoaW5nLCBhbmQgdGhhdCBpcyB0aGF0IEknbSBhIGx1bWJlcmphY2s="].map(atob),n=["VGhhdCdzIG5vdCByZWFsbHkgYSBjaG9pY2UsIG5vdyBpcyBpdD8=","U291bmRzIGxpa2UgeW91IGhhdmUgYWxyZWFkeSBkZWNpZGVk","Q2hlYXRlciBjaGVhdGVyIHlvdXIgaG91c2UgaXMgYSBoZWF0ZXI="].map(atob),e=["QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWJzb2x1dGVseSBub3Q=","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIG5v","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QWxsIHNpZ25zIHBvaW50IHRvIHllcw==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnV0IG9mIGNvdXJzZQ==","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","QnkgYWxsIG1lYW5z","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5IG5vdA==","Q2VydGFpbmx5","Q2VydGFpbmx5","Q2VydGFpbmx5","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RGVmaW5pdGVseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RG91YnRmdWxseQ==","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","RnJhbmtseSBteSBkZWFyLCBJIGRvbid0IGdpdmUgYSBkZWFu","SSBjYW4gbmVpdGhlciBjb25maXJtIG5vciBkZW55","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSBleHBlY3Qgc28=","SSdtIG5vdCBzbyBzdXJlIGFueW1vcmUuIEl0IGNhbiBnbyBlaXRoZXIgd2F5","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW1wb3NzaWJsZQ==","SW5kZWVk","SW5kZWVk","SW5kZWVk","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","SW5kdWJpdGFibHk=","Tm8gd2F5","Tm8gd2F5","Tm8gd2F5","Tm8=","Tm8=","Tm8=","Tm8=","Tm9wZQ==","Tm9wZQ==","Tm9wZQ==","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGEgY2hhbmNl","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","Tm90IGF0IGFsbA==","TnVoLXVo","TnVoLXVo","TnVoLXVo","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIG5vdA==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","T2YgY291cnNlIQ==","UHJvYmFibHk=","UHJvYmFibHk=","UHJvYmFibHk=","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzIQ==","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5","WWVzLCBhYnNvbHV0ZWx5"].map(atob),bot.listen(o,function(e){function o(){var t;do t=s.random();while(t===l);e.reply("Wait, I changed my mind! "+r(t))}function r(e){return e.replace(/(should(?:n'?t)?) (\S+)/,a)}function a(e,t,n){var o,r=n.toLowerCase();return o=i.hasOwnProperty(r)?i[r]:n,o+" "+t}for(var s=e.replace(/^\s*choose\s/i,"").replace(/\?$/,"").split(/\s*\bor\b\s*/i).filter(Boolean),c=s.length,u=1,m=!0;c>u;u++)if(s[u]!==s[u-1]){m=!1;break}if(m)return n.random();if(Math.random()<.01)return 2===c?"Both!":"All of them!";if(Math.random()<.01)return 2===c?"Neither":"None of them!";if(Math.random()<.01)return t.random();var l=s.random();return Math.random()<.01&&(bot.log("weasel decision mind change jedi nun-chuck"),setTimeout(o,1e4)),r(l)}),bot.listen(r,function(){return e.random()})}(),function(){"use strict";function e(e){var t=o.exec(e);if(t)n.latlon(t[1],t[2],e.reply.bind(e));else{if(!e.content)return"See `/help weather` for usage info";n.city(e.content,e.reply.bind(e))}}var t=Object.TruthMap(["US","United States of America","United States","BZ","Belize","BS","Bahamas","KY","Cayam Islands"]),n={latlon:function(e,t,n){var o=Number(e),r=Number(t),i=[];return(-180>o||o>180)&&i.push("Latitude must be between -180 and 180"),(-180>r||r>180)&&i.push("Longitude must be between -180 and 180"),i.length?void n(i.join("; ")):void IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{lat:e,lon:t,cnt:1,type:"json"},fun:this.finishCb(n),error:this.errorCb(n)})},city:function(e,t){IO.jsonp({url:"http://api.openweathermap.org/data/2.5/weather",jsonpName:"callback",data:{q:e,type:"json"},fun:this.finishCb(t),error:this.errorCb(t)})},finishCb:function(e){var t=this;return function(n){e(t.format(n))}},errorCb:function(e){return e},format:function(e){var t=e.main;return t?this.formatter(e):(console.error(e),"Sorry, I couldn't get the data: "+e.message)},formatter:function(e){var n,o=e.main;o.celsius=(o.temp-273.15).maxDecimal(4),n=bot.adapter.link(e.name,"http://openweathermap.org/city/"+e.id)+": ",t[e.sys.country]?(o.fahrenheit=(9*o.temp/5-459.67).maxDecimal(4),n+="{fahrenheit}F ({celsius}C, {temp}K)".supplant(o)):n+="{celsius}C ({temp}K)".supplant(o);var r=(e.weather||[]).map(function(e){return e.description}).join(", ");return r&&(n+=", "+r),n}},o=/\((-?\d+\.?\d*),\s*(-?\d+\.?\d*)\)/;bot.addCommand({name:"weather",fun:e,permissions:{del:"NONE"},async:!0,description:"Gets current weather: `/weather (lan, lon)` or `/weather city`"})}(),function(){"use strict";function e(e,t){bot.adapter.out.add(bot.adapter.reply(e)+" "+o,t)}var t=bot.memory.get("users"),n=17,o="Welcome to the JavaScript chat! Please review the "+bot.adapter.link("room pseudo-rules","http://rlemon.github.com/so-chat-javascript-rules/")+". Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.";IO.register("input",function(o){function r(t){var o,r=t.querySelector("#room-"+n+" .room-message-count");o=r?Number(/^\d+/.exec(r.title))<2:!0,o&&e(c.name,u),i()}function i(e){e?delete t[s]:t[s]=!0,bot.memory.save("users")}function a(e){return bot.isOwner(e.id)||e.reputation>1e3||e.reputation<20}var s=o.user_id,c=bot.users[o.user_id],u=o.room_id,m=c&&a(c);return Number(u)!==n||m||t[o.user_id]?void(m&&i(!0)):void IO.xhr({method:"GET",url:"/users/"+s,document:!0,complete:r})}),bot.addCommand({name:"welcome",fun:function(t){return t.length?void e(t,t.get("room_id")):o},permission:{del:"NONE"},description:"Welcomes a user. `/welcome user`"})}(),function(){"use strict";function e(e,t){function n(n){var o=n[3][0],r=!0;o||(r=!1,o=["No result found","The Wikipedia contains no knowledge of such a thing","The Gods of Wikipedia did not bless us"].random()),t&&t.call?t(o):r?e.directreply(o):e.reply(o)}IO.jsonp({url:"http://en.wikipedia.org/w/api.php",jsonpName:"callback",data:{action:"opensearch",search:e.toString(),limit:1,format:"json"},fun:n})}bot.addCommand({name:"wiki",fun:e,permissions:{del:"NONE"},description:"Search Wikipedia. `/wiki term`",async:!0})}(),function(){function e(e,t){function n(e){var t=e.num;i?"new"===i&&r(a+t):r(a+Math.rand(1,t))}function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var t=e.responseData.results;if(!t.length)return void r("Seems like you hallucinated this comic");var n=t[0],o=n.url,i=/xkcd.com\/(\d+)/.exec(o);i||(o="Search didn't yield a comic; got "+n.unescapedUrl),r(o)}function r(n){bot.log(n,"/xkcd finish"),n=n.replace(/^https:/,"http:"),t&&t.call?t(n):e.directreply(n)}var i=(e.parse()[0]||"").toLowerCase(),a="http://xkcd.com/";return/^\d+$/.test(i)?(bot.log("/xkcd specific",i),void r(a+i)):i&&"new"!==i?(bot.log("/xkcd search",e.toString()),void IO.jsonp.google(e.toString()+" site:xkcd.com -forums.xkcd -m.xkcd -fora.xkcd",o)):(bot.log("/xkcd random/latest",i),void IO.jsonp({url:"http://dynamic.xkcd.com/api-0/jsonp/comic",jsonpName:"callback",fun:n}))}bot.addCommand({name:"xkcd",fun:e,permissions:{del:"NONE"},description:"Returns an XKCD. Call with no args for random, `new` for latest, or a number for a specific one.",async:!0})}(),function(){function e(e,n){function o(e){if(200!==e.responseStatus)return void r("Something went on fire; status "+e.responseStatus);var n=e.responseData.results[0];bot.log(n,"/youtube result"),r(n?decodeURIComponent(n.url):t.random())}function r(t){n&&n.call?n(t):e.directreply(t)}IO.jsonp.google(e.toString()+" site:youtube.com/watch",o)}var t=["Video not found (rule 35?)","I could not find such a video","The Lords of YouTube did not find your query favorable"];bot.addCommand({name:"youtube",fun:e,permissions:{del:"NONE"},description:"Search Youtube. `/youtube query`",async:!0})}(),function(){var e=function(e){var t,n,o,r=function(e){return Math.floor(Math.random()*e)},i=e.split(""),a=[0,1,2].random(),s=["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈́","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],c=["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],u=["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͏","͜","͝","͞","͟","͠","͢","̸","̷","͡","҉"],m="",l=0,d="A̪̗̐̿̄̔̉̏̾L̹͓̲̈́ͮL̜̼͓͉̞̘̩̇̊",p=i.length;1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2);var h;h="T̷̂͒̃̽H̸͒̿̒̚̕͜E͋ͥ̋̈̉̏̏̔̔͞ ̏ͥ̊͠P̷̑̌̀O̵̔̑̇̐͌̓̀̚Ǹ͌̍̾̈҉Y͛̈́̉҉͘";for(var l=0;p>l;l++){m+=i[l],d++,a||(t=r(8),n=r(8),o=r(6)),1==a&&(t=r(16)/2+1,n=r(16)/2+1,o=r(6)/2),2==a&&(t=r(64)/4+3,n=r(64)/4+3,o=r(16)/4+1);for(var f=0;t>f;f++)m+=s.random();for(var f=0;o>f;f++)m+=u.random();for(var f=0;n>f;f++)m+=c.random()}return m||/<([a-z]+) *[^\/]*?>/};bot.addCommand({name:"zalgo",fun:e,permissions:{del:"NONE"},description:"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ http://stackoverflow.com/a/1732454/1216976"})}();
\ No newline at end of file
diff --git a/source/adapter.js b/source/adapter.js
index 12a0628..43558ef 100644
--- a/source/adapter.js
+++ b/source/adapter.js
@@ -290,7 +290,7 @@ var polling = bot.adapter.in = {
 	openSocket : function ( url, discard ) {
 		var socket;
 		// socket-saver extension specific code:
-		if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' ) {
+		if ( typeof window.__stackexchangeChatSavedSocket !== 'undefined' && !discard ) {
 			var potentialSocket = window.__stackexchangeChatSavedSocket;
 			console.assert( potentialSocket.constructor === window.WebSocket );
 			console.assert( potentialSocket.url.startsWith( 'wss://chat.sockets.stackexchange.com' ) );

From 1916eee0751709ca31c0dad76a2d642058aed57c Mon Sep 17 00:00:00 2001
From: awalGarg 
Date: Tue, 22 Sep 2015 14:43:51 +0530
Subject: [PATCH 3/3] please change

---
 loader.user.js       | 19 ++++++++++++++++---
 socket-saver.user.js | 27 ---------------------------
 2 files changed, 16 insertions(+), 30 deletions(-)
 delete mode 100644 socket-saver.user.js

diff --git a/loader.user.js b/loader.user.js
index 6437984..5a43fd0 100644
--- a/loader.user.js
+++ b/loader.user.js
@@ -5,11 +5,24 @@
 // @version 0.1
 // @description Loads the bot when you visit a room
 // @include /http://chat\.stack(overflow|exchange)\.com/rooms/\d+/
+// @run-at       document-start
 // ==/UserScript==
 
 var s = document.createElement( 'script' );
-s.src = 'http://jscripts.local/chatbot-master.js';
+s.src = 'https://raw.github.com/Zirak/SO-ChatBot/master/master.js';
 
-window.addEventListener('stackexchange-socket-saved', function () {
+if (document.body) {
+	console.warn('Socket Saver: Not properly running at document-start, setup shit properly FFS!');
     document.head.appendChild( s );
-});
+} else {
+    // we are running at document-start properly. yipee!!
+    Object.defineProperty(WebSocket.prototype, 'onopen', {
+        set: function (val) {
+            if (this.url.startsWith('wss://chat.sockets.stackexchange.com')) {
+                console.info('Socket Saver: socket saved properly, use it with window.__stackexchange_chat_saved_socket');
+                window.__stackexchangeChatSavedSocket = this;
+    			document.head.appendChild( s );
+            }
+        }
+    });
+}
diff --git a/socket-saver.user.js b/socket-saver.user.js
deleted file mode 100644
index fe79761..0000000
--- a/socket-saver.user.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// ==UserScript==
-// @name         SO-Chat-Socket-Saver
-// @namespace    http://awal.js.org/
-// @version      0.1
-// @description  i dunno what to put this is a template lmao
-// @author       awal
-// @match        *://chat.stackoverflow.com/rooms/*
-// @match        *://meta.chat.stackexchange.com/rooms/*
-// @match        *://chat.stackexchange.com/rooms/*
-// @grant        none
-// @run-at       document-start
-// ==/UserScript==
-
-if (document.body) {
-	console.warn('Socket Saver: Not properly running at document-start, setup shit properly FFS!');
-} else {
-    // we are running at document-start properly. yipee!!
-    Object.defineProperty(WebSocket.prototype, 'onopen', {
-        set: function (val) {
-            if (this.url.startsWith('wss://chat.sockets.stackexchange.com')) {
-                console.info('Socket Saver: socket saved properly, use it with window.__stackexchange_chat_saved_socket');
-                window.__stackexchangeChatSavedSocket = this;
-                window.dispatchEvent(new CustomEvent('stackexchange-socket-saved'));
-            }
-        }
-    });
-}