]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
weather: fix url detection for multiple stations/sites
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 9 May 2011 09:47:26 +0000 (11:47 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 9 May 2011 09:47:26 +0000 (11:47 +0200)
data/rbot/plugins/weather.rb

index 8f59a9ba693eea6f98c61a3f42d69fe53f4a29a2..0d3abee27071cfc61de190ba0c47ef7dc7f92da2 100644 (file)
@@ -211,7 +211,7 @@ class WeatherPlugin < Plugin
           m.reply "couldn't parse weather data from #{where}"
         end
         wu_out_special(m, xml)
-      when /<a href="\/(?:global\/stations|US\/\w\w)\//
+      when /<a href="\/auto\/mobile[^\/]+\/(?:global\/stations|[A-Z][A-Z])\//
         wu_weather_multi(m, xml)
       else
         debug xml
@@ -224,7 +224,7 @@ class WeatherPlugin < Plugin
 
   def wu_weather_multi(m, xml)
     # debug xml
-    stations = xml.scan(/<td>\s*(?:<a href="([^?"]+\?feature=[^"]+)"\s*[^>]*><img [^>]+><\/a>\s*)?<a href="\/(?:global\/stations|US\/(\w\w))\/([^"]*?)\.html">(.*?)<\/a>\s*:\s*(.*?)<\/td>/m)
+    stations = xml.scan(/<td>\s*(?:<a href="([^?"]+\?feature=[^"]+)"\s*[^>]*><img [^>]+><\/a>\s*)?<a href="\/auto\/mobile[^\/]+\/(?:global\/stations|([A-Z][A-Z]))\/([^"]*?)\.html">(.*?)<\/a>\s*:\s*(.*?)<\/td>/m)
     # debug stations
     m.reply "multiple stations available, use 'weather station <code>' or 'weather <city, state>' as appropriate, for one of the following (current temp shown):"
     stations.map! { |ar|