X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fweather.rb;h=4ff92769b5c710f87aaca7ebe3d031f21536be89;hb=60c45f4da1d3a299d61698cbf7a1cdd232e6133c;hp=88194e9067ca5ace3c15c60d23d8c9d4f029a95a;hpb=edd1cf77be07ae507014574141e920ad23eb164d;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index 88194e90..4ff92769 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -11,7 +11,6 @@ # # License:: GPL v2 -require 'uri' require 'rexml/document' # Wraps NOAA National Weather Service information @@ -165,7 +164,7 @@ class WeatherPlugin < Plugin def wu_station(m, where, units) begin - xml = @bot.httputil.get_cached(@wu_station_url % [units, URI.escape(where)]) + xml = @bot.httputil.get(@wu_station_url % [units, CGI.escape(where)]) case xml when nil m.reply "couldn't retrieve weather information, sorry" @@ -187,17 +186,22 @@ class WeatherPlugin < Plugin def wu_weather(m, where, units) begin - xml = @bot.httputil.get_cached(@wu_url % [units, URI.escape(where)]) + xml = @bot.httputil.get(@wu_url % [units, CGI.escape(where)]) case xml when nil m.reply "couldn't retrieve weather information, sorry" - return when /City Not Found/ m.reply "no such location found (#{where})" - return - when /(.*?)<\/table>/m - data = $1 - m.reply wu_weather_filter(data) + when /Current<\/a>/ + data = "" + xml.scan(/
(.*?)<\/table>/m).each do |match| + data += wu_weather_filter(match.first) + end + if data.length > 0 + m.reply data + else + m.reply "couldn't parse weather data from #{where}" + end when //) m.reply "multiple stations available, use 'weather station ' where code is one of " + stations.join(", ")