X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fweather.rb;h=b58354471e302101fe349c51d4b5622b2dc3f100;hb=25dce328a87fcf2af9fa0e1c2da7ed30b7def441;hp=47ab1ca259fe4f330a4bb32563b25770f8c689bd;hpb=9cd035d187a581446fd2cecd333fb214b1182ce8;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index 47ab1ca2..b5835447 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -192,7 +192,7 @@ class WeatherPlugin < Plugin m.reply "couldn't retrieve weather information, sorry" when /City Not Found/ m.reply "no such location found (#{where})" - when // data = "" xml.scan(/
(.*?)<\/table>/m).each do |match| data += wu_weather_filter(match.first) @@ -202,9 +202,8 @@ class WeatherPlugin < Plugin 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(", ") + when //,'') txt.gsub!(/<\/?span[^<>]*?>/,'') txt.gsub!(/]*?>/,'') txt.gsub!(//,'') + txt + end + + def wu_weather_multi(m, xml) + stations = xml.scan(/
\s*(.*?)<\/a>\s*:\s*(.*?)<\/td>/m) + m.reply "multiple stations available, use 'weather station ' or 'weather ' as appropriate, for one of the following (current temp shown):" + stations.map! { |ar| + if ar.first # US state + "%s, %s (%s): %s" % [ar[1], ar[0], ar[2], wu_clean(ar[3])] + else # non-US station + "station %s (%s): %s" % [ar[1], ar[2], wu_clean(ar[3])] + end + } + m.reply stations.join("; ") + end + + def wu_weather_filter(stuff) + txt = wu_clean(stuff) result = Array.new if txt.match(/<\/a>\s*Updated:\s*(.*?)\s*Observed at\s*(.*?)\s*<\/td>/)