User:RussianInvader/bot.js

// Import scripts used for chatlogging importScriptPage('User:Monchoman45/ChatHacks.js', 'c'); var logInterval = 600000; importScriptPage('User:Joeytje50/ChatLogger.js', 'runescape'); localStorage.clear; // Commands for User:RussianBot var send = function (m) { mainRoom.socket.send(new models.ChatEntry({ roomId: this.roomId, name: mw.config.get('wgUserName'), text: m       }).xport); },   commands = function (chat) { if (chat.attributes.name !== mw.config.get('wgUserName')) { var t = chat.attributes.text, n = chat.attributes.name; switch (true) { case t === '!hello': send('Hello there' + n + '!'); break; case t === '!emotes': send('You can view the emoticons here.'); break; case t === '!logs': send('You can view the chatlogs here.'); break; case t === '!cmds': send('You can view the commands here.'); break; case /^\!remind/.test(t): if (localStorage.getItem('cmd') !== 'on') { return; }               var s = t.slice(8), a = s.split('~'); if (s === '') { return; }               if (!localStorage.getItem('remind ' + a[0])) { localStorage.setItem('remind ' + a[0], a[0] + ': ' + a[1] + ', from ' + n); send('Okay! I will remind ' + a[0] + ' after his/her next message.'); } else { send(a[1] + ' already has a reminder sent by ' + n + '. Please wait for him/her to speak and try again.'); }               break; case /^\!tell/.test(t): if (localStorage.getItem('cmd') !== 'on') { return; }               var s2 = t.slice(6), a2 = s2.split('~'); if (s2 === '') { return; }               send(a2[0] + ', ' + a2[1]); break; case /^\!note/.test(t): if (localStorage.getItem('cmd') !== 'on') { return; }               if (!localStorage.getItem('note ' + n)) { localStorage.setItem('note ' + n, 'Note: ' + t.slice(5)); send('Noted! I will message it to you after your next message.'); } else { send('You already have given me a note! Please try again.'); send(localStorage.getItem('note ' + n)); localStorage.removeItem('note ' + n); }               break; case /^\!miss/.test(t): if (localStorage.getItem('cmd') !== 'on') { return; }               if (!localStorage.getItem('miss ' + t.slice(6))) { localStorage.setItem('miss ' + t.slice(6), n); send('Okay! I will message ' + t.slice(6) + ' that you missed him/her after he/she has messaged.'); } 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 him/her, including ' + h.length + '.'); }               break; case /^\!move/.test(t): if (localStorage.getItem('cmd') !== 'on' || !mainRoom.userMain.attributes.isModerator) { return; }               var s3 = t.slice(6), a3 = s3.split('~'); send('Moving from ' + a3[0] + ' to ' + a3[1] + '...'); $.post(mw.config.get('wgServer') + '/api.php', {                   action: 'move',                    from: a3[0],                    to: a3[1],                    reason: a3[2] ? encodeURIComponent(a3[2]) : '',                    token: mw.user.tokens.values.editToken                }, function  {                    send('Done! Here is your newly-moved page: ' + a3[1] + '.');               }); break; case /^\!delete/.test(t): if (localStorage.getItem('cmd') !== 'on' || !mainRoom.userMain.attributes.isModerator) { return; }               var s4 = t.slice(8), a4 = s4.split('~'); send('Deleting ' + a4[0] + '...'); $.post(mw.config.get('wgServer') + '/api.php', {                   action: 'delete',                    title: a4[0],                    reason: a4[1] ? encodeURIComponent(a4[1]) : '',                    token: mw.user.tokens.values.editToken                }, function  {                    send('Done! ' + a4[0] + ' is now deleted.');               }); break; case /^\!add/.test(t): if (localStorage.getItem('cmd') !== 'on' || !mainRoom.userMain.attributes.isModerator) { return; }               var s5 = t.slice(5), a5 = s5.split('~'); send('Adding text you\'ve specified to ' + a5[0] + '...'); $.post(mw.config.get('wgServer') + '/api.php', {                   action: 'edit',                    title: a5[0],                    appendtext: a5[1],                    reason: a5[2] ? encodeURIComponent(a5[2]) : '',                    token: mw.user.tokens.values.editToken                }, function  {                    send('Done! The text you\'ve specified is now added to ' + a5[0] + '.');               }); break; case /^\!kick/.test(t): if (localStorage.getItem('cmd') !== 'on' || !mainRoom.userMain.attributes.isModerator) { return; }               mainRoom.kick({                    name: t.slice(6)                }); break; case /^\!on/.test(t): if (!mainRoom.userMain.attributes.isModerator) { return; }               if (localStorage.getItem('cmd') !== 'on') { localStorage.setItem('cmd', 'on'); send('Commands activated!'); } else { send('Commands are already activated!'); }               break; case /^\!off/.test(t): if (!mainRoom.userMain.attributes.isModerator) { return; }               if (localStorage.getItem('cmd') !== 'off') { localStorage.setItem('cmd', 'off'); send('Commands deactivated!'); } else { send('Commands are already deactivated!'); }               break; default: if (localStorage.getItem('cmd') !== 'on') { return; }               if (localStorage.getItem('note ' + n)) { send(localStorage.getItem('note ' + n)); localStorage.removeItem('note ' + n); }               if (localStorage.getItem('remind ' + n)) { send(localStorage.getItem('remind ' + n)); localStorage.removeItem('remind ' + n); }               if (localStorage.getItem('miss ' + n)) { send(n + ': ' + localStorage.getItem('miss ' + n) + ' missed you!'); localStorage.removeItem('miss ' + n); }           }        }    }; mainRoom.model.chats.bind('afteradd', commands);