OpalBot-Code

//inspired by the great Dorumin
//<syntaxhighlight lang="javascript">
// Is after
$.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!';

```

};

function callAPI(data, method, callback) {

```
   data.format = 'json';
   $.ajax({
       data: data,
       dataType: 'json',
       url: wgScriptPath + '/api.php',
       type: method,
       success: function(response) {
           if (response.error)
               showError('API error: ' + response.error.info);
           else
               callback(response);
       },
       error: function(xhr, error) {
           showError('AJAX error: ' + error);
       }
   });

```

}

var kickcount = 0,

```
   cbancount = 0,
   quitcount = 0,
   joincount = 0,
   chatcount = 0,
   kickmsg = "\\(gem destabilizer left\\) \\[\\[User:.*\\|.*]] has been destabilized by \\[\\[User:.*\\|.*]] \\(gem destabilizer right\\)",
   cbanmsg = "\\(break\\) \\[\\[User:.*\\|.*]] has been broken by \\[\\[User:.*\\|.*]] \\(breakleft\\) .*",
   quitmsg = "\\[\\[User:.*\\|.*]] has warped out",
   joinmsg = "\\[\\[User:.*\\|.*]] has warped into the Crystal Palace";

```

var months = [

```
       "January",
       "February",
       "March",
       "April",
       "May",
       "June",
       "July",
       "August",
       "September",
       "October",
       "November",
       "December"
   ],

```

 logText = '',

```
   restart = false,
   leave = false,
   postLog = false;

```

mw.util.addCSS('.faded{color:grey;}');

var curDay = new Date().getUTCDate();

setTimeout(function() {

```
   $('.Chat li').each(function() {
       if (!$(this).isAfter('.inline-alert') && !$(this).hasClass('inline-alert')) {
           $(this).children('.message').attr('class', 'faded');
       }
   });

```

}, 15000);

// Send function
var send = function(m) {

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

   // Swears
   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"
   ],

   // Function itself
   BotCheck = function(chat) {
       // Logging
       if (!$('#entry-' + chat.cid).isAfter('.inline-alert') && !$('#entry-' + chat.cid).isAfter('#' + localStorage.getItem('lastMsg'))) return;
       var t = chat.attributes.text,
           te = mw.html.escape(t);
       var n = chat.attributes.name,
           ne = mw.html.escape(n);
       var ns = n + 'Swr';
       cid = chat.cid;
       var msgType;
       if ( new Date().getUTCDate() != curDay ) {
           curDay = new Date().getUTCDate();
           submitLogs();
       }
       if (n ===  *&& new RegExp(joinmsg, 'mi').test(t)) {*
           msgType = ' [JOIN] ';
           joincount++;
       } else if (n ===  *&& new RegExp(quitmsg, 'mi').test(t)) {*
           msgType = ' [QUIT] ';
           quitcount++;
       } else if (n ===  *&& new RegExp(kickmsg, 'mi').test(t)) {*
           msgType = ' [KICK] ';
           kickcount++;
       } else if (n ===  *&& new RegExp(cbanmsg, 'mi').test(t)) {*
           msgType = ' [CBAN] ';
           cbancount++;
       } else if (n === mw.config.get('wgUserName') ) {
           msgType = ' [CBOT] ';
       } else if (n === *) {*
            return;
       } else {
           msgType = ' [CHAT] ';
           chatcount++;
       }
       var msgDate = new Date();
       var msgTimestamp = (msgDate.getUTCHours() < 10 ? '0' : *) + msgDate.getUTCHours() + ':' + (msgDate.getUTCMinutes() < 10 ? '0' :* ) + msgDate.getUTCMinutes() + ':' + (msgDate.getUTCSeconds() < 10 ? '0' : *) + msgDate.getUTCSeconds();*
       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');

```
       }
       // Other checking
       if (chat.attributes.name !== mw.config.get('wgUserName')) {
           if (localStorage.getItem('disabled') !== 'disabled') {
               for (var i = 0; i < SWEARS.length; i++) {
                   if (new RegExp(SWEARS[i], "mi").test(t) === true) {
                       send(n + ', please don\'t swear!');
                       setTimeout(function() {
                           mainRoom.kick({
                               name: n
                           });
                       }, 200);
                       break;
                   }
               }
               // ban for slurs
               for (var i = 0; i < SLURS.length; i++) {
                   if (new RegExp(SLURS[i], "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());
                       break;
                   }
               }
           }
           // Commands
           if (mainRoom.model.users.findByName(n) == null) return;
           var matched = true;
           if (mainRoom.model.users.findByName(n).attributes.isModerator) {
               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 t === '!restart':
                       restart = true;
                       send('Logging...');
                       submitLogs();
                       break;
                   case t === '!log':
                       postLog = true;
                       send('Logging...');
                       submitLogs();
                       break;
               }
               if (localStorage.getItem('OBenabled') !== 'enabled') return;
               switch (true) {
                   case t === '!hello':
                       if (n == 'Lenhi') {
                           send('Hello meme queen (fire)');
                       } else if (n == 'Dorumin') {
                           send('Hello useless pile of goop');
                       } else if (n == '50000cal') {
                           send('Hello Pearl.');
                       } 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('[[[Project:Chat/Logs|All logs]]] - [[[Project:Chat/Logs/' + ttl + '|Today]]]');
                       break;
                   case t === '!test':
                       send('ʇsǝʇ¡');
                       break;
                   case t === '!info':
                       send('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 === '!donut':
                       send('[big]◯[/big]');
                       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 === '!memes':
                       send('[c="red"] [big] [font="chiller"] not today satan [/font] [/big] [/c]');
                       break;
                   case /has been destabilized by/.test(t):
                       if (n === *) {*
                           localStorage.setItem('lastK', t.replace(/(\(gem destabilizer left\) \[\[User:.*?\||]] has been destabilized by \[\[User:.*\|.*]] \(gem destabilizer right\))/g, *));*
                       }
                       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('lastK'), localStorage.getItem('lastK') + ': ' + wrn);
                       send('Sure thing.');
                       break;
                   default:
                       matched = false;
                       break;
               }
           } // End mod-only section
           if (matched) return;
           // 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);
   }

```

});
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)');*

```

});

if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {

```
   mainRoom.model.chats.bind('afteradd', BotCheck);

```

}

// Submits the logs (uploadText) and then clears them
submitLogs = function() {

```
   if ( wgPageName != 'Special:Chat' ) return;
   var d = new Date(),
       ttl = d.getUTCDate() + '_' + months[d.getUTCMonth()] + '_' + d.getUTCFullYear(),
       uploadText = logText;

```

 logText = '';

```
   callAPI({
       '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) {
           callAPI({
               '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[[Category:Wikia Chat logs|2016 04 23]]'
            }, 'POST', function(response) {
                console.log('Creating [[Project:Chat/Logs/' + ttl + '|chatlog]]: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.');
                if ( postLog ) {
                    send('Creating chatlog: ' + kickcount + ' kicks and ' + cbancount + ' bans reported. ' + joincount + ' joins, ' + quitcount + ' leaves, and ' + chatcount + ' messages logged.');
                }
                if ( restart ) {
                    send('Restarting...');
                    localStorage.setItem('lastMsg', mainRoom.viewDiscussion.chatUL.children().last().attr('id'));
                    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('<li class="inline-alert">Window cleared.</li>');
            });
        } else {
            callAPI({
                '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.');
               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...');
                   localStorage.setItem('lastMsg', mainRoom.viewDiscussion.chatUL.children().last().attr('id'));
                   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 actual interval
setInterval(function() {
 submitLogs();
}, logInterval);

// Submit commands from bot
$('[name="message"]').keypress(function(e) {
 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 d = new Date();
 var ttl = d.getUTCDate() + '\_' + months[d.getUTCMonth()] + '\_' + d.getUTCFullYear();
 send('[[[Project:Chat/Logs|All logs]]] - [[[Project:Chat/Logs/' + ttl + '|Today]]]');
 break;
 case val === '!test':
 send('ʇsǝʇ¡');
 break;
 case val === '!info':
 send('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);
 }
});
//
//<syntaxhighlight lang="javascript">