if they use the old one # # Commands: # None # module.exports = (robot) -> robot.hear /^hubot:? (.+)/i, (res) -> response = "Sorry, I'm a diva and only respond to #{robot.name}" response += " or #{robot.alias}" if robot.alias res.reply response return 6
be called when hear any ‘badger’ word res.send "Badgers? BADGERS? WE DON'T NEED NO STINKIN BADGERS" # Send a message back to the room robot.respond /open the pod bay doors/i, (res) -> # Will be called when bot was mentioned, ie ‘@hubot: open the pod bay doors’ res.reply "I'm afraid I can't let you do that." # Reply to the person that sent the message Respond and hear 7
of :room is going to vary by adapter, it might be a numeric id, name, token, or some other value robot.router.post '/hubot/chatsecrets/:room', (req, res) -> room = req.params.room data = if req.body.payload? then JSON.parse req.body.payload else req.body secret = data.secret robot.messageRoom room, "I have a secret: #{secret}" res.send 'OK' 9
# Get number of sodas had (coerced to a number). sodasHad = robot.brain.get('totalSodas') * 1 or 0 if sodasHad > 4 res.reply "I'm too fizzy.." else res.reply 'Sure!' robot.brain.set 'totalSodas', sodasHad+1 robot.respond /sleep it off/i, (res) -> robot.brain.set 'totalSodas', 0 msg.reply 'zzzzz' 10