From 03a565c6f6a11e950f66b7aa159de86c2119efee Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 26 Mar 2008 22:17:18 +0100 Subject: weather plugin: properly support and signal multiple weather stations when one has a special statement --- data/rbot/plugins/weather.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index b5835447..ff5f0537 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -226,13 +226,20 @@ class WeatherPlugin < Plugin end def wu_weather_multi(m, xml) - stations = xml.scan(/\s*(.*?)<\/a>\s*:\s*(.*?)<\/td>/m) + # debug xml + stations = xml.scan(/\s*(?:]*>]+><\/a>\s*)?(.*?)<\/a>\s*:\s*(.*?)<\/td>/m) + # debug stations 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])] + warning = ar[0] + loc = ar[2] + state = ar[1] + par = ar[3] + w = ar[4] + if state # US station + (warning ? "*" : "") + ("%s, %s (%s): %s" % [loc, state, par, wu_clean(w)]) else # non-US station - "station %s (%s): %s" % [ar[1], ar[2], wu_clean(ar[3])] + (warning ? "*" : "") + ("station %s (%s): %s" % [loc, par, wu_clean(w)]) end } m.reply stations.join("; ") -- cgit v1.2.3