Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
83
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. #userEnteredJokeList = robot.brain.get('jokeList')
  27.  
  28. #if robot.brain.get('jokeList') is not null
  29. #   jokeList.push robot.brain.get('jokeList')
  30.  
  31. #if userEnteredJokeList is null
  32. #   userEnteredJokeList = []
  33.  
  34. module.exports = (robot) ->
  35.    robot.respond /Q:(.*)A:(.*)/, (msg) ->
  36.       jokeFirstPart = msg.match[1]
  37.       jokeSecondPart = msg.match[2]
  38.       msg.send ":P. That is funny indeed. Saving it in memory..."
  39.       setTimeout () ->
  40.          msg.send "Done"
  41.       ,1000
  42.       tempJoke = [jokeFirstPart, jokeSecondPart]
  43.       jokeList.push tempJoke
  44. #      userEnteredJokeList.push tempJoke
  45. #      robot.brain.set('jokeList') userEnteredJokeList
  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. #      robot.brain.set('jokeList') null
  61. #      userEnteredJokeList = []
  62. #      jokeList = jokeList[0..12]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement