Guest User

Untitled

a guest
Jul 21st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. var me = "Alan";
  2. var moonwalkOn = false;
  3. var waitOn = false;
  4. var botOn = false;
  5. var timer = 20;
  6. var lastSpeech = 0;
  7. var swoop = false;
  8. 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!");
  9. function newMessage(obj)
  10. {
  11. msg = obj.M;
  12. user = obj.U;
  13. timer = timer * 1000;
  14. if (user == me)
  15. {
  16. commands = msg.split(" ");
  17. switch (commands[0])
  18. {
  19. case ":bot":
  20. bot(commands[1]);
  21. break;
  22. }
  23. }
  24. else
  25. {
  26. if (botOn)
  27. {
  28. botReply(user, msg);
  29. }
  30. }
  31. }
  32. function bot(attrib)
  33. {
  34. if (attrib == "on" && !botOn)
  35. {
  36. botOn = true;
  37. }
  38. if (attrib == "off" && botOn)
  39. {
  40. botOn = false;
  41. clearInterval();
  42. }
  43. if (botOn)
  44. {
  45. Kynto.moveUser(0, 0);
  46. randWait = Math.floor(Math.random() * 1);
  47.  
  48. if (randWait == 1)
  49. {
  50. waitOn = true;
  51. }
  52. else
  53. {
  54. waitOn = false;
  55. }
  56. setInterval("activateBot()", timer);
  57. }
  58. }
  59. function activateBot()
  60. {
  61. if (botOn)
  62. {
  63. randX = Math.floor(Math.random() * 3);
  64. randY = Math.floor(Math.random() * 4);
  65. randMoon = Math.floor(Math.random() * 4);
  66. randSpeech = Math.floor(Math.random() * 5);
  67. randTalk = Math.floor(Math.random() * 2);
  68.  
  69. if (waitOn)
  70. {
  71. // Waiting..
  72. waitOn = false;
  73. }
  74. else
  75. {
  76. Kynto.moveUser(randX, randY);
  77. waitOn = false;
  78. }
  79.  
  80. if (randTalk == 1)
  81. {
  82. if (randMoon == 2 && !moonwalkOn)
  83. {
  84. Kynto.sendChat(":moonwalk");
  85. moonwalkOn = false;
  86. }
  87. else
  88. {
  89. if (lastSpeech == randSpeech)
  90. {
  91. randSpeech = Math.floor(Math.random() * 4) + 1;
  92. lastSpeech = randSpeech;
  93. }
  94. lastSpeech = randSpeech;
  95. Kynto.sendChat(messages[randSpeech]);
  96. moonwalkOn = true;
  97. }
  98. }
  99. }
  100. }
  101. function help(attrib)
  102. {
  103. if (attrib == 'help')
  104. {
  105. if (swoop)
  106. {
  107. Kynto.sendChat("Type :help followed by 1, 2 or 3 (:help 2).");
  108. swoop = false;
  109. }
  110. else
  111. {
  112. Kynto.sendChat("Type :help followed by 1, 2 or 3 (:help 2)");
  113. swoop = true;
  114. }
  115. }
  116. else
  117. {
  118. switch (attrib)
  119. {
  120. case '1':
  121. if (swoop)
  122. {
  123. Kynto.sendChat("Type :commands for a list of commands!");
  124. swoop = false;
  125. }
  126. else
  127. {
  128. Kynto.sendChat("Type :commands for a list of commands.");
  129. swoop = true;
  130. }
  131. break;
  132.  
  133. case '2':
  134. if (swoop)
  135. {
  136. Kynto.sendChat("Type :console to start scripting!");
  137. swoop = false;
  138. }
  139. else
  140. {
  141. Kynto.sendChat("Type :console to start scripting.");
  142. swoop = true;
  143. }
  144. break;
  145.  
  146. case '3':
  147. if (swoop)
  148. {
  149. Kynto.sendChat("Use the big blue ? to call a moderator!");
  150. swoop = false;
  151. }
  152. else
  153. {
  154. Kynto.sendChat("Use the big blue ? to call a moderator.");
  155. swoop = true;
  156. }
  157. break;
  158.  
  159. case 'api':
  160. var APIHelpBox1 = "Kynto.createAlert(MESSAGE)\t/\/\Creates and shows a new alert.";
  161. var APIHelpBox2 = "Kynto.sendChat(MESSAGE)\t/\/\Sends a speech bubble from you.";
  162. if (swoop)
  163. {
  164. Kynto.sendChat(APIHelpBox1);
  165. swoop = false;
  166. }
  167. else
  168. {
  169. Kynto.sendChat(APIHelpBox2);
  170. swoop = true;
  171. }
  172. break;
  173. }
  174. }
  175. }
  176. function botReply(user, msg)
  177. {
  178. commands = msg.split(":");
  179. switch (commands[1])
  180. {
  181. case 'help':
  182. help('help');
  183. break;
  184.  
  185. case 'apihelp':
  186. help('api');
  187. break;
  188.  
  189. case 'help 1':
  190. help('1');
  191. break;
  192.  
  193. case 'help 2':
  194. help('2');
  195. break;
  196.  
  197. case 'help 3':
  198. help('3');
  199. break;
  200. }
  201. }
  202. function addUser(obj)
  203. {
  204. user = obj.U;
  205. if (user != me && botOn)
  206. {
  207. if (swoop)
  208. {
  209. Kynto.sendChat("Welcome to kynto, " + user + "!");
  210. swoop = false;
  211. }
  212. else
  213. {
  214. Kynto.sendChat("Welcome, " + user + "!");
  215. swoop = true;
  216. }
  217. }
  218. }
  219. function userStatus(obj)
  220. {
  221. user = obj.U;
  222. if(obj.S == "online" && user != me && botOn)
  223. {
  224. if (swoop)
  225. {
  226. Kynto.sendChat("Welcome back, " + user + "!");
  227. swoop = false;
  228. }
  229. else
  230. {
  231. Kynto.sendChat("Welcome back, " + user + " :)");
  232. swoop = true;
  233. }
  234. }
  235. }
Add Comment
Please, Sign In to add comment