User:WQCX/core.javascript

$.fn.isAfter = function(sel) { return this.prevAll(sel).length !== 0; }; // Don't leave window.onbeforeunload = function { if (leave || restart) return; return 'Man you must be out of your mind!'; };

// Regex Escape RegExp.escape= function(s) { return s.replace(/[-\/\\^$*+?.|[\]{}]/g, '\\$&'); };

// Call API function API(data, method, callback) { data.format = 'json'; $.ajax({       data: data,        dataType: 'json',        url: wgScriptPath + '/api.php',        type: method,        success: function(response) {            if (response.error)                console.log('API error: ' + response.error.info);            else                callback(response);        },        error: function(xhr, error) {            console.log('AJAX error: ' + error);        }    }); } // For custom inline-alerts function getInlineRegex(variable, Default, title) { $.get('/api.php?action=query&format=json&prop=revisions&rvprop=content&titles=' + title, function(data) {      if ( data.query.pages['-1'] ) {            window[variable] = Default;        } else {            window[variable] = RegExp.escape(data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*']).replace(/\\\$(1|2|3)/g, '.*');        }    }); }

getInlineRegex('kickmsg', '.+ has been kicked by .+', 'MediaWiki:Chat-user-was-kicked'); getInlineRegex('cbanmsg', '.+ has been banned by .+', 'MediaWiki:Chat-user-was-banned'); getInlineRegex('quitmsg', '.+ has left the chat', 'MediaWiki:Chat-user-parted'); getInlineRegex('joinmsg', '.+ has joined the chat', 'MediaWiki:Chat-user-joined');

var kickcount = 0, cbancount = 0, quitcount = 0, joincount = 0, chatcount = 0, restart  = false, leave    = false, postLog  = false, wasFound = false, isLogging = false, logText  = ' ', version  = 'v1.6', curDay   = new Date.getUTCDate, botStart = new Date.getTime;

// Swears var SWEARS = [ "\\bfuck", "\\bmotherfuck", "\\bshit\\b", "\\bshitt", "\\bshitp", "\\bbitch", "\\bcunt", "\\bdafuq\\b", "\\bwhore\\b", "\\bmofo\\b", "\\bfml\\b", "\\bgtfo\\b", "\\bstfu\\b", "\\bwtf\\b", "\\bidfk\\b", "\\bidfc\\b", "\\bidgaf\\b", "\\bidefk\\b", "\\bjfc\\b", "\\bomf", "\\bffs\\b", "\\bw t f", "\\bmilf\\b" ],

// Slurs SLURS = [ "\\bnigg", "\\bniglet\\b", "\\bfag\\b", "\\bfagg" ], weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],

months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];

// Send function var send = function(m) { mainRoom.socket.send(new models.ChatEntry({ roomId: this.roomId, name: mw.config.get('wgUserName'), text: m   }).xport); },

// Function that will run after each message is sent BotCheck = function(chat) { /* Logging */ // return if it was found before the bot entered, or if it its placed before the last mesage on !restart if (!$('#entry-' + chat.cid).isAfter('.inline-alert') && !wasFound) { if ( mainRoom.model.chats._byId[Number(localStorage.getItem('lastMsg'))] != null ) { wasFound = true; }       return; }   // get variables var t = chat.attributes.text, te = mw.html.escape(t); var n = chat.attributes.name, ne = mw.html.escape(n); var isInlineAlert = chat.attributes.isInlineAlert == null ? false : true; var ns = n + 'Swr'; cid = chat.cid; var msgType; // submit at the end of the day if ( new Date.getUTCDate != curDay ) { curDay = new Date.getUTCDate; submitLogs(date.getUTCDate + '_' + months[date.getUTCMonth] + '_' + date.getUTCFullYear); }   date = new Date; // get message type if ( isInlineAlert ) { if ( new RegExp(joinmsg, 'mi').test(t)) { msgType = ' [JOIN] '; joincount++; } else if ( new RegExp(quitmsg, 'mi').test(t)) { msgType = ' [QUIT] '; quitcount++; } else if ( new RegExp(kickmsg, 'mi').test(t)) { msgType = ' [KICK] '; localStorage.setItem('lastKick', t.trim.replace(/\[\[User:.*?\||\]\] has been given to the gnomes by \[\[User:.*\|.*\]\]/g, )); kickcount++; } else if ( new RegExp(cbanmsg, 'mi').test(t)) { msgType = ' [CBAN] '; te = te.replace(/\(&lt;a href=&quot;#&quot; data-type=&quot;ban-undo&quot; data-user=&quot;.+&quot;\s*&gt;undo&lt;\/a&gt;\)/, ); cbancount++; } else { return; }   } else if (n === mw.config.get('wgUserName') ) { msgType = ' [CBOT] '; } else { msgType = ' [CHAT] '; chatcount++; }   // get message time var msgDate = new Date; var msgTimestamp = (msgDate.getUTCHours < 10 ? '0' : ) + msgDate.getUTCHours + ':' + (msgDate.getUTCMinutes < 10 ? '0' : ) + msgDate.getUTCMinutes + ':' + (msgDate.getUTCSeconds < 10 ? '0' : ) + msgDate.getUTCSeconds; // adds the values to the actual log if ( msgType == ' [CHAT] ' || msgType == ' [CBOT] ' ) { te = te.replace(/\n/g, '\n         ' + msgType); logText = logText.replace(' ', '[' + msgTimestamp + ']' + msgType + ne + ': ' + te + '\n '); } else { logText = logText.replace(' ', '[' + msgTimestamp + ']' + msgType + te + '\n '); }   /* Swear/Rule-break checking */ if (chat.attributes.name !== mw.config.get('wgUserName')) { if (localStorage.getItem('disabled') !== 'disabled' && !isInlineAlert) { // kick for swears if (new RegExp(SWEARS.join('|'), "mi").test(t) === true) { send(n + ', please don\'t swear!'); setTimeout(function {                   mainRoom.kick({ name: n                   });                }, 200); }           // ban for slurs else if (new RegExp(SLURS.join('|'), "mi").test(t) === true) { send(n + ', please don\'t use that language.'); mainRoom.socket.send(new models.BanCommand({ userToBan: n,                   time: 86400, reason: 'Slur' }).xport); }           // warn for caps else if (t.match(/\b[A-Z]{2,}\b/g) !== null) { if (t.match(/\b[A-Z]{2,}\b/g).length > 6) { send(n + ', please don\'t abuse caps!'); }           // warn for stretching text } else if ( /(\S)\1{22,}/.test(t)) { send(n + ', please don\'t stretch text!'); }           // warn for big text else if ( t.match(/\[big\](.+?)\[\/big\]/g) !== null ) { if ( t.match(/\[big\](.+?)\[\/big\]/g).join(' ').replace(/\b\S\b|\(.*\)|\[big]|\[\/big]/g, ).split(' ').filter(Boolean).length > 6) { send(n + ', please don\'t abuse big text!'); }           } else if ( t.match(/\[big\](?!.*\[big\])(.*)/g) !== null ) { if ( t.match(/\[big\](?!.*\[big\])(.*)/g)[0].replace(/\b\S\b|\(.*\)|\[big]|\[\/big]/g, ).split(' ').filter(Boolean).length > 6 ) { send(n + ', please don\'t abuse big text!'); }           }        }        /* Commands */ if (mainRoom.model.users.findByName(n) == null) return; // return if is inline-alert var matched = true; // for !note // only execute commands if chat moderator if (mainRoom.model.users.findByName(n).attributes.isModerator || t.charAt(0) != '!') { // command that are always on           switch (true) { case /^\!on/.test(t):

if (localStorage.getItem('OBenabled') === 'enabled') { send('Already up and running!'); } else { localStorage.setItem('OBenabled', 'enabled'); send('Booting up!'); }                   break; case /^\!off/.test(t):

if (localStorage.getItem('OBenabled') === 'disabled') { send('...'); } else { localStorage.setItem('OBenabled', 'disabled'); send('Shutting down...'); }                   break; case /^\!enable/.test(t):

if (localStorage.getItem('disabled') === 'disabled') { localStorage.setItem('disabled', 'enabled'); send('Enabling swear checking!'); } else { send('Swear checking is already enabled!'); }                   break; case /^\!disable/.test(t):

if (localStorage.getItem('disabled') !== 'disabled') { localStorage.setItem('disabled', 'disabled'); send('Swear checking disabled.'); } else { send('Swear checking is already disabled.'); }                   break; case /^\!leave/.test(t): leave = true; submitLogs; break; case /^\!runtime/.test(t): var botEnd    = new Date.getTime; var msDiff    = botEnd - botStart;   // in ms                    var secDiff    = msDiff / 1000 % 60;         // in s                    var minDiff    = msDiff / 60 / 1000 % 60;    // in minutes var hourDiff  = msDiff / 3600 / 1000 % 24;  // in hours var dayDiff   = msDiff / 86400 / 1000; // in days send('FootBot ' + version + ' has been running for ' + Math.floor(dayDiff) + ' days, ' + Math.floor(hourDiff) + ' hours, ' + Math.floor(minDiff) + ' minutes, and ' + Math.floor(secDiff) + ' seconds.'); break; case t === '!restart': restart = true; send('Logging...'); submitLogs; break; case t === '!log': postLog = true; send('Logging...'); submitLogs; break; }           // commands that can be disabled with !off if (localStorage.getItem('OBenabled') !== 'enabled') return; switch (true) { case t === '!hello': if (n == 'Ditto Creeper Bot') { send('Hello my couch'); } else if (n == 'Terrios528') { send('Hello Terraria o/'); } else if (n == 'Flash of Memory') { send('Oh my Memories ;3'); } else { send('Hello there ' + n + '!'); }                   break; case t === '!bye': send('Goodbye, ' + n + '. Don\'t be gone for long. :(');                   break;                case t === '!emotes':                    send('You can view the emoticons here. Or the "Emoticons" Rail button, yeah that\'s new and it rendered this command useless.');                   break;                case t === '!logs':                    var d = new Date;                    var ttl = d.getUTCDate + '_' + months[d.getUTCMonth] + '_' + d.getUTCFullYear;                    send('All logs] - Today]');                    break;                case t === '!test':                    send('ʇsǝʇ¡');                    break;                case t === '!info':                    send('FootBot ' + version + ': Commands here. Swear checking: ' + localStorage.getItem('disabled') + '. Commands: ' + localStorage.getItem('OBenabled') + '.');                   break;                case t === '!site':                    send('You are using Wikia.com, a website dedicated to wiki farming.');                    break;                case t === '!tou':                    send('Wikia\'s Terms of Use are located here.');                    break;                case t === '!rules':                    send('You can find the chat rules here.');                    break;                case t === '!fun':                    send('Fun you say? You may be looking for this: http://theuselessweb.com');                   break;                case t === '!baby':                    send('http://www.youtube.com/watch?v=dQw4w9WgXcQ');                    break;                case t === '!swag':                    send('The user above me has some serious swag.');                    break;                case t === '!space may be the final frontier':                    send('But it\'s made in a Hollywood basement.');                    break;                case t === '!Knock':                    send('Whose there?');                    break;                case t === '!ping':                    send('Pong!\n' + String(new Date.getTime - mainRoom.model.chats.models[mainRoom.model.chats.models.length - 1].attributes.timeStamp).replace(/...$/, '.$&'));                    break;                case /^\!tell/.test(t):

var s = t.slice(6), a = s.split(' that:');

if (s === ) { return; }

if (a[0] == n) { send('I\'m not sending yourself a message. Winners don\'t use drugs.'); return; }

if (a[0] == mw.config.get('wgUserName')) { send('How about no?'); return; }

if (mainRoom.model.users.findByName(a[0]) != null) { send('They\'re already on chat. Tell them yourself you lazy bum.'); return; }

if (!localStorage.getItem('tell ' + a[0])) { localStorage.setItem('tell ' + a[0], 'Ah! ' + a[0] + '! ' + n + ' wanted me to tell you: ' + a[1] + '.'); send('Okay! I will tell ' + a[0] + ' that next time we meet.'); } else { send(a[0] + ' already has a message pending. Please wait for them to speak and try again.'); }                   break; case /^\!gettell/.test(t):

var m = t.slice(9);

if (m === ) { return; }

if (localStorage.getItem('tell ' + m)) { send('on ' + m + ' inbox: ' + localStorage.getItem('tell ' + m).replace(/Ah! .*! .* wanted me to tell you: /gi, ) ); } else { send(m + ' has no messages pending!'); }                   break; case /^\!seen/.test(t):

var x = t.slice(6);

if (x === ) { return; }

if (x == n) { send('Heck I dunno, ask ' + n); return; }

if (x == mw.config.get('wgUserName')) { send('No.'); return; }

if (mainRoom.model.users.findByName(x) != null) { send('They\'re in chat right now so... you just pinged them.'); return; }

if (localStorage.getItem('seen ' + x)) { send(localStorage.getItem('seen ' + x)); } else { send('I have not seen ' + x + '. Sorry.'); }                   break; case /^\!cleartell/.test(t):

var w = t.slice(11);

if (w === ) { return; }

if (localStorage.getItem('tell ' + w)) { localStorage.removeItem('tell ' + w); send('Messages for ' + w + ' have been cleared!'); } else { send(w + ' has no messages pending!'); }                   break; case /^\!note/.test(t):

if (!localStorage.getItem('note ' + n)) { localStorage.setItem('note ' + n, n + ': ' + t.slice(5)); send('Noted! I will message it to you next time we meet.'); } else { send('You already have given me a note! Winners don\'t use drugs.'); send(localStorage.getItem('note ' + n)); localStorage.removeItem('note ' + n); }                   break; case /^\!miss/.test(t):

if (t.slice(6) == n) { send('how dang egoistic are you?'); break; }

if (t.slice(6) == mw.config.get('wgUserName')) { send('Aww thank you ;^>'); break; }

if (mainRoom.model.users.findByName(t.slice(6)) != null) { send('I\'m sure they miss you back.'); break; }

if (!localStorage.getItem('miss ' + t.slice(6))) { localStorage.setItem('miss ' + t.slice(6), n); send('Okay! I will tell ' + t.slice(6) + ' that you missed them next time we meet.'); } else { var l = localStorage.getItem('miss ' + t.slice(6)), h = l.split('~');

localStorage.setItem('miss ' + t.slice(6), l + '~' + n); send('Okay! I will message ' + t.slice(6) + ' that you missed them, including ' + h.length + '.'); }                   break; case /^\!warn/.test(t):

var wrn = t.slice(6);

localStorage.setItem('warn ' + localStorage.getItem('lastKick'), localStorage.getItem('lastK') + ': ' + wrn); send('Sure thing.'); break; default: matched = false; break; }       } // End mod-only section if (matched) return; // for !note // Check everyone if (localStorage.getItem('note ' + n)) { send(localStorage.getItem('note ' + n)); localStorage.removeItem('note ' + n); }

if (localStorage.getItem('tell ' + n)) { send(localStorage.getItem('tell ' + n)); localStorage.removeItem('tell ' + n); }

if (localStorage.getItem('miss ' + n)) { send('Ah! ' + n + '! ' + localStorage.getItem('miss ' + n) + ' missed you!'); localStorage.removeItem('miss ' + n); }   } }; // Inline-alert checking mainRoom.model.users.bind('add', function(add) {   var n = add.attributes.name;    if ( n == mw.config.get('wgUserName') ) return;    if (localStorage.getItem('note ' + n)) {        send(localStorage.getItem('note ' + n));        localStorage.removeItem('note ' + n);    }    if (localStorage.getItem('warn ' + n)) {        send(localStorage.getItem('warn ' + n));        localStorage.removeItem('warn ' + n);    }    if (localStorage.getItem('tell ' + n)) {        send(localStorage.getItem('tell ' + n));        localStorage.removeItem('tell ' + n);    }    if (localStorage.getItem('miss ' + n)) {        send('Ah! ' + n + '! ' + localStorage.getItem('miss ' + n) + ' missed you!');       localStorage.removeItem('miss ' + n);    } });

// quits mainRoom.model.users.bind('remove', function(remove) {   var n = remove.attributes.name;    if ( n == mw.config.get('wgUserName') ) return;    curDate = new Date;    localStorage.setItem('seen ' + n, "Last time I saw " + n + ' was on: ' + weekdays[curDate.getDay] + ', ' + months[curDate.getMonth] + " " + curDate.getDate + ', ' + curDate.getFullYear + " at " + (curDate.getUTCHours < 10 ? '0' : ) + curDate.getUTCHours + ":" + (curDate.getUTCMinutes < 10 ? '0' : ) + curDate.getUTCMinutes + ":" + (curDate.getUTCSeconds < 10 ? '0' : ) + curDate.getUTCSeconds + ' (UTC)'); }); // Function to submit the logs (uploadText) and then clears them submitLogs = function(logDate) { if ( wgPageName != 'Special:Chat' || isLogging) return; isLogging = true; var d = new Date, ttl = logDate || d.getUTCDate + '_' + months[d.getUTCMonth] + '_' + d.getUTCFullYear, uploadText = logText; logText = ' '; localStorage.setItem('lastMsg', mainRoom.model.chats.models[Object.keys(mainRoom.model.chats.models).length - 1].attributes.id); API({       'action': 'query',        'prop': 'info|revisions',        'intoken': 'edit',        'titles': 'Project:Chat/Logs/' + ttl,        'rvprop': 'content|timestamp',        'rvlimit': '1',        'indexpageids': 'true',    }, 'GET', function(response) {        var page = response.query.pages[Object.keys(response.query.pages)[0]];        var pageExists = response.query.pages["-1"] ? false : true;        var content = typeof(page.revisions) != "undefined" ? page.revisions[0]['*'] : ;        if (!pageExists) {            API({ 'minor': 'yes', 'bot': 'yes', 'summary': 'Creating chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.', 'action': 'edit', 'title': 'Project:Chat/Logs/' + ttl, 'token': page.edittoken, 'text': '\n' + uploadText + '\n' }, 'POST', function(response) { console.log('Creating chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.'); isLogging = false; if ( postLog ) { send('Creating chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.'); }                 if ( restart ) { send('Restarting...'); window.location.reload; }                 if ( leave ) { send('I\'m so sorry...'); window.open('/wiki/User:I_love_the_Smell_of_Napalm_after_I_bang_Gay_Lenhi', '_self'); }                 kickcount = 0, cbancount = 0, quitcount = 0, joincount = 0, chatcount = 0; $('#entry-' + cid).prevAll('.Chat li').remove; $('#entry-' + cid).replaceWith('Window cleared.'); });         } else {              API({ 'minor': 'yes', 'bot': 'yes', 'summary': 'Adding to chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.', 'action': 'edit', 'title': 'Project:Chat/Logs/' + ttl, 'basetimestamp': page.revisions[0].timestamp, 'token': page.edittoken, 'text': content.replace(' ', uploadText) }, 'POST', function(response) { console.log('Adding to chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.'); isLogging = false; if ( postLog ) { send('Adding to chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.'); postLog = false; }               if ( restart ) { send('Restarting...'); window.location.reload; }               if ( leave ) { send('I\'m so sorry...'); window.open('/wiki/User:I_love_the_Smell_of_Napalm_after_I_bang_Gay_Lenhi', '_self'); }               kickcount = 0, cbancount = 0, quitcount = 0, joincount = 0, chatcount = 0; $('#entry-' + cid).prevAll('.Chat li').remove; $('#entry-' + cid).replaceWith(' Window cleared.'); }); } }); }; // Sets the interval for submitting the logs setInterval(function { submitLogs; }, window.logInterval || 600000); // Appends the function to chat updates if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') { mainRoom.model.chats.bind('afteradd', BotCheck); } // Submit commands from the bot window $('[name="message"]').keypress(function(e) { if (e.which !== 13 || e.shiftKey || !mainRoom.active) return; var val = this.value; var n = mw.config.get('wgUserName'); this.value = ; switch(true) { case /^\!on/.test(val): if (localStorage.getItem('OBenabled') !== 'enabled') { localStorage.setItem('OBenabled', 'enabled'); send('Booting up!'); } else { send('Already up and running!'); } break; case /^\!off/.test(val): if (localStorage.getItem('OBenabled') !== 'disabled') { localStorage.setItem('OBenabled', 'disabled'); send('Shutting down...'); } else { send('...'); } break; case /^\!enable/.test(val): if (localStorage.getItem('disabled') === 'disabled') { localStorage.setItem('disabled', 'enabled'); send('Enabling swear checking!'); } else { send('Swear checking is already enabled!'); } break; case /^\!disable/.test(val): if (localStorage.getItem('disabled') !== 'disabled') { localStorage.setItem('disabled', 'disabled'); send('Swear checking disabled.'); } else { send('Swear checking is already disabled.'); } break; case /^\!leave/.test(val): leave = true; submitLogs; break; case val === '!restart': send('Logging...'); restart = true; submitLogs; break; case val === '!log': send('Logging...'); postLog = true; submitLogs; break; case val === '!hello': send('Hello there ' + n + '!'); break; case val === '!bye': send('Goodbye, ' + n + '. Don\'t be gone for long. :('); break; case val === '!emotes': send('You can view the emoticons here. Or the "Emoticons" Rail button, yeah that\'s new and it rendered this command useless.'); break; case val === '!logs': var ttl = date.getUTCDate + '_' + months[date.getUTCMonth] + '_' + date.getUTCFullYear; send('All logs] - Today]'); break; case val === '!test': send('ʇsǝʇ¡'); break; case val === '!info': send('OpalBot ' + version + ': Commands here. Swear checking: ' + localStorage.getItem('disabled') + '. Commands: ' + localStorage.getItem('OBenabled') + '.'); break; case val === '!site': send('You are using Wikia.com, a website dedicated to wiki farming.'); break; case val === '!tou': send('Wikia\'s Terms of Use are located here.'); break; case val === '!rules': send('You can find the chat rules here.'); break; case val === '!fun': send('Fun you say? You may be looking for this: http://theuselessweb.com'); break; case val === '!donut': send('[big]◯[/big]'); break; case val === '!baby': send('http://www.youtube.com/watch?v=dQw4w9WgXcQ'); break; case val === '!swag': send('The user above me has some serious swag.'); break; case val === '!space may be the final frontier': send('But it\'s made in a Hollywood basement.'); break; case val === '!memes': send('[c="red"] [big] [font="chiller"] not today satan [/font] [/big] [/c]'); break; case /^\!tell/.test(val): var s = val.slice(6), a = s.split(' that:'); if (s === ) { return; } if (a[0] == n) { send('I\'m not sending yourself a message. Winners don\'t use drugs.'); return; } if (a[0] == mw.config.get('wgUserName')) { send('How about no?'); return; } if (!localStorage.getItem('tell ' + a[0])) { localStorage.setItem('tell ' + a[0], 'Ah! ' + a[0] + '! ' + n + ' wanted me to tell you: ' + a[1] + '.'); send('Okay! I will tell ' + a[0] + ' that next time we meet.'); } else { send(a[0] + ' already has a message pending. Please wait for them to speak and try again.'); } break; case /^\!gettell/.test(val): var m = val.slice(9); if (m === ) { return; } if (localStorage.getItem('tell ' + m)) { send('on ' + m + ' inbox: ' + localStorage.getItem('tell ' + m).replace(/Ah! .*! .* wanted me to tell you: /gi, ) ); } else { send(m + ' has no messages pending!'); } break; case /^\!seen/.test(val): var x = val.slice(6); if (x === ) { return; } if (x == n) { send('Heck I dunno, ask ' + n); return; } if (x == mw.config.get('wgUserName')) { send('No.'); return; } if (localStorage.getItem('seen ' + x)) { send(localStorage.getItem('seen ' + x)); } else { send('I have not seen ' + x + '. Sorry.'); } break; case /^\!cleartell/.test(val): var w = val.slice(11); if (w === ) { return; } if (localStorage.getItem('tell ' + w)) { localStorage.removeItem('tell ' + w); send('Messages for ' + w + ' have been cleared!'); } else { send(w + ' has no messages pending!'); } break; case /^\!note/.test(val): if (!localStorage.getItem('note ' + n)) { localStorage.setItem('note ' + n, n + ': ' + val.slice(5)); send('Noted! I will message it to you next time we meet.'); } else { send('You already have given me a note! Winners don\'t use drugs.'); send(localStorage.getItem('note ' + n)); localStorage.removeItem('note ' + n); } break; case /^\!miss/.test(val): if (val.slice(6) == n) { send('how dang egoistic are you?'); break; } if (val.slice(6) == mw.config.get('wgUserName')) { send('Aww thank you ;^>'); break; } if (!localStorage.getItem('miss ' + val.slice(6))) { localStorage.setItem('miss ' + val.slice(6), n); send('Okay! I will tell ' + val.slice(6) + ' that you missed them next time we meet.'); } else { var l = localStorage.getItem('miss ' + val.slice(6)), h = l.split('~'); localStorage.setItem('miss ' + val.slice(6), l + '~' + n); send('Okay! I will message ' + val.slice(6) + ' that you missed them, including ' + h.length + '.'); } break; case /^\!warn/.test(val): var wrn = val.slice(6); localStorage.setItem('warn ' + localStorage.getItem('lastK'), localStorage.getItem('lastK') + ': ' + wrn); send('Sure thing.'); break; default: send(val); } });