Skip to content

Instantly share code, notes, and snippets.

@slb350
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save slb350/6f37597eea02674a1ee8 to your computer and use it in GitHub Desktop.

Select an option

Save slb350/6f37597eea02674a1ee8 to your computer and use it in GitHub Desktop.
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