summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/url.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index 2b5b468e..3fa9f62d 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -30,9 +30,13 @@ class UrlPlugin < Plugin
"[Link Info] title: #{title}"
end
- def get_title_for_url(uri_str)
+ def get_title_for_url(uri_str, depth=10)
# This god-awful mess is what the ruby http library has reduced me to.
# Python's HTTP lib is so much nicer. :~(
+
+ if depth == 0
+ raise "Error: Maximum redirects hit."
+ end
puts "+ Getting #{uri_str}"
url = URI.parse(uri_str)
@@ -50,7 +54,7 @@ class UrlPlugin < Plugin
puts "+ redirect location: #{redirect_to}"
url = URI.join url.to_s, redirect_to
puts "+ whee, redirecting to #{url.to_s}!"
- title = get_title_for_url(url.to_s)
+ title = get_title_for_url(url.to_s, depth-1)
when Net::HTTPSuccess then
if head['content-type'] =~ /^text\// and (not head['content-length'] or head['content-length'].to_i < 400000)
# since the content is 'text/*' and is small enough to