example.coffee 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Description:
  2. # Example scripts for you to examine and try out.
  3. #
  4. # Notes:
  5. # They are commented out by default, because most of them are pretty silly and
  6. # wouldn't be useful and amusing enough for day to day huboting.
  7. # Uncomment the ones you want to try and experiment with.
  8. #
  9. # These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md
  10. module.exports = (robot) ->
  11. # robot.hear /badger/i, (msg) ->
  12. # msg.send "Badgers? BADGERS? WE DON'T NEED NO STINKIN BADGERS"
  13. #
  14. # robot.respond /open the (.*) doors/i, (msg) ->
  15. # doorType = msg.match[1]
  16. # if doorType is "pod bay"
  17. # msg.reply "I'm afraid I can't let you do that."
  18. # else
  19. # msg.reply "Opening #{doorType} doors"
  20. #
  21. # robot.hear /I like pie/i, (msg) ->
  22. # msg.emote "makes a freshly baked pie"
  23. #
  24. # lulz = ['lol', 'rofl', 'lmao']
  25. #
  26. # robot.respond /lulz/i, (msg) ->
  27. # msg.send msg.random lulz
  28. #
  29. # robot.topic (msg) ->
  30. # msg.send "#{msg.message.text}? That's a Paddlin'"
  31. #
  32. #
  33. # enterReplies = ['Hi', 'Target Acquired', 'Firing', 'Hello friend.', 'Gotcha', 'I see you']
  34. # leaveReplies = ['Are you still there?', 'Target lost', 'Searching']
  35. #
  36. # robot.enter (msg) ->
  37. # msg.send msg.random enterReplies
  38. # robot.leave (msg) ->
  39. # msg.send msg.random leaveReplies
  40. #
  41. # answer = process.env.HUBOT_ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING
  42. #
  43. # robot.respond /what is the answer to the ultimate question of life/, (msg) ->
  44. # unless answer?
  45. # msg.send "Missing HUBOT_ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING in environment: please set and try again"
  46. # return
  47. # msg.send "#{answer}, but what is the question?"
  48. #
  49. # robot.respond /you are a little slow/, (msg) ->
  50. # setTimeout () ->
  51. # msg.send "Who you calling 'slow'?"
  52. # , 60 * 1000
  53. #
  54. # annoyIntervalId = null
  55. #
  56. # robot.respond /annoy me/, (msg) ->
  57. # if annoyIntervalId
  58. # msg.send "AAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEIIIIIIIIHHHHHHHHHH"
  59. # return
  60. #
  61. # msg.send "Hey, want to hear the most annoying sound in the world?"
  62. # annoyIntervalId = setInterval () ->
  63. # msg.send "AAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEIIIIIIIIHHHHHHHHHH"
  64. # , 1000
  65. #
  66. # robot.respond /unannoy me/, (msg) ->
  67. # if annoyIntervalId
  68. # msg.send "GUYS, GUYS, GUYS!"
  69. # clearInterval(annoyIntervalId)
  70. # annoyIntervalId = null
  71. # else
  72. # msg.send "Not annoying you right now, am I?"
  73. #
  74. #
  75. # robot.router.post '/hubot/chatsecrets/:room', (req, res) ->
  76. # room = req.params.room
  77. # data = JSON.parse req.body.payload
  78. # secret = data.secret
  79. #
  80. # robot.messageRoom room, "I have a secret: #{secret}"
  81. #
  82. # res.send 'OK'
  83. #
  84. # robot.error (err, msg) ->
  85. # robot.logger.error "DOES NOT COMPUTE"
  86. #
  87. # if msg?
  88. # msg.reply "DOES NOT COMPUTE"
  89. #
  90. # robot.respond /have a soda/i, (msg) ->
  91. # # Get number of sodas had (coerced to a number).
  92. # sodasHad = robot.brain.get('totalSodas') * 1 or 0
  93. #
  94. # if sodasHad > 4
  95. # msg.reply "I'm too fizzy.."
  96. #
  97. # else
  98. # msg.reply 'Sure!'
  99. #
  100. # robot.brain.set 'totalSodas', sodasHad+1
  101. #
  102. # robot.respond /sleep it off/i, (msg) ->
  103. # robot.brain.set 'totalSodas', 0
  104. # robot.respond 'zzzzz'