diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-18 06:15:54 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-18 06:15:54 +0000 |
commit | f9b22f53301e5dcb9078aa13efe3dbe93eca0ea5 (patch) | |
tree | 6a4e89380375daade73d22cf6523e04e36874273 /lib/rbot | |
parent | b1debac35f5e45545066da07027ddaaf6c9faca7 (diff) |
HTML processing refactoring: Utils.get_first_pars now uses Utils.get_html_info
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/utils/utils.rb | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb index 8c23b2cf..a9844d6b 100644 --- a/lib/rbot/core/utils/utils.rb +++ b/lib/rbot/core/utils/utils.rb @@ -757,25 +757,20 @@ module ::Irc # FIXME what happens if some big file is returned? We should share # code with the url plugin to only retrieve partial file content! - xml = self.bot.httputil.get(url) - if xml.nil? - debug "Unable to retrieve #{url}" - next - end - par = Utils.ircify_first_html_par(xml, opts) - if par.empty? - debug "No first par found\n#{xml}" - # FIXME only do this if the 'url' plugin is loaded - # TODO even better, put the code here - # par = @bot.plugins['url'].get_title_from_html(xml) - if par.empty? - retval.push(nil) - next + begin + info = Utils.get_html_info(URI.parse(url), opts) + + par = info[:content] + retval.push(par) + + if par + msg.reply "[#{idx}] #{par}", :overlong => :truncate if msg + count -=1 end + rescue + debug "Unable to retrieve #{url}: #{$!}" + next end - msg.reply "[#{idx}] #{par}", :overlong => :truncate if msg - count -=1 - retval.push(par) end return retval end |