Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Description
  2. #   Tells the user a joke.
  3. #
  4. # Commands:
  5. #   "nameOfBot:" followed by "joke" in a sentence
  6. #   Example -> GooeyJrVaibhav: Joke, please.
  7. #
  8. # Author:
  9. #   VaibhavBajaj (https://github.com/VaibhavBajaj)
  10.  
  11. jokeList = [
  12.             ["Who is the hide and seek champion since 1958?", ";"],
  13.             ["I'm on a whiskey diet. Guess what.", "I've lost three days already."],
  14.             ["A seal walks into a club... ", "... That's it really"],
  15.             ["Did you hear about the guy whose whole left side was cut off?", "He's all right now."],
  16.             ["How many programmers does it take to change a light bulb?", "None, that's a hardware problem"],
  17.             ["If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.", "The rest of them will write Perl programs."],
  18.             ["To understand what recursion is...", "you must first understand recursion."],
  19.             ["So this programmer goes out on a date with a hot chick", "Hahahaha ... okay, I'm okay now... Hahahahahhahahah!!"],
  20.             ["Why don't jokes work in octal?", "Because 7 10 11."],
  21.             ["Keyboard not found ...", "Press F1 to continue"],
  22.             ["I never make mistakes.I thought I did once...", "But I was wrong."],
  23.             ["If you understand English, press 1. If you do not understand English, press 2.", "Get it? :D"]
  24.       ]
  25.  
  26.  
  27. module.exports = (robot) ->
  28.    userEnteredJokeList = robot.brain.get 'jokeList'
  29.    if userEnteredJokeList is null
  30.       userEnteredJokeList = []
  31.  
  32.    for joke in userEnteredJokeList
  33.       jokeList.push joke
  34.  
  35.    robot.respond /.*Q:(.*)A:(.*)/, (msg) ->
  36.       jokeFirstPart = msg.match[1]
  37.       jokeSecondPart = msg.match[2]
  38.       tempJoke = [jokeFirstPart, jokeSecondPart]
  39.       jokeList.push tempJoke
  40.       userEnteredJokeList.push tempJoke
  41.       robot.brain.set 'jokeList', userEnteredJokeList
  42.       msg.send ":P. That is funny indeed. Saving it in memory... Done"
  43.  
  44.    robot.respond /(.*)joke[^s](.*)/i, (msg) ->
  45.       msg.send "Joke? Joke! I know a JOKE!"
  46.       joke = msg.random jokeList
  47.       msg.send joke[0]
  48.       setTimeout () ->
  49.          msg.send joke[1]
  50.       ,4000
  51.       msg.send userEnteredJokeList
  52.  
  53.    robot.respond /how (should|do|can) i (save|store|add) jokes.*/i, (msg) ->
  54.       msg.send "Please enter a two-part joke with 'Q:'' to indicate question and 'A:' to indicate concluding sentence like so:"
  55.       msg.send "Q:Did you hear about the guy whose whole left side was cut off? A: He's all right now."
  56.  
  57.    robot.respond /refresh jokes memory/i, (msg) ->
  58.       msg.send "Clearing up data... Done"
  59.       robot.brain.remove 'jokeList'
  60.       userEnteredJokeList = []
  61.       jokeList = jokeList[0..12]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement