Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var me = "Alan";
- var moonwalkOn = false;
- var waitOn = false;
- var botOn = false;
- var timer = 20;
- var lastSpeech = 0;
- var swoop = false;
- var messages = new Array("Need help? Type :help", "Type :apihelp for help creating scripts!", "Yes, yes! Blaim Mattie!", "I am Kynto's first playable bot!", "Kynto is the place to be!");
- function newMessage(obj)
- {
- msg = obj.M;
- user = obj.U;
- timer = timer * 1000;
- if (user == me)
- {
- commands = msg.split(" ");
- switch (commands[0])
- {
- case ":bot":
- bot(commands[1]);
- break;
- }
- }
- else
- {
- if (botOn)
- {
- botReply(user, msg);
- }
- }
- }
- function bot(attrib)
- {
- if (attrib == "on" && !botOn)
- {
- botOn = true;
- }
- if (attrib == "off" && botOn)
- {
- botOn = false;
- clearInterval();
- }
- if (botOn)
- {
- Kynto.moveUser(0, 0);
- randWait = Math.floor(Math.random() * 1);
- if (randWait == 1)
- {
- waitOn = true;
- }
- else
- {
- waitOn = false;
- }
- setInterval("activateBot()", timer);
- }
- }
- function activateBot()
- {
- if (botOn)
- {
- randX = Math.floor(Math.random() * 3);
- randY = Math.floor(Math.random() * 4);
- randMoon = Math.floor(Math.random() * 4);
- randSpeech = Math.floor(Math.random() * 5);
- randTalk = Math.floor(Math.random() * 2);
- if (waitOn)
- {
- // Waiting..
- waitOn = false;
- }
- else
- {
- Kynto.moveUser(randX, randY);
- waitOn = false;
- }
- if (randTalk == 1)
- {
- if (randMoon == 2 && !moonwalkOn)
- {
- Kynto.sendChat(":moonwalk");
- moonwalkOn = false;
- }
- else
- {
- if (lastSpeech == randSpeech)
- {
- randSpeech = Math.floor(Math.random() * 4) + 1;
- lastSpeech = randSpeech;
- }
- lastSpeech = randSpeech;
- Kynto.sendChat(messages[randSpeech]);
- moonwalkOn = true;
- }
- }
- }
- }
- function help(attrib)
- {
- if (attrib == 'help')
- {
- if (swoop)
- {
- Kynto.sendChat("Type :help followed by 1, 2 or 3 (:help 2).");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Type :help followed by 1, 2 or 3 (:help 2)");
- swoop = true;
- }
- }
- else
- {
- switch (attrib)
- {
- case '1':
- if (swoop)
- {
- Kynto.sendChat("Type :commands for a list of commands!");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Type :commands for a list of commands.");
- swoop = true;
- }
- break;
- case '2':
- if (swoop)
- {
- Kynto.sendChat("Type :console to start scripting!");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Type :console to start scripting.");
- swoop = true;
- }
- break;
- case '3':
- if (swoop)
- {
- Kynto.sendChat("Use the big blue ? to call a moderator!");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Use the big blue ? to call a moderator.");
- swoop = true;
- }
- break;
- case 'api':
- var APIHelpBox1 = "Kynto.createAlert(MESSAGE)\t/\/\Creates and shows a new alert.";
- var APIHelpBox2 = "Kynto.sendChat(MESSAGE)\t/\/\Sends a speech bubble from you.";
- if (swoop)
- {
- Kynto.sendChat(APIHelpBox1);
- swoop = false;
- }
- else
- {
- Kynto.sendChat(APIHelpBox2);
- swoop = true;
- }
- break;
- }
- }
- }
- function botReply(user, msg)
- {
- commands = msg.split(":");
- switch (commands[1])
- {
- case 'help':
- help('help');
- break;
- case 'apihelp':
- help('api');
- break;
- case 'help 1':
- help('1');
- break;
- case 'help 2':
- help('2');
- break;
- case 'help 3':
- help('3');
- break;
- }
- }
- function addUser(obj)
- {
- user = obj.U;
- if (user != me && botOn)
- {
- if (swoop)
- {
- Kynto.sendChat("Welcome to kynto, " + user + "!");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Welcome, " + user + "!");
- swoop = true;
- }
- }
- }
- function userStatus(obj)
- {
- user = obj.U;
- if(obj.S == "online" && user != me && botOn)
- {
- if (swoop)
- {
- Kynto.sendChat("Welcome back, " + user + "!");
- swoop = false;
- }
- else
- {
- Kynto.sendChat("Welcome back, " + user + " :)");
- swoop = true;
- }
- }
- }
Add Comment
Please, Sign In to add comment