summaryrefslogtreecommitdiff
path: root/lib/rbot/plugins/tube.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-10 23:51:00 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-10 23:51:00 +0100
commit6e75d722a918654642d01b52018b97e84bee3180 (patch)
tree497b0406db6e8ee433012666ae955c8a00eb1f12 /lib/rbot/plugins/tube.rb
parent1ae131c231c308f13eaed68a3564c19f7eb7f2f1 (diff)
svn import left spurious lib/rbot/plugins hanging around
Diffstat (limited to 'lib/rbot/plugins/tube.rb')
-rw-r--r--lib/rbot/plugins/tube.rb77
1 files changed, 0 insertions, 77 deletions
diff --git a/lib/rbot/plugins/tube.rb b/lib/rbot/plugins/tube.rb
deleted file mode 100644
index 77ca5227..00000000
--- a/lib/rbot/plugins/tube.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-#Tube Status Enquiry plugin for rbot
-#Plugin by Colm Linehan
-
-require 'rexml/document'
-require 'uri/common'
-
-class TubePlugin < Plugin
- include REXML
- def help(plugin, topic="")
- "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(/<[^>]+>|&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 = @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
- end
- unless tube_page
- m.reply "Cannot contact Tube Service Status page"
- return
- end
- stations_array = Array.new
- tube_page.each_line {|l|
- if (l =~ /<tr valign=top> <td valign="middle" class="Station"><b>(.*)<\/b><\/td><\/tr>\s*/i)
- stations_array.push $1
- end
- }
- if stations_array.empty?
- m.reply "There are no station-specific announcements"
- return
- else
- m.reply stations_array.join(", ")
- return
- end
- end
-end
-plugin = TubePlugin.new
-plugin.register("tube")