Advertisement
Riekelt

Poyofy

May 19th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Declarables:
  2. var buttCounter = 0;
  3. var buttAllow = false;
  4. var wordCounter = 0;
  5. var buttLineLength = 0;
  6. var res = "";
  7.  
  8. //Start command, my thing scans every message and only responds to things starting where the first word is something (splittext[0])
  9. else if (splittext[0] === "!poyofy") {
  10.         if ((user['display-name'] === "Riekeltje") || (user['user-type'] === "mod")) {
  11. //This toggles the automatic poyofyer
  12.             if (splittext[1] === "on") {
  13.                 buttAllow = true;
  14.                 throttledSendMessage(channel, "The poyos are active");
  15.             } else if (splittext[1] === "off") {
  16.                 buttAllow = false;
  17.                 throttledSendMessage(channel, "The poyos are not active anymore.");
  18.             } else {
  19. //This part... It's been a while and I have no idea why this code is double... :thinking:
  20.                 //--
  21.                 buttLineLength = splittext.length;
  22.                 if (buttLineLength > 2) {
  23.                     res = randomIntInc(buttLineLength, 1);
  24.                     message = message.replace(splittext[res - 1], "poyo");
  25.                     message = message.slice(6);
  26.                     throttledSendMessage(channel, message);
  27.                     buttCounter = 0;
  28.                 } else {}
  29.                 //--
  30.             }
  31.         } else {
  32.             //--x
  33.             buttLineLength = splittext.length;
  34.             if (buttLineLength > 2) {
  35.                 res = randomIntInc(buttLineLength, 1);
  36.                 message = message.replace(splittext[res - 1], "poyo");
  37.                 message = message.slice(6);
  38.                 throttledSendMessage(channel, message);
  39.                 buttCounter = 0;
  40.             } else {}
  41.             //--
  42.         }
  43.     }
  44. //REST OF COMMANDS
  45. //Else if no real command is toggled
  46.   } else {
  47.         //After being activated, waits 35 lines until it does the rest again
  48.         if (buttCounter > 35) {
  49.             //If !poyofy is on
  50.             if (buttAllow === true) {
  51.                 //After the 35 lines, there is a 10% chance the script triggers
  52.                 if (randomIntInc(100, 1) > 90) {
  53.                     buttLineLength = splittext.length;
  54.                     if (buttLineLength > 2) {
  55.                         res = randomIntInc(buttLineLength, 1);
  56.                         message = message.replace(splittext[res - 1], "poyo");
  57.                         throttledSendMessage(channel, message);
  58.                         buttCounter = 0;
  59.                     } else {}
  60.                 }
  61.             } else {}
  62.         } else {
  63.             buttCounter++;
  64.         }
  65.     }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. function randomIntInc(high, low) {
  72.     return Math.floor(Math.random() * (high - low + 1) + low);
  73. }
  74.  
  75. //throttledsendmessage makes sure that only 1 message can be send every 5 seconds, you can ignore all of this.
  76. var throttledSendMessage = _.throttle(function(channel, message) {
  77.     client.say(channel, message);
  78. }, 5000, {
  79.     leading: true,
  80.     trailing: false
  81. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement