-
-
Save slb350/6f37597eea02674a1ee8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (robot) -> | |
| robot.respond /(.*) sara$/i, (msg) -> | |
| msg.http('http://catfacts-api.appspot.com/api/facts?number=1') | |
| .get() (error, response, body) -> | |
| # passes back the complete reponse | |
| response = JSON.parse(body) | |
| if response.success == "true" | |
| sara_message = response.facts[0] | |
| msg.send sara_message.replace /cat/g, "sara" | |
| else | |
| msg.send "Unable to get cat facts right now." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment