Skip to content
Newer
Older
100644 32 lines (29 sloc) 973 Bytes
393034c @aaronott Adding f-ing weather.
aaronott authored
1 # Description:
2 # Returns the weather from thefuckingweather.com
3 #
4 # Dependencies:
5 # None
6 #
7 # Configuration:
8 # None
9 #
10 # Commands:
11 # hubot what's the weather for <city> - Get the weather for a location
12 # hubot what's the weather for <zip> - Get the weather for a zipcode
13 #
14 # Author:
15 # aaronott
16
17 weather = (msg, query, cb) ->
18 msg.http('http://thefuckingweather.com/')
19 .query(where: query)
20 .header('User-Agent', 'Mozilla/5.0')
21 .get() (err, res, body) ->
22 temp = body.match(/<span class="temperature" tempf="\d*">(\d+)/)?[1] || ""
23 remark = body.match(/<p class="remark">(.*)</)?[1] || "remark not found"
24 flavor = body.match(/<p class="flavor">(.*)</)?[1] || "flavor not found"
25 cb(temp, remark, flavor)
26
27 module.exports = (robot) ->
28 robot.respond /(what's|what is) the weather for (.*)/i, (msg) ->
29 weather msg, msg.match[2], (temp, remark, flavor) ->
30 out = temp + " degrees " + remark + " " + flavor
31 msg.send out
Something went wrong with that request. Please try again.