Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 32 lines (29 sloc) 0.805 kB
50796ea @tombell Update "h" scripts help comments
tombell authored
1 # Description:
2 # None
3 #
4 # Dependencies:
5 # None
6 #
7 # Configuration:
8 # None
9 #
10 # Commands:
11 # hubot horse - Display a randomly selected insight on the world from Horse_Ebooks
12 #
13 # Author:
14 # lavelle
078c083 @lavelle Add horse_ebooks module
lavelle authored
15
16 module.exports = (robot) ->
17 robot.respond /horse/i, (msg) ->
18 url = 'http://api.twitter.com/1/statuses/user_timeline.json'
19 msg
20 .http(url)
21 .query
22 screen_name: 'horse_ebooks'
23 count: 10
24 .get() (err, res, body) ->
25 tweets = JSON.parse(body)
26
27 if tweets? and tweets.length > 0
28 n = Math.floor Math.random() * tweets.length or 0
29 msg.send(tweets[n].text)
30 else
31 msg.reply "Couldn't find any insights for you this time"
Something went wrong with that request. Please try again.