From c6b7a60b7cca32037372bedbf36587e4e250e430 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 27 Mar 2008 00:02:33 +0100 Subject: weather plugin: echo special advisories if present --- data/rbot/plugins/weather.rb | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'data/rbot/plugins') diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index ff5f0537..4f89e08d 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -173,8 +173,9 @@ class WeatherPlugin < Plugin m.reply "no such station found (#{where})" return when /(.*?)<\/table>/m - data = $1 + data = $1.dup m.reply wu_weather_filter(data) + wu_out_special(m, xml) else debug xml m.reply "something went wrong with the data for #{where}..." @@ -202,6 +203,7 @@ class WeatherPlugin < Plugin else m.reply "couldn't parse weather data from #{where}" end + wu_out_special(m, xml) when /]*>([^<]+)}) + special = { + :url => "http://mobile.wunderground.com"+$1, + :special => $2.dup + } + spec_xml = @bot.httputil.get(special[:url]) + if spec_xml and spec_td = spec_xml.match(/\s*
\s*(.*?)\s*<\/td>\s*<\/tr>\s*<\/table>/m) + return special.merge(:text => $1.ircify_html) + else + return special + end + else + return nil + end + end + + def wu_out_special(m, xml) + special = wu_check_special(xml).merge(:underline => Underline) + if special + if special[:text] + m.reply("%{underline}%{special}%{underline}: %{text}" % special) + else + m.reply("%{underline}%{special}%{underline} @ %{url}" % special) + end + end + end + def wu_weather_filter(stuff) txt = wu_clean(stuff) -- cgit v1.2.3