- "tube [district|circle|metropolitan|central|jubilee|bakerloo|waterloo_city|hammersmith_city|victoria|eastlondon|northern|piccadilly] => display tube service status for the specified line(Docklands Light Railway is not currently supported), tube stations => list tube stations (not lines) with problems"
- end
- def privmsg(m)
- if m.params && m.params =~ /^stations$/
- check_stations m
- elsif m.params && m.params =~ /^(.*)$/
- line = $1.downcase.capitalize
- check_tube m, line
- end
- end
-
- def check_tube(m, line)
- begin
- tube_page = @bot.httputil.get(URI.parse("http://www.tfl.gov.uk/tfl/service_rt_tube.shtml"), 1, 1)
- rescue URI::InvalidURIError, URI::BadURIError => e
- m.reply "Cannot contact Tube Service Status page"
- return
- end
- unless tube_page
- m.reply "Cannot contact Tube Service Status page"
- return
- end
- next_line = false
- tube_page.each_line {|l|
- 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(/<[^>]+>| /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."
+ "tube [district|circle|metropolitan|central|jubilee|bakerloo|waterlooandcity|hammersmithandcity|victoria|eastlondon|northern|piccadilly] => display tube service status for the specified line(Docklands Light Railway is not currently supported)" # , tube stations => list tube stations (not lines) with problems"