diff options
author | Dmitry Kim <dmitry point kim at gmail point com> | 2007-09-16 22:36:04 +0000 |
---|---|---|
committer | Dmitry Kim <dmitry point kim at gmail point com> | 2007-09-16 22:36:04 +0000 |
commit | 87e7db2b40eb31b33f27e7c3bb7eeb256724718a (patch) | |
tree | 910f35f3e4dc4dbe1e5a528debfac36b60e69b37 /data/rbot/plugins/url.rb | |
parent | b7d9887aa2fdc2238b8263274fc980ec198ed914 (diff) |
* (plugins/url) get_title_for_url(uri_str, opts={})
Diffstat (limited to 'data/rbot/plugins/url.rb')
-rw-r--r-- | data/rbot/plugins/url.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index 65439178..296ece33 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -57,7 +57,7 @@ class UrlPlugin < Plugin $1.ircify_html end - def get_title_for_url(uri_str, nick = nil, channel = nil, ircline = nil) + def get_title_for_url(uri_str, opts = {}) url = uri_str.kind_of?(URI) ? uri_str : URI.parse(uri_str) return if url.scheme !~ /https?/ @@ -66,10 +66,7 @@ class UrlPlugin < Plugin return "Sorry, info retrieval for #{url.host} is disabled" end - logopts = Hash.new - logopts[:nick] = nick if nick - logopts[:channel] = channel if channel - logopts[:ircline] = ircline if ircline + logopts = opts.dup title = nil extra = String.new @@ -171,7 +168,10 @@ class UrlPlugin < Plugin Thread.start do debug "Getting title for #{urlstr}..." begin - title = get_title_for_url urlstr, m.source.nick, m.channel, m.message + title = get_title_for_url(urlstr, + :nick => m.source.nick, + :channel => m.channel, + :ircline => m.message) if title m.reply "#{LINK_INFO} #{title}", :overlong => :truncate debug "Title found!" @@ -225,7 +225,9 @@ class UrlPlugin < Plugin list[0..(max-1)].each do |url| disp = "[#{url.time.strftime('%Y/%m/%d %H:%M:%S')}] <#{url.nick}> #{url.url}" if @bot.config['url.info_on_list'] - title = url.info || get_title_for_url(url.url, url.nick, channel) rescue nil + title = url.info || + get_title_for_url(url.url, + :nick => url.nick, :channel => channel) rescue nil # If the url info was missing and we now have some, try to upgrade it if channel and title and not url.info ll = @registry[channel] |