Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit d84bc01

Browse files
author
Tom Bell
committed
Merge pull request #734 from scottmeyer/master
Added a cat facts plugin
2 parents f2e8569 + 230b088 commit d84bc01

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/scripts/catfacts.coffee

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Description:
2+
# Retrieves random cat facts.
3+
#
4+
# Dependencies:
5+
# None
6+
#
7+
# Configuration:
8+
# None
9+
#
10+
# Commands:
11+
# hubot catfact - Reply back with random cat fact.
12+
#
13+
# Author:
14+
# scottmeyer
15+
16+
module.exports = (robot) ->
17+
robot.respond /CATFACT$/i, (msg) ->
18+
msg.http('http://catfacts-api.appspot.com/api/facts?number=1')
19+
.get() (error, response, body) ->
20+
# passes back the complete reponse
21+
response = JSON.parse(body)
22+
if response.success == "true"
23+
msg.send response.facts[0]
24+
else
25+
msg.send "Unable to get cat facts right now."
26+
27+

0 commit comments

Comments
 (0)