X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fweather.rb;h=b58354471e302101fe349c51d4b5622b2dc3f100;hb=25dce328a87fcf2af9fa0e1c2da7ed30b7def441;hp=4ff92769b5c710f87aaca7ebe3d031f21536be89;hpb=60c45f4da1d3a299d61698cbf7a1cdd232e6133c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index 4ff92769..b5835447 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -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>/)