Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
72
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.  
  28. module.exports = (robot) ->
  29. #   userEnteredJokeList = robot.brain.get('jokeList')
  30.  
  31. #   if robot.brain.get('jokeList') is not null
  32. #      jokeList.push robot.brain.get('jokeList')
  33.  
  34.    if userEnteredJokeList is null
  35.       userEnteredJokeList = []
  36.    robot.respond /.*Q:(.*)A:(.*)/, (msg) ->
  37.       jokeFirstPart = msg.match[1]
  38.       jokeSecondPart = msg.match[2]
  39.       msg.send ":P. That is funny indeed. Saving it in memory... Done"
  40.       tempJoke = [jokeFirstPart, jokeSecondPart]
  41.       jokeList.push tempJoke
  42.  #     userEnteredJokeList.push tempJoke
  43.  #     robot.brain.set('jokeList') userEnteredJokeList
  44.  #     msg.send robot.brain.get('jokeList')[0]
  45.  #     msg.send userEnteredJokeList[0]
  46.  
  47.    robot.respond /(.*)joke[^s](.*)/i, (msg) ->
  48.       msg.send "Joke? Joke! I know a JOKE!"
  49.       joke = msg.random jokeList
  50.       msg.send joke[0]
  51.       setTimeout () ->
  52.          msg.send joke[1]
  53.       ,4000
  54.  
  55.    robot.respond /how do i (save|store) jokes\?/i, (msg) ->
  56.       msg.send "Please enter a two-part joke with 'Q:'' to indicate question and 'A:' to indicate concluding sentence like so:"
  57.       msg.send "Q:Did you hear about the guy whose whole left side was cut off? A: He's all right now."
  58.  
  59.    robot.respond /refresh jokes memory/i, (msg) ->
  60.       msg.send "Clearing up data... Done"
  61. #      robot.brain.remove('jokeList')
  62. #      userEnteredJokeList = []
  63. #      jokeList = jokeList[0..12]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement