What 2 Do? | CoffeeScript | JavaScript |
---|
Create a script | module.exports = (robot) -> | module.exports = function(robot) { } |
listen to all chats | robot.hear /<regular expression here>/ | |
listen to chats addressed to the bot | robot.respond /<regular expression here>/ | robot.respond(/is it (weekend|holiday)\s?\?/i, function(msg){ } |
Matches from regular expression | msg.match[<match number>] | |
Send message in room | msg.send "<message here>" | |
Send message to specific person | msg.respond "<message here>" | |
Make HTTP call | robot.http('<url here>').get() (err, res, body) -> | |
Send random message from a list | msg.send msg.random ['hello', 'hi', 'how do you do'] | |
Detect when user enters or leaves room | robot.enter (msg) -> , robo.leave (msg) -> | |
Access environment variables | process.env.ENVIRONMENT_VARIABLE | |
HTTP Listener | robot.router.post '/hubot/chatsecrets/:room', (req, res) -> | |
Emit and listen to events | robot.emit '<event>' , robot.on '<event>' | |
Persistence interface | robot.brain
| |