summaryrefslogtreecommitdiff
path: root/rbot
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-21 11:02:04 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-21 11:02:04 +0000
commite3c4d9ad30b8548c09dd7d26abdfeef223c23f40 (patch)
tree9a22304ff2b491827ac52d62f1d897eeebad6696 /rbot
parent73eb00417fdeff67e7bc46d806b16ab34cf74f09 (diff)
rework the tube plugin's html parser a bit, to enable it to work properly
with tricky station names, such as hammersmity & city.
Diffstat (limited to 'rbot')
-rw-r--r--rbot/plugins/tube.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/rbot/plugins/tube.rb b/rbot/plugins/tube.rb
index 98b90c6c..77ca5227 100644
--- a/rbot/plugins/tube.rb
+++ b/rbot/plugins/tube.rb
@@ -29,26 +29,27 @@ class TubePlugin < Plugin
m.reply "Cannot contact Tube Service Status page"
return
end
+ next_line = false
tube_page.each_line {|l|
- if (l =~ /class="#{line}"/i)
- tube_page.each_line { |l2|
- if (l2 =~ /^<tr valign=top> <td>\s*(.*#{line}.*)<\/td><\/tr>/i)
- problem_message = Array.new
- problem_message = $1.split(/<[^>]+>|&nbsp;/i)
- m.reply problem_message.join(" ")
- return
- end
- }
+ next if l == "\r\n"
+ next if l == "\n"
+ if (next_line)
+ if (l =~ /^<tr valign=top> <td>\s*(.*)<\/td><\/tr>/i)
+ m.reply $1.split(/<[^>]+>|&nbsp;/i).join(" ")
+ return
+ else
m.reply "There are problems on the #{line} line, but I didn't understand the page format. You should check out http://www.tfl.gov.uk/tfl/service_rt_tube.shtml for more details."
return
end
- }
+ end
+ next_line = true if (l =~ /class="#{line}"/i)
+ }
m.reply "No Problems on the #{line} line."
end
def check_stations(m)
begin
- tube_page = Utils.http_get("http://www.tfl.gov.uk/tfl/service_rt_tube.shtml")
+ tube_page = @bot.httputil.get(URI.parse("http://www.tfl.gov.uk/tfl/service_rt_tube.shtml"))
rescue URI::InvalidURIError, URI::BadURIError => e
m.reply "Cannot contact Tube Service Status page"
return