Skip to content

Commit

Permalink
weather in PLACE
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Dec 14, 2010
1 parent cdbb961 commit b4a1d9f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion botart.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,21 @@ hear /about/, (message) ->
message.say "I am learning to love."

hear /help/, (message) ->
message.say "I listen for '@#{username} image me PHRASE' and '@#{username} wiki me PHRASE'"
message.say "I listen for '@#{username} image me PHRASE' and '@#{username} wiki me PHRASE' and '@#{username} weather in PLACE'"

hear /weather in (.+)/i, (message) ->
place = message.match[1]
url = "http://www.google.com/ig/api?weather=#{escape place}"

get url, (body) ->
try
console.log body
if match = body.match(/<current_conditions>(.+?)<\/current_conditions>/)
icon = match[1].match(/<icon data="(.+?)"/)
degrees = match[1].match(/<temp_f data="(\d+?)"/)
message.say "#{degrees[1]}° — http://www.google.com#{icon[1]}"
catch e
console.log "Weather error: " + e

hear /wiki me (.*)/i, (message) ->
term = escape(message.match[1])
Expand Down

0 comments on commit b4a1d9f

Please sign in to comment.