From b4a1d9f6e1d5ea3fba34879da2ed8b2aa5cb5d0e Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 14 Dec 2010 03:56:35 -0800 Subject: [PATCH] weather in PLACE --- botart.coffee | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/botart.coffee b/botart.coffee index 924c36b..f894bd6 100644 --- a/botart.coffee +++ b/botart.coffee @@ -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>/) + icon = match[1].match(/ term = escape(message.match[1])