From 83cb5754e808afc77ac625ef66e5ff128ee00d4f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 18 Sep 2007 06:15:47 +0000 Subject: [PATCH] HTML processing refactoring: ensure HTML title works with and without Hpricot --- lib/rbot/core/utils/extends.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index 0b07257a..dcc257a2 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -182,15 +182,18 @@ class ::String # This method tries to find an HTML title in the string, # and returns it if found def get_html_title - return unless Irc::Utils::TITLE_REGEX.match(self) - $1 + if defined? ::Hpricot + Hpricot(self).at("title").inner_html + else + return unless Irc::Utils::TITLE_REGEX.match(self) + $1 + end end # This method returns the IRC-formatted version of an # HTML title found in the string def ircify_html_title - return unless Irc::Utils::TITLE_REGEX.match(self) - $1.ircify_html + self.get_html_title.ircify_html rescue nil end end -- 2.39.2